[Schmitzm-commits] r483 - in branches/1.0-gt2-2.6/src/schmitzm: jfree jfree/chart/style jfree/feature/style xml

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 20 16:16:03 CEST 2009


Author: mojays
Date: 2009-10-20 16:16:01 +0200 (Tue, 20 Oct 2009)
New Revision: 483

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/jfree/JFreeChartUtil.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/AbstractChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/BasicChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
   branches/1.0-gt2-2.6/src/schmitzm/xml/XMLUtil.java
Log:
(Feature)ChartStyles: consistent use of the general copyTo(ChartStyle) method to avoid "undefined" polymorphism behavior
Utility methods to center the chart axis origin.
Chart centering to XML.

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/JFreeChartUtil.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/JFreeChartUtil.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -36,7 +36,9 @@
 
 import org.apache.log4j.Logger;
 import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.Axis;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.event.PlotChangeEvent;
 import org.jfree.chart.event.PlotChangeListener;
 import org.jfree.chart.event.RendererChangeEvent;
@@ -67,6 +69,7 @@
 import org.jfree.chart.title.Title;
 import org.jfree.chart.urls.StandardXYURLGenerator;
 import org.jfree.chart.urls.XYURLGenerator;
+import org.jfree.data.Range;
 import org.jfree.data.function.Function2D;
 import org.jfree.data.function.LineFunction2D;
 import org.jfree.data.general.Dataset;
@@ -92,6 +95,10 @@
 public class JFreeChartUtil {
   private static Logger LOGGER = Logger.getLogger(JFreeChartUtil.class.getName());
   
+  /** Default percentage, an (axis) range is extended with on centering
+   *  to avoid points directly on the plot border. */ 
+  public static final Double DEFAULT_CENTRATION_BOUNDARY_PCT = 0.1; 
+  
   /** {@link ResourceProvider}, der die Lokalisation fuer GUI-Komponenten
    *  zur Verfuegung stellt. Diese sind in properties-Datein unter
    *  {@code schmitzm.jfree.resource.locales.JFreeResourceBundle_XXX.properties}
@@ -138,6 +145,62 @@
   }
 
   /**
+   * Returns the maximum extend of a {@link Range} including
+   * a given boundary.
+   * @param range a {@link Range}
+   * @param boundaryPct extends the {@link Range} bound by percentage (if {@code null}
+   *                    {@value #DEFAULT_CENTRATION_BOUNDARY_PCT} is used).
+   * @return a value >= 0
+   */
+  public static double getAbsRange(Range range, Double boundaryPct) {
+    if ( boundaryPct == null )
+      boundaryPct = DEFAULT_CENTRATION_BOUNDARY_PCT;
+    return Math.max(
+            Math.abs(range.getUpperBound()),
+            Math.abs(range.getLowerBound())
+           ) * (1+boundaryPct);
+  }
+  
+  /**
+   * Returns a new centered {@link Range} defined as [-maxAbs; maxAbs] of a
+   * given {@link Range}.
+   * @param range the {@link Range} to center
+   * @param boundaryPct extends the range's absolute maximum by percentage (if {@code null}
+   *                    {@value #DEFAULT_CENTRATION_BOUNDARY_PCT} is used).
+   * @return a new {@link Range} object
+   */
+  public static Range centerRange(Range range, Double boundaryPct) {
+    double absMax = getAbsRange(range,boundaryPct);
+    return new Range(-absMax, absMax);
+  }
+  
+  /**
+   * Centers a gives {@link Axis} around 0.
+   * @param axis the {@link Axis} to center
+   * @param boundaryPct extends the axis range's absolute maximum by percentage (if {@code null}
+   *                    {@value #DEFAULT_CENTRATION_BOUNDARY_PCT} is used).
+   */
+  public static void centerAxis(ValueAxis axis, Double boundaryPct) {
+    double absMax = getAbsRange(axis.getRange(),boundaryPct);
+    axis.setRange(-absMax, absMax);
+  }
+
+  /**
+   * Centers a gives {@link Plot} around 0/0 (of the main axis).
+   * For {@link CategoryPlot} only the range axis is centered.
+   * @param axis the {@link Plot} to center
+   * @param boundaryPct percentage boundary the absolute maximum is extended with
+   */
+  public static void centerPlot(Plot plot, Double boundaryPct) {
+    if ( plot instanceof XYPlot ) {
+      centerAxis( ((XYPlot)plot).getDomainAxis(), boundaryPct );
+      centerAxis( ((XYPlot)plot).getRangeAxis(), boundaryPct );
+    }
+    if ( plot instanceof CategoryPlot )
+      centerAxis( ((CategoryPlot)plot).getRangeAxis(), boundaryPct );
+  }
+
+  /**
    * Creates a {@link XYItemRenderer} for the given stepped and stacked
    * properties.
    * @param type    chart type

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/AbstractChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/AbstractChartStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/AbstractChartStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -177,28 +177,13 @@
    */
   @Override
   public ChartStyle copyTo(ChartStyle dest) {
-    if ( dest != null && !(dest instanceof AbstractChartStyle) )
-      throw new IllegalArgumentException(LangUtil.getSimpleClassName(this)+".copy(..) can not be applied on "+LangUtil.getSimpleClassName(dest));
-    return copyTo((AbstractChartStyle)dest);
-  }
-  
-  /**
-   * Copies all properties of this chart style to another
-   * chart style.
-   * @param dest destination object (if {@code null} the copy
-   *             is created by {@link #copy()})
-   * @return {@code dest} or the new instance
-   * @exception IllegalArgumentException if {@code dest} is no
-   *            {@link AbstractChartStyle}
-   */
-  public AbstractChartStyle copyTo(AbstractChartStyle dest) {
     if ( dest == null )
       return copy();
     if ( !(dest instanceof AbstractChartStyle) )
       throw new IllegalArgumentException(LangUtil.getSimpleClassName(this)+".copy(..) can not be applied on "+LangUtil.getSimpleClassName(dest));
 
     AbstractChartStyle destStyle = (AbstractChartStyle)dest;
-    destStyle.id   = getID();
+    destStyle.id = getID();
     destStyle.setType( getType() );
     destStyle.setTitleStyle( CopyableUtil.copyOrCreate(getTitleStyle(), destStyle.getTitleStyle()) );
     destStyle.setDescStyle( CopyableUtil.copyOrCreate(getDescStyle(), destStyle.getDescStyle()) );

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/BasicChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/BasicChartStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/BasicChartStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -130,7 +130,7 @@
    */
   @Override
   public BasicChartStyle copy() {
-    return copyTo( new BasicChartStyle("") );
+    return (BasicChartStyle) copyTo( new BasicChartStyle("") );
   }
   
   /**
@@ -142,13 +142,16 @@
    * @exception IllegalArgumentException if {@code dest} is no
    *            {@link AbstractChartStyle}
    */
-  public BasicChartStyle copyTo(BasicChartStyle dest) {
+  @Override
+  public ChartStyle copyTo(ChartStyle dest) {
     // copy the super class properties
-    dest = (BasicChartStyle)copyTo((AbstractChartStyle)dest);
-    // copy this classes properties
-    dest.setStacked( isStacked() );
-    dest.setStepped( isStepped() );
-
+    dest = super.copyTo(dest);
+    if ( dest instanceof BasicChartStyle ) {
+      BasicChartStyle destBCS = (BasicChartStyle) dest;
+      // copy this classes properties
+      destBCS.setStacked( isStacked() );
+      destBCS.setStepped( isStepped() );
+    }
     return dest;
   }
 

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartPlotStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -45,6 +45,7 @@
 import org.jfree.ui.Layer;
 import org.jfree.ui.RectangleInsets;
 
+import schmitzm.jfree.JFreeChartUtil;
 import schmitzm.lang.LangUtil;
 import skrueger.geotools.Copyable;
 
@@ -69,8 +70,8 @@
  * @version 1.0
  */
 public class ChartPlotStyle implements Copyable<ChartPlotStyle> {
-	private final ValueMarker VALUE_MARKER = new ValueMarker(0., Color.black, new BasicStroke(1f));
-    private final CategoryMarker CAT_MARKER = new CategoryMarker(0., Color.black, new BasicStroke(1f));
+	private final ValueMarker    VALUE_MARKER = new ValueMarker(0., Color.black, new BasicStroke(1f));
+    private final CategoryMarker CAT_MARKER   = new CategoryMarker(0., Color.black, new BasicStroke(1f));
 
 	/** Logger for this class */
 	protected final Category LOGGER = LangUtil.createLogger(this);
@@ -95,16 +96,10 @@
 	protected Boolean crosshairVisible = null;
 	/** Holds the color of the range grid line. */
 	protected Color crosshairPaint = null;
-	/**
-	 * Boolean determining whether the plot will be centered around the axis
-	 * origin and will have extends: Xmax = -Xmin && Ymax = -Ymin
-	 **/
+	/** Boolean determining whether the plot will be centered around the axis
+	 *  origin and will have extends: Xmax = -Xmin and Ymax = -Ymin **/
 	protected boolean centerOriginSymetrically = false;
 
-	//
-	// private int absMaxY;
-	//
-	// private int absMaxX;
 
 	/**
 	 * Creates a new style with default values.
@@ -143,6 +138,7 @@
 		dest.setRangeGridlinePaint(getRangeGridlinePaint());
 		dest.setCrosshairVisible(isCrosshairVisible());
 		dest.setCrosshairPaint(getCrosshairPaint());
+		dest.setCenterOriginSymetrically( isCenterOriginSymetrically() );
 
 		return dest;
 	}
@@ -415,6 +411,11 @@
           plot.removeDomainMarker(CAT_MARKER);
           plot.removeRangeMarker(CAT_MARKER);
         }
+        // Axis origin centration
+        plot.getRangeAxis().setAutoRange(!isCenterOriginSymetrically());
+        if (isCenterOriginSymetrically()) {
+            JFreeChartUtil.centerAxis( plot.getRangeAxis(), 0.1);
+        }
 
 	}
 
@@ -427,6 +428,7 @@
 	 */
 	protected void applyToXYPlot(XYPlot plot) {
 
+	    // Grid lines
 		if (isDomainGridlineVisible() != null)
 			plot.setDomainGridlinesVisible(isDomainGridlineVisible());
 		if (getDomainGridlinePaint() != null)
@@ -435,6 +437,7 @@
 			plot.setRangeGridlinesVisible(isRangeGridlineVisible());
 		if (getRangeGridlinePaint() != null)
 			plot.setRangeGridlinePaint(getRangeGridlinePaint());
+		// Axis origin crosshair lines
 		if (isCrosshairVisible() != null && isCrosshairVisible() == true) {
 		  if (getCrosshairPaint() != null)
 		    VALUE_MARKER.setPaint(getCrosshairPaint());
@@ -448,80 +451,20 @@
 		  plot.removeDomainMarker(VALUE_MARKER);
 		  plot.removeRangeMarker(VALUE_MARKER);
 		}
-		
-		 plot.setDomainPannable(true);
-		 plot.setRangePannable(true);
-
+        // Axis origin centration
+		plot.getRangeAxis().setAutoRange(!isCenterOriginSymetrically());
+		plot.getDomainAxis().setAutoRange(!isCenterOriginSymetrically());
 		if (isCenterOriginSymetrically()) {
-			plot.getRangeAxis().setAutoRange(false);
-			plot.getDomainAxis().setAutoRange(false);
-			
-			{
-				// Domain
-				Range range = plot.getDomainAxis().getRange();
-				
-				double absMax = Math.max(Math.abs(range.getUpperBound()), Math
-						.abs(range.getLowerBound())) * 1.1;
-				plot.getDomainAxis().setRange(-absMax, absMax);
-			}
-
-			{
-				// Range
-				Range range = plot.getRangeAxis().getRange();
-
-				double absMax = Math.max(Math.abs(range.getUpperBound()), Math
-						.abs(range.getLowerBound())) * 1.1;
-				plot.getRangeAxis().setRange(-absMax, absMax);
-			}
-		
-		} else {
-			plot.getRangeAxis().setAutoRange(true);
-			plot.getDomainAxis().setAutoRange(true);
+			JFreeChartUtil.centerAxis( plot.getDomainAxis(), 0.1);
+			JFreeChartUtil.centerAxis( plot.getRangeAxis(), 0.1);
 		}
+// TEST
+        plot.setDomainPannable(true);
+        plot.setRangePannable(true);
 
-		// TESTS
-		// plot.zoomDomainAxes(1.0, null, new Point2D.Double(50,50), true );
-		// plot.zoomDomainAxes(0.5,0.5, null, null);
-		// plot.zoomRangeAxes(0.5,0.5, null, null);
-		// Range domainAxisRange = plot.getDomainAxis().getRange();
-		// double domainAbsMax = Math.max(
-		// Math.abs(domainAxisRange.getLowerBound()),
-		// Math.abs(domainAxisRange.getUpperBound())
-		// );
-		// plot.getDomainAxis().setRange(-domainAbsMax, domainAbsMax);
-		//    
-		//    
-		// Range rangeAxisRange = plot.getRangeAxis().getRange();
-		// double rangeAbsMax = Math.max(
-		// Math.abs(rangeAxisRange.getLowerBound()),
-		// Math.abs(rangeAxisRange.getUpperBound())
-		// );
-		// plot.getRangeAxis().setRange(-rangeAbsMax, rangeAbsMax);
-
-//		 plot.getDomainAxis().centerRange(0);
-//		 plot.getRangeAxis().centerRange(0);
-		//    
-		// plot.getDomainAxis().setAutoRange(false);
-		// plot.getRangeAxis().setAutoRange(false);
-		// plot.getDomainAxis().setDefaultAutoRange( new Range(
-		// plot.getDomainAxis().getRange().getLowerBound(),
-		// plot.getDomainAxis().getRange().getUpperBound())
-		// );
-		// plot.getRangeAxis().setDefaultAutoRange( new Range(
-		// plot.getRangeAxis().getRange().getLowerBound(),
-		// plot.getRangeAxis().getRange().getUpperBound())
-		// );
 	}
+	
 
-	//
-	// private int getAbsMaxY() {
-	// return absMaxY;
-	// }
-	//
-	// private int getAbsMaxX() {
-	// return absMaxX;
-	// }
-
     /**
      * Sets whether the axis origin is centered in the plot.
      * @param originSym indicated whether the axis origin should
@@ -537,12 +480,5 @@
 	public boolean isCenterOriginSymetrically() {
 		return centerOriginSymetrically;
 	}
-	//
-	// public void setAbsMaxX(int absMaxX) {
-	// this.absMaxX = absMaxX;
-	// }
-	//
-	// public void setAbsMaxY(int absMaxY) {
-	// this.absMaxY = absMaxY;
-	// }
+
 }

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -319,6 +319,9 @@
   public ChartPlotStyle createPlotStyleFromXML(Element element) {
     ChartPlotStyle style = new ChartPlotStyle();
 
+    // Axis origin centration
+    style.setCenterOriginSymetrically( XMLUtil.getBooleanAttribute(element, "centerAxisOrigin", false) );
+    
     // foreground transparency
     Element foregroundElem = element.getChild("foreground");
     if ( foregroundElem != null ) {
@@ -455,6 +458,9 @@
     if ( style.getPlotStyle() != null ) {
       Element        plotElem  = addChildToElement(root, "plot");
       ChartPlotStyle plotStyle = style.getPlotStyle();
+      
+      XMLUtil.setAttribute(plotElem, "centerAxisOrigin", plotStyle.isCenterOriginSymetrically(), false);
+      
       addChildToElement(plotElem, "foreground", false,
           "alpha", plotStyle.getForegroundAlpha()
       );

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/style/ScatterChartStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -64,7 +64,7 @@
    */
   @Override
   public ScatterChartStyle copy() {
-    return copyTo( new ScatterChartStyle("") );
+    return (ScatterChartStyle) copyTo( new ScatterChartStyle("") );
   }
   
   /**
@@ -76,12 +76,15 @@
    * @exception IllegalArgumentException if {@code dest} is no
    *            {@link AbstractChartStyle}
    */
-  public ScatterChartStyle copyTo(ScatterChartStyle dest) {
+  @Override
+  public ChartStyle copyTo(ChartStyle dest) {
     // copy the super class properties
-    dest = (ScatterChartStyle)copyTo((AbstractChartStyle)dest);
+    dest = super.copyTo(dest);
     // copy this classes properties
-    dest.setRegressionLineVisible( isRegressionLineVisible() );
-
+    if ( dest instanceof ScatterChartStyle ) {
+      ScatterChartStyle destSCS = (ScatterChartStyle) dest;
+      destSCS.setRegressionLineVisible( isRegressionLineVisible() );
+    }
     return dest;
   }
 

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -36,6 +36,7 @@
 import org.jfree.data.xy.XYDataset;
 
 import schmitzm.jfree.chart.style.BasicChartStyle;
+import schmitzm.jfree.chart.style.ChartStyle;
 import schmitzm.jfree.chart.style.ChartType;
 
 /**
@@ -73,7 +74,7 @@
      */
     @Override
     public FeatureBasicChartStyle copy() {
-      return copyTo( new FeatureBasicChartStyle("") );
+      return (FeatureBasicChartStyle) copyTo( new FeatureBasicChartStyle("") );
     }
     
     /**
@@ -82,11 +83,13 @@
      *             is created by {@link #copy()})
      * @return {@code dest} or the new instance
      */
-    public FeatureBasicChartStyle copyTo(FeatureBasicChartStyle dest) {
+    @Override
+    public ChartStyle copyTo(ChartStyle dest) {
       // copy the super class properties
-      dest = (FeatureBasicChartStyle)copyTo((BasicChartStyle)dest);
+      dest = super.copyTo(dest);
       // copy this classes properties
-      dummyFeatureChartStyle.copyTo((FeatureChartStyle)dest);
+      if ( dest instanceof FeatureChartStyle )
+        dummyFeatureChartStyle.copyTo(dest);
 
       return dest;
     }

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureChartStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureChartStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -225,17 +225,6 @@
     }
     
     /**
-     * Does nothing but returning the input style, because
-     * {@link Dummy} only maintains the {@link FeatureChartStyle}
-     * properties!
-     */
-    @Override
-    public AbstractChartStyle copyTo(AbstractChartStyle dest) {
-      return dest;
-    }
-    
-    
-    /**
      * Copies all properties of this style to another one. The properties
      * of the super class ({@link AbstractChartStyle}) are <b>ignored</b>
      * because they are unused for the dummy.
@@ -243,25 +232,32 @@
      *             is created by {@link #copy()})
      * @return {@code dest} or the new instance
      */
-    public FeatureChartStyle copyTo(FeatureChartStyle dest) {
-      // !! do NOT copy the super class properties !!
-      // !! copy only this classes properties !!
-      dest.setSortDomainAxis( isSortDomainAxis() );
-      dest.setForceCategories( isForceCategories() );
+    @Override
+    public ChartStyle copyTo(ChartStyle dest) {
+      // !! do NOT copy the super class properties  !!
+      // !! copy only this classes properties       !!
+      // !! Reason: the dummy does not maintain the !!
+      // !!         super class properties and we   !!
+      //            do not want to overwrite them   !!
+      if ( dest instanceof FeatureChartStyle ) {
+        FeatureChartStyle destFCS = (FeatureChartStyle) dest;
+        destFCS.setSortDomainAxis( isSortDomainAxis() );
+        destFCS.setForceCategories( isForceCategories() );
 
-      // Clear the attribute names and attribute normalization
-      int max = dest.getMaxAttributeCount();
-      for (int i=0; i<max; i++) {
-        dest.setAttributeName(i, null);
-        dest.setAttributeNormalized(i, null);
+        // Clear the attribute names and attribute normalization
+        int max = destFCS.getMaxAttributeCount();
+        for (int i=0; i<max; i++) {
+          destFCS.setAttributeName(i, null);
+          destFCS.setAttributeNormalized(i, null);
+        }
+        // Copy attribute names and normalization
+        for (Integer idx : attrNames.keySet() )
+          if ( getAttributeName(idx) != null )
+            destFCS.setAttributeName(idx, getAttributeName(idx));
+        for (Integer idx : normalizeAttr.keySet() )
+          if ( isAttributeNormalized(idx) )
+            destFCS.setAttributeNormalized(idx, isAttributeNormalized(idx));
       }
-      // Copy attribute names and normalization
-      for (Integer idx : attrNames.keySet() )
-        if ( getAttributeName(idx) != null )
-          dest.setAttributeName(idx, getAttributeName(idx));
-      for (Integer idx : normalizeAttr.keySet() )
-        if ( isAttributeNormalized(idx) )
-          dest.setAttributeNormalized(idx, isAttributeNormalized(idx));
       
       return dest;
     }

Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -37,6 +37,7 @@
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
 
+import schmitzm.jfree.chart.style.ChartStyle;
 import schmitzm.jfree.chart.style.ScatterChartStyle;
 
 /**
@@ -89,7 +90,7 @@
    */
   @Override
   public FeatureScatterChartStyle copy() {
-    return copyTo( new FeatureScatterChartStyle("") );
+    return (FeatureScatterChartStyle) copyTo( new FeatureScatterChartStyle("") );
   }
   
   /**
@@ -98,11 +99,13 @@
    *             is created by {@link #copy()})
    * @return {@code dest} or the new instance
    */
-  public FeatureScatterChartStyle copyTo(FeatureScatterChartStyle dest) {
+  @Override
+  public ChartStyle copyTo(ChartStyle dest) {
     // copy the super class properties
-    dest = (FeatureScatterChartStyle)copyTo((ScatterChartStyle)dest);
+    dest = super.copyTo(dest);
     // copy this classes properties
-    dummyFeatureChartStyle.copyTo((FeatureChartStyle)dest);
+    if ( dest instanceof FeatureChartStyle )
+      dummyFeatureChartStyle.copyTo(dest);
 
     return dest;
   }

Modified: branches/1.0-gt2-2.6/src/schmitzm/xml/XMLUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/xml/XMLUtil.java	2009-10-20 13:51:11 UTC (rev 482)
+++ branches/1.0-gt2-2.6/src/schmitzm/xml/XMLUtil.java	2009-10-20 14:16:01 UTC (rev 483)
@@ -163,6 +163,7 @@
    * Exceptions:
    * <ul>
    *   <li>{@link Color}: the color is converted to hex rgb string</li>
+   *   <li>{@link Translation}: the translation is converted {@linkplain Translation#toOneLine() to one line}</li>
    * </ul>
    * @param element      element the attribute is set for
    * @param attrName     name of the attribute to set
@@ -183,6 +184,7 @@
     // Special: convert color to hex rgb string
     if ( value instanceof Color )
       valueStr = SwingUtil.convertColorToHex((Color)value);
+    // Special: convert Translation to one line
     if ( value instanceof Translation )
       valueStr = ((Translation)value).toOneLine();
     
@@ -190,7 +192,7 @@
   
     return true;
   }
-
+  
   /**
    * Sets an attribute value if the value is not {@code null}.
    * The {@code .toString()} method is used to convert the object



More information about the Schmitzm-commits mailing list