[Schmitzm-commits] r269 - in trunk/src/schmitzm: jfree jfree/chart/style jfree/feature/style xml

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


Author: mojays
Date: 2009-08-01 17:33:38 +0200 (Sat, 01 Aug 2009)
New Revision: 269

Modified:
   trunk/src/schmitzm/jfree/JFreeChartUtil.java
   trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
   trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
   trunk/src/schmitzm/xml/XMLUtil.java
Log:
Legend properties for series in ChartRendererStyle and ChartStyleXMLFactory.

Modified: trunk/src/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/JFreeChartUtil.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/jfree/JFreeChartUtil.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -94,12 +94,12 @@
    *  hinterlegt. */
   public static ResourceProvider RESOURCE = new ResourceProvider( LangUtil.extendPackagePath(JFreeChartUtil.class,"resource.locales.JFreeResourceBundle"), Locale.ENGLISH );
 
-	/**
-	 * Convenience method to access the {@link ResourceProvider}.
-	*/
-	public static String R(String key, Object... values) {
-		return RESOURCE.getString(key, values);
-	}
+  /**
+   * Convenience method to access the {@link ResourceProvider}.
+   */
+  public static String R(String key, Object... values) {
+    return RESOURCE.getString(key, values);
+  }
 
   /** Instance of {@link ChartStyleXMLFactory}. */
   public static final ChartStyleXMLFactory<ChartStyle> CHART_STYLE_FACTORY = new ChartStyleXMLFactory<ChartStyle>();

Modified: trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -46,6 +46,9 @@
 
 import org.apache.log4j.Category;
 import org.jfree.chart.JFreeChart;
+import org.jfree.chart.LegendItem;
+import org.jfree.chart.LegendItemCollection;
+import org.jfree.chart.LegendItemSource;
 import org.jfree.chart.axis.Axis;
 import org.jfree.chart.labels.CategoryToolTipGenerator;
 import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
@@ -57,6 +60,7 @@
 import org.jfree.chart.renderer.AbstractRenderer;
 import org.jfree.chart.renderer.category.CategoryItemRenderer;
 import org.jfree.chart.renderer.xy.XYItemRenderer;
+import org.jfree.chart.title.LegendTitle;
 import org.jfree.chart.title.TextTitle;
 import org.jfree.chart.urls.CategoryURLGenerator;
 import org.jfree.chart.urls.StandardCategoryURLGenerator;
@@ -64,6 +68,7 @@
 import org.jfree.chart.urls.XYURLGenerator;
 
 import schmitzm.jfree.JFreeChartUtil;
+import schmitzm.jfree.chart.ChangableLegendItem;
 import schmitzm.lang.LangUtil;
 
 /**
@@ -405,6 +410,41 @@
       }
     }
     
+//    // style the legend (by the series properties of ChartRendererStyle!!)
+//    LegendTitle legend = chart.getLegend();
+//    if ( legend != null && legend.getSources().length > 0 ) {
+//      final LegendItemSource[]   legendSource = legend.getSources();      
+//      final LegendItemCollection oldLegend    = legendSource[0].getLegendItems();      
+//      // redefine the primary legend
+//      legendSource[0] = new LegendItemSource() {
+//        public LegendItemCollection getLegendItems() {
+//          LegendItemCollection lic = new LegendItemCollection();
+//          for (int i=0 ; i<oldLegend.getItemCount(); i++ ) {
+//            // create a changeable copy of the legend item
+//            LegendItem          legendItem     = oldLegend.get(i);
+//            ChangableLegendItem changeableItem = null;
+//            if ( legendItem instanceof ChangableLegendItem )
+//              changeableItem = (ChangableLegendItem)legendItem;
+//            else
+//              changeableItem = new ChangableLegendItem( legendItem );
+//            
+//            // restyle the legend item according to the renderer style
+//            int rendererIdx              = newItem.getDatasetIndex();
+//            int seriesIdx                = newItem.getSeriesIndex();
+//            ChartRendererStyle rendStyle = getRendererStyle(rendererIdx);
+//            if ( rendStyle != null ) {
+//              if ( rendStyle.getSeriesLegendLabel(seriesIdx) != null )
+//                newItem.setLabel(rendStyle.getSeriesLegendLabel(seriesIdx).getLabel());
+//              if ( rendStyle.getSeriesLegendTooltip(seriesIdx) != null )
+//                newItem.setToolTipText(rendStyle.getSeriesLegendTooltip(seriesIdx).getLabel());
+//            }
+//            lic.add(newItem);
+//          } 
+//          return lic;
+//        }
+//      }
+//    }
+
     // style plot
     if ( getPlotStyle() != null )
       getPlotStyle().applyToPlot(chart.getPlot());

Modified: trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -56,13 +56,20 @@
   protected Color paint = null;
   
   /**
-   * Creates a new style with default values (empty label, color black).
+   * Creates a new style with default values (empty label, color undefined).
    */
   public ChartLabelStyle() {
-    this("",Color.BLACK);
+    this("");
   }
 
   /**
+   * Creates a new style (color undefined).
+   * @param label label text (localized or static label is provided)
+   */
+  public ChartLabelStyle(String label) {
+    this(new Translation(label), null);
+  }
+    /**
    * Creates a new style.
    * @param label label text (localized or static label is provided)
    * @param color text color

Modified: trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -34,11 +34,30 @@
 import java.util.Map;
 
 import org.apache.log4j.Category;
+import org.jfree.chart.labels.CategorySeriesLabelGenerator;
+import org.jfree.chart.labels.CategoryToolTipGenerator;
+import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
+import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator;
+import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
+import org.jfree.chart.labels.StandardXYItemLabelGenerator;
+import org.jfree.chart.labels.StandardXYSeriesLabelGenerator;
+import org.jfree.chart.labels.StandardXYToolTipGenerator;
+import org.jfree.chart.labels.XYSeriesLabelGenerator;
+import org.jfree.chart.labels.XYToolTipGenerator;
 import org.jfree.chart.renderer.AbstractRenderer;
+import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer;
+import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
 import org.jfree.chart.renderer.xy.XYBarRenderer;
+import org.jfree.chart.urls.CategoryURLGenerator;
+import org.jfree.chart.urls.StandardCategoryURLGenerator;
+import org.jfree.chart.urls.StandardXYURLGenerator;
+import org.jfree.chart.urls.XYURLGenerator;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.xy.XYDataset;
 
 import schmitzm.jfree.JFreeChartUtil;
 import schmitzm.lang.LangUtil;
+import skrueger.i8n.Translation;
 
 /**
  * This class defines the rendering style the charts series. The following
@@ -57,21 +76,41 @@
   /** Logger for this class */
   protected final Category LOGGER = LangUtil.createLogger(this);
 
+  /** Standard label generator used for XY-Charts. */
+  protected XYSeriesLabelGenerator LABELGEN_XY = new StandardXYSeriesLabelGenerator();
+  /** Standard label generator used for Category-Charts. */
+  protected CategorySeriesLabelGenerator LABELGEN_CAT = new StandardCategorySeriesLabelGenerator();
+
   /** Holds whether the item labels are visible for a series. */
   protected Map<Integer, Boolean> seriesItemLabelsVisible = new HashMap<Integer, Boolean>();
   /** Holds the color a series is painted with. */
   protected Map<Integer, Color> seriesPaint = new HashMap<Integer, Color>();
   /** Holds whether the shape of a series is visible. */
   protected Map<Integer, Boolean> seriesShapesVisible = new HashMap<Integer, Boolean>();
+  /** Holds whether the series is visible in the legend. */
+  protected Map<Integer, Boolean> seriesLegendVisible = new HashMap<Integer, Boolean>();
+  /** Holds the label shown in the legend for the series. */
+  protected Map<Integer, ChartLabelStyle> seriesLegendLabel = new HashMap<Integer, ChartLabelStyle>();
+  /** Holds the tooltip shown in the legend for the series. */
+  protected Map<Integer, ChartLabelStyle> seriesLegendTooltip = new HashMap<Integer, ChartLabelStyle>();
   /** Holds the maximum series index for which a series is specified. */
   protected int maxSeriesIdx = 0;
   /** Holds the (percentage) margin for the bars. Only applicable for {@link XYBarRenderer}. */
   protected double margin = 0.0;
   
+  /** Label generator bases on the legend label definitions of this
+   *  style. */
+  protected LegendLabelGenerator legendLabelGenerator = null;
+  /** Label generator bases on the legend tooltip definitions of this
+   *  style. */
+  protected LegendTooltipGenerator legendTooltipGenerator = null;
+  
   /**
    * Creates a new style with default values.
    */
   public ChartRendererStyle() {
+    legendLabelGenerator   = new LegendLabelGenerator();
+    legendTooltipGenerator = new LegendTooltipGenerator();
   }
 
   /**
@@ -156,8 +195,84 @@
     seriesShapesVisible.put(series,visible);
     updateSeriesCount();
   }
+  
+  /**
+   * Returns whether the series is shown in the legend.
+   * @param series series index
+   * @return {@code null} if property is not set for the series
+   */
+  public Boolean isSeriesLegendVisible(int series) {
+    return seriesLegendVisible.get(series);
+  }
 
   /**
+   * Sets whether the series is shown in the legend.
+   * @param series  series index
+   * @param visible indicates the visibility of the series legend item (can be
+   *                {@code null} to reset to a non-specific property)
+   */
+  public void setSeriesLegendVisible(int series, Boolean visible) {
+    seriesLegendVisible.put(series,visible);
+    updateSeriesCount();
+  }
+  
+  /**
+   * Returns the style of the series label in the legend.
+   * @param series series index
+   * @return {@code null} if property is not set for the series
+   */
+  public ChartLabelStyle getSeriesLegendLabel(int series) {
+    return seriesLegendLabel.get(series);
+  }
+
+  /**
+   * Sets the style of the series label in the legend.
+   * @param series  series index
+   * @param labelStyle the style for the series label in the legend (can be
+   *                   {@code null} to reset to a non-specific property)
+   */
+  public void setSeriesLegendLabel(int series, ChartLabelStyle labelStyle) {
+    seriesLegendLabel.put(series,labelStyle);
+    updateSeriesCount();
+  }
+
+  /**
+   * Returns the style of the series tooltip in the legend.
+   * @param series series index
+   * @return {@code null} if property is not set for the series
+   */
+  public ChartLabelStyle getSeriesLegendTooltip(int series) {
+    return seriesLegendTooltip.get(series);
+  }
+
+  /**
+   * Sets the style of the series tooltip in the legend.
+   * @param series  series index
+   * @param labelStyle the style for the series tooltip in the legend (can be
+   *                   {@code null} to reset to a non-specific property)
+   */
+  public void setSeriesLegendTooltip(int series, ChartLabelStyle tooltipStyle) {
+    seriesLegendTooltip.put(series,tooltipStyle);
+    updateSeriesCount();
+  }
+  
+  /**
+   * Returns a label generator based on the <b>legend label</b>
+   * definitions of this style.
+   */
+  public LegendTooltipGenerator getLegendLabelGenerator() {
+    return legendTooltipGenerator;
+  }
+
+  /**
+   * Returns a label generator based on the <b>legend tooltip</b>
+   * definitions of this style.
+   */
+  public LegendTooltipGenerator getLegendTooltipGenerator() {
+    return legendTooltipGenerator;
+  }
+
+  /**
    * Updates the local variable for the defined series with
    * the maximum index (key) of the several hash maps. 
    */
@@ -165,13 +280,22 @@
     maxSeriesIdx = LangUtil.max(
                       seriesPaint.keySet(),
                       seriesShapesVisible.keySet(),
-                      seriesItemLabelsVisible.keySet()
+                      seriesItemLabelsVisible.keySet(),
+                      seriesLegendVisible.keySet(),
+                      seriesLegendLabel.keySet(),
+                      seriesLegendTooltip.keySet()
     );
   }
   
   /**
    * Applies the style to a specific renderer.<br>
-   * Note: Some style properties can only be applied to specific renderer types.
+   * <b>Note</b>:
+   * <ul>
+   *   <li>Some style properties can only be applied to specific renderer types.</li>
+   *   <li>The legend properties can not be applied by this method because the
+   *       chart / legend is unknown at this point. The properties are set by
+   *       {@link ChartStyle#applyToChart(org.jfree.chart.JFreeChart)}</li>
+   * </ul>
    * @param renderer a renderer
    */
   public void applyToRenderer(AbstractRenderer renderer) {
@@ -181,35 +305,48 @@
     }
 
     // Apply item label visibility
-    for (int i=0; i<seriesItemLabelsVisible.size(); i++)
+    for (int series : seriesItemLabelsVisible.keySet())
       try {
-        if ( isSeriesItemLabelsVisible(i) != null )
-          renderer.setSeriesItemLabelsVisible(i, isSeriesItemLabelsVisible(i), false);
+        if ( isSeriesItemLabelsVisible(series) != null )
+          renderer.setSeriesItemLabelsVisible(series, isSeriesItemLabelsVisible(series), false);
       } catch (Exception err) {
-        LOGGER.warn("Renderer contains not series "+i+". Label visibility can not be applied.");
+        LOGGER.warn("Renderer contains not series "+series+". Label visibility can not be applied.");
       }
     
     // Apply shape visibility
-    for (int i=0; i<seriesShapesVisible.size(); i++)
+    for (int series : seriesShapesVisible.keySet())
       try {
-        if ( isSeriesShapesVisible(i) != null )
-          renderer.setSeriesShape(i, isSeriesShapesVisible(i) ? AbstractRenderer.DEFAULT_SHAPE : null, false);
+        if ( isSeriesShapesVisible(series) != null )
+          renderer.setSeriesShape(series, isSeriesShapesVisible(series) ? AbstractRenderer.DEFAULT_SHAPE : null, false);
       } catch (Exception err) {
-        LOGGER.warn("Renderer contains not series "+i+". Shapes visibility can not be applied.");
+        LOGGER.warn("Renderer contains not series "+series+". Shapes visibility can not be applied.");
       }
 
     // Apply rendering color
-    for (int i=0; i<seriesPaint.size(); i++)
+    for (int series : seriesPaint.keySet())
       try {
-        if ( getSeriesPaint(i) != null )
-          renderer.setSeriesPaint(i, getSeriesPaint(i), false);
+        if ( getSeriesPaint(series) != null )
+          renderer.setSeriesPaint(series, getSeriesPaint(series), false);
       } catch (Exception err) {
-        LOGGER.warn("Renderer contains not series "+i+". Paint can not be applied.");
+        LOGGER.warn("Renderer contains not series "+series+". Paint can not be applied.");
       }
 
-    // Apply margin according to the specific renderer type
+    // Apply legend visibility
+    for (int series : seriesLegendVisible.keySet())
+      try {
+        if ( isSeriesLegendVisible(series) != null )
+          renderer.setSeriesVisibleInLegend(series, isSeriesLegendVisible(series), false);
+      } catch (Exception err) {
+        LOGGER.warn("Renderer contains not series "+series+". Legend visibility can not be applied.");
+      }
+
+    // Other properties must be applied according to the specific renderer type
     if (renderer instanceof XYBarRenderer)
       applyToBarRenderer((XYBarRenderer)renderer);
+    if (renderer instanceof AbstractXYItemRenderer)
+      applyToXYItemRenderer((AbstractXYItemRenderer)renderer);
+    if (renderer instanceof AbstractXYItemRenderer)
+      applyToCategoryItemRenderer((AbstractCategoryItemRenderer)renderer);
     
     // notify the listeners about style change
     JFreeChartUtil.fireChangeEvent(renderer);
@@ -226,4 +363,111 @@
     if ( getMargin() != null )
       renderer.setMargin(margin);
   }
+
+  /**
+   * Applies style properties which can only be applied to
+   * {@link AbstractXYItemRenderer}.<br>
+   * Called by {@link #applyToRenderer(AbstractRenderer)}. 
+   * @param renderer a {@link AbstractXYItemRenderer}
+   */
+  protected void applyToXYItemRenderer(AbstractXYItemRenderer renderer) {
+    renderer.setLegendItemLabelGenerator( getLegendLabelGenerator() );
+    renderer.setLegendItemToolTipGenerator( getLegendTooltipGenerator() );
+  }
+
+  /**
+   * Applies style properties which can only be applied to
+   * {@link AbstractCategoryItemRenderer}.<br>
+   * Called by {@link #applyToRenderer(AbstractRenderer)}. 
+   * @param renderer a {@link AbstractCategoryItemRenderer}
+   */
+  protected void applyToCategoryItemRenderer(AbstractCategoryItemRenderer renderer) {
+    renderer.setLegendItemLabelGenerator( getLegendLabelGenerator() );
+    renderer.setLegendItemToolTipGenerator( getLegendTooltipGenerator() );
+  }
+  
+  
+  /**
+   * This class implements a label generator based on the
+   * <b>legend label</b> definitions of this style, which can be used also
+   * for {@link AbstractCategoryItemRenderer} and {@link AbstractXYItemRenderer}.
+   * If no label definition is defined in the style, the label generator
+   * falls back to the standard label generators.
+   * @see ChartRendererStyle#LABELGEN_CAT
+   * @see ChartRendererStyle#LABELGEN_XY
+   * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+   */
+  protected class LegendLabelGenerator implements XYSeriesLabelGenerator, CategorySeriesLabelGenerator {
+    /**
+     * Returns the legend label for a series.
+     * @param dataset only used for the standard label generator
+     * @param series  the series the legend label is returned for
+     * @see ChartRendererStyle#getSeriesLegendLabel(int)
+     */
+    @Override
+    public String generateLabel(XYDataset dataset, int series) {
+      // if label is not defined, use the standard label generator 
+      if ( getSeriesLegendLabel(series) == null )
+        return LABELGEN_XY.generateLabel(dataset, series);
+      return getSeriesLegendLabel(series).getLabel();
+    }
+
+    /**
+     * Returns the legend label for a series.
+     * @param dataset only used for the standard label generator
+     * @param series  the series the legend label is returned for
+     * @see ChartRendererStyle#getSeriesLegendLabel(int)
+     */
+    @Override
+    public String generateLabel(CategoryDataset dataset, int series) {
+      // if label is not defined, use the standard label generator 
+      if ( getSeriesLegendLabel(series) == null )
+        return LABELGEN_CAT.generateLabel(dataset, series);
+      return getSeriesLegendLabel(series).getLabel();
+    }
+  }
+
+  /**
+   * This class implements a label generator based on the
+   * <b>legend tooltip</b> definitions of this style, which can be used also
+   * for {@link AbstractCategoryItemRenderer} and {@link AbstractXYItemRenderer}.
+   * If no tooltip definition is defined in the style, the label generator
+   * generates <b>no tooltip</b>.
+   * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+   */
+  protected class LegendTooltipGenerator implements XYSeriesLabelGenerator, CategorySeriesLabelGenerator {
+    /**
+     * Returns the legend tooltip for a series.
+     * @param dataset not used
+     * @param series  the series the legend label is returned for
+     * @return {@code null} if the style does not define a tooltip
+     *         for the series
+     * @see ChartRendererStyle#getSeriesLegendTooltip(int)
+     */
+    @Override
+    public String generateLabel(XYDataset dataset, int series) {
+      return generateLabel(series);
+    }
+
+    /**
+     * Returns the legend label for a series.
+     * @param dataset not used
+     * @param series  the series the legend label is returned for
+     * @return {@code null} if the style does not define a tooltip
+     *         for the series
+     * @see ChartRendererStyle#getSeriesLegendTooltip(int)
+     */
+    @Override
+    public String generateLabel(CategoryDataset dataset, int series) {
+      return generateLabel(series);
+    }
+    
+    public String generateLabel(int series) {
+      // if label is not defined, generate no tooltip 
+      if ( getSeriesLegendLabel(series) == null )
+        return null;
+      return getSeriesLegendTooltip(series).getLabel();
+    }
+  }
+  
 }

Modified: trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -292,6 +292,21 @@
       Boolean shapesVisible = XMLUtil.getBooleanAttribute(seriesElement, "shapesVisible");
       if ( shapesVisible != null )
         style.setSeriesShapesVisible(i, shapesVisible);
+      
+      // legend visibility
+      Boolean legendVisible = XMLUtil.getBooleanAttribute(seriesElement, "legendVisible");
+      if ( legendVisible != null )
+        style.setSeriesLegendVisible(i, legendVisible);
+      
+      // legend label
+      String legendLabel = XMLUtil.getAttribute(seriesElement, "legendLabel");
+      if ( legendLabel != null )
+        style.setSeriesLegendLabel(i, new ChartLabelStyle(legendLabel));
+      
+      // legend tooltip
+      String legendTooltip = XMLUtil.getAttribute(seriesElement, "legendTooltip");
+      if ( legendTooltip != null )
+        style.setSeriesLegendTooltip(i, new ChartLabelStyle(legendTooltip));
     }
     return style;
   }
@@ -591,6 +606,11 @@
         XMLUtil.setNotNullAttribute(seriesElem, "paint", rendererStyle.getSeriesPaint(i));
         XMLUtil.setNotNullAttribute(seriesElem, "itemLabelsVisible", rendererStyle.isSeriesItemLabelsVisible(i));
         XMLUtil.setNotNullAttribute(seriesElem, "shapesVisible", rendererStyle.isSeriesShapesVisible(i));
+        XMLUtil.setNotNullAttribute(seriesElem, "legendVisible", rendererStyle.isSeriesLegendVisible(i));
+        if ( rendererStyle.getSeriesLegendLabel(i) != null )
+          XMLUtil.setNotNullAttribute(seriesElem, "legendLabel", rendererStyle.getSeriesLegendLabel(i).getLabelTranslation());
+        if ( rendererStyle.getSeriesLegendTooltip(i) != null )
+          XMLUtil.setNotNullAttribute(seriesElem, "legendTooltip", rendererStyle.getSeriesLegendTooltip(i).getLabelTranslation());
       }
     }
     

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -31,14 +31,9 @@
 
 import org.geotools.feature.FeatureCollection;
 import org.jfree.chart.JFreeChart;
-import org.jfree.chart.LegendItem;
-import org.jfree.chart.LegendItemCollection;
-import org.jfree.chart.LegendItemSource;
-import org.jfree.chart.title.LegendTitle;
 import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.general.Dataset;
 import org.jfree.data.xy.XYDataset;
-import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
 
 import schmitzm.jfree.chart.style.BasicChartStyle;
@@ -195,31 +190,6 @@
           this
       );
       JFreeChart chart = applyToDataset(dataset);
-      
-//      for (int i=0; i<dataset.getSeriesCount(); i++) {
-//        XYSeries series = dataset.getSeries(i); 
-//        series.setDescription("My description for "+series.getKey());
-//      } 
-//      
-//      
-//      
-//      LegendTitle        lt        = chart.getLegend();
-//      LegendItemSource[] source    = lt.getSources();
-//      final LegendItemSource   oldSource = source[0];      
-//      
-//      source[0] = new LegendItemSource() {
-//        public LegendItemCollection getLegendItems() {
-//          LegendItemCollection lic = new LegendItemCollection();
-//          for (int i=0; i<dataset.getSeriesCount(); i++) {
-//            XYSeries   series = dataset.getSeries(i); 
-//            LegendItem li     = new LegendItem( series.getDescription() );
-//            lic.add(li);
-//          } 
-//          // TODO Auto-generated method stub
-//          return lic;
-//        }
-//        
-//      };
 
       return chart;
     }

Modified: trunk/src/schmitzm/xml/XMLUtil.java
===================================================================
--- trunk/src/schmitzm/xml/XMLUtil.java	2009-08-01 15:15:00 UTC (rev 268)
+++ trunk/src/schmitzm/xml/XMLUtil.java	2009-08-01 15:33:38 UTC (rev 269)
@@ -38,6 +38,7 @@
 import org.jdom.output.XMLOutputter;
 
 import schmitzm.swing.SwingUtil;
+import skrueger.i8n.Translation;
 
 
 /**
@@ -182,6 +183,8 @@
     // Special: convert color to hex rgb string
     if ( value instanceof Color )
       valueStr = SwingUtil.convertColorToHex((Color)value);
+    if ( value instanceof Translation )
+      valueStr = ((Translation)value).toOneLine();
     
     element.setAttribute(attrName, valueStr);
   



More information about the Schmitzm-commits mailing list