[Schmitzm-commits] r271 - trunk/src/schmitzm/jfree/chart

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Aug 1 17:36:10 CEST 2009


Author: mojays
Date: 2009-08-01 17:36:09 +0200 (Sat, 01 Aug 2009)
New Revision: 271

Added:
   trunk/src/schmitzm/jfree/chart/ChangableLegendItem.java
Log:
ups... forgot the new ChangableLegendItem (fortunately currently unused)

Added: trunk/src/schmitzm/jfree/chart/ChangableLegendItem.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/ChangableLegendItem.java	2009-08-01 15:35:52 UTC (rev 270)
+++ trunk/src/schmitzm/jfree/chart/ChangableLegendItem.java	2009-08-01 15:36:09 UTC (rev 271)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Krüger - additional utility classes
+ ******************************************************************************/
+package schmitzm.jfree.chart;
+
+import org.jfree.chart.LegendItem;
+
+/**
+ * This class extents the {@link LegendItem} with functionalities to
+ * change the following legend item properties.
+ * <ul>
+ *   <li>legend item label</li>
+ *   <li>legend item description</li>
+ *   <li>legend item tooltip</li>
+ * </ul>  
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ */
+public class ChangableLegendItem extends LegendItem {
+  /** Holds the label shown in the legend. Unfortunately the
+   *  super class variable is private. */
+  protected String label = "";
+  /** Holds the description of the legend item. Unfortunately the
+   *  super class variable is private. */
+  protected String description = null;
+  /** Holds the tooltip of the legend item. Unfortunately the
+   *  super class variable is private. */
+  protected String toolTipText = null;
+  
+  /**
+   * Creates a new legend item
+   * @param item sample legend item
+   */
+  public ChangableLegendItem(String label) {
+    super("LegendItem.label not used!");
+    setLabel(label);
+  }
+
+  /**
+   * Creates a new legend item
+   * @param item sample legend item
+   */
+  public ChangableLegendItem(LegendItem item) {
+    super(
+        "LegendItem.label not used!", // we use our own variable for label
+        "LegendItem.description not used", // we use our own variable for description
+        "LegendItem.toolTipText not used", // we use our own variable for tooltip
+        item.getURLText(),
+        item.isShapeVisible(),
+        item.getShape(),
+        item.isShapeFilled(),
+        item.getFillPaint(),
+        item.isShapeOutlineVisible(),
+        item.getOutlinePaint(),
+        item.getOutlineStroke(),
+        item.isLineVisible(),
+        item.getLine(),
+        item.getLineStroke(),
+        item.getLinePaint()
+    );
+    setLabel(item.getLabel());
+    setDescription(item.getDescription());
+    setToolTipText(item.getToolTipText());
+    setDataset(item.getDataset());
+    setDatasetIndex(item.getDatasetIndex());
+    setSeriesKey(item.getSeriesKey());
+  }
+
+  /**
+   * Returns the label shown in the legend.
+   */
+  @Override
+  public String getLabel() {
+    return this.label;
+  }
+  
+  /**
+   * Sets the label shown in the legend.
+   * @param label the new label.
+   */
+  public void setLabel(String label) {
+    this.label = label;
+  }
+
+  /**
+   * Returns the description of the legend item.
+   */
+  @Override
+  public String getDescription() {
+    return this.label;
+  }
+  
+  /**
+   * Sets the description of the legend item.
+   * @param desc the new description.
+   */
+  public void setDescription(String desc) {
+    this.description = desc;
+  }
+
+  /**
+   * Returns the tooltip of the legend item.
+   */
+  @Override
+  public String getToolTipText() {
+    return this.toolTipText;
+  }
+  
+  /**
+   * Sets the tooltip of the legend item.
+   * @param desc the new tooltip.
+   */
+  public void setToolTipText(String tooltip) {
+    this.toolTipText = tooltip;
+  }
+}



More information about the Schmitzm-commits mailing list