[Schmitzm-commits] r831 - in trunk: src/schmitzm/jfree/feature/style src_junit/schmitzm/jfree/feature/style

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 5 18:39:22 CEST 2010


Author: alfonx
Date: 2010-05-05 18:39:21 +0200 (Wed, 05 May 2010)
New Revision: 831

Modified:
   trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java
   trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
Log:
aggregationFunctionWeightAttributeName und aggregationFunctionWeightAttributeNoDataValues werden nun auch in XML geschrieben und gelesen.

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java	2010-05-05 15:55:39 UTC (rev 830)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java	2010-05-05 16:39:21 UTC (rev 831)
@@ -44,7 +44,7 @@
 import schmitzm.jfree.feature.AggregationFunction;
 import schmitzm.lang.LangUtil;
 import schmitzm.xml.XMLUtil;
-
+	
 /**
  * This class defines a factory to create a chart style from XML
  * specialized for {@link FeatureCollection}.
@@ -103,12 +103,21 @@
       rangeAttrNo++;
       chartStyle.setAttributeName(rangeAttrNo, featureAttrName);
       chartStyle.setAttributeNormalized(rangeAttrNo, XMLUtil.getBooleanAttribute(rangeAttrElem, "normalize", false));
+      nullAliases = XMLUtil.getSetAttribute(rangeAttrElem, "nullAliases");
+      if (nullAliases != null)
+    	  chartStyle.setNoDataValues(rangeAttrNo, nullAliases);
+      
       String aggrFuncStr = XMLUtil.getAttribute(rangeAttrElem, "function", (String)null);
-      if ( aggrFuncStr != null )
+      if ( aggrFuncStr != null ) 
         chartStyle.setAttributeAggregation(rangeAttrNo, AggregationFunction.valueOf(aggrFuncStr) );
-      nullAliases = XMLUtil.getSetAttribute(rangeAttrElem, "nullAliases");
+
+      String aggrFuncWeightAtt = XMLUtil.getAttribute(rangeAttrElem, "weightAttrName", (String)null);
+      if ( aggrFuncWeightAtt != null )
+        chartStyle.setAttributeAggregationWeightAttributeName(rangeAttrNo, aggrFuncWeightAtt );
+      
+      nullAliases = XMLUtil.getSetAttribute(rangeAttrElem, "weightAttrNullAliases");
       if (nullAliases != null)
-        chartStyle.setNoDataValues(rangeAttrNo, nullAliases);
+    	  chartStyle.setWeightAttributeNoDataValues(rangeAttrNo, nullAliases);
     }
 
     // Read (optional) series attribute (its values defines the series groups)
@@ -175,7 +184,9 @@
           "name", style.getAttributeName(i),
           "normalize", style.isAttributeNormalized(i),
           "nullAliases", XMLUtil.convertSetToSeparatedString(style.getNoDataValues(i)), 
-          "function", style.getAttributeAggregation(i)
+          "function", style.getAttributeAggregation(i),
+          "weightAttrName", style.getAttributeAggregationWeightAttributeName(i),
+          "weightAttrNullAliases", XMLUtil.convertSetToSeparatedString(style.getWeightAttributeNoDataValues(i))
       );
 
     // Series attribute definition

Modified: trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
===================================================================
--- trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-05-05 15:55:39 UTC (rev 830)
+++ trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-05-05 16:39:21 UTC (rev 831)
@@ -29,6 +29,7 @@
 import schmitzm.jfree.chart.style.ChartRendererStyle;
 import schmitzm.jfree.chart.style.ChartStyleUtil;
 import schmitzm.jfree.chart.style.ChartType;
+import schmitzm.jfree.feature.AggregationFunction;
 import schmitzm.xml.XMLUtil;
 
 public class FeatureChartStyleTest {
@@ -45,6 +46,7 @@
 				"testLineChart", ChartType.BAR);
 		weightChartStyle.setAttributeName(0, "attX");
 		weightChartStyle.setAttributeName(1, "attY");
+		weightChartStyle.setAttributeAggregation(1, AggregationFunction.AVG_WEIGHTED);
 		weightChartStyle.setAttributeAggregationWeightAttributeName(1, "weight");
 	
 		
@@ -53,10 +55,14 @@
 		xmlFactory.writeStyleToFile(weightChartStyle, "testWeightedhart",
 				testFile);
 		
+		System.out.println(IOUtil.readFileAsString(testFile));
+		
 		// XML wieder einlesen
 		FeatureChartStyle weightChartAusXMLgelesen = xmlFactory.readStyleFromFile(testFile);
+		assertEquals(AggregationFunction.AVG_WEIGHTED, weightChartAusXMLgelesen.getAttributeAggregation(1));
 		assertEquals("weight", weightChartAusXMLgelesen.getAttributeAggregationWeightAttributeName(1));
 
+
 		// Nochmal in XML schreiben
 		File testFile2 = File.createTempFile("testWeightChart", ".xml");
 		xmlFactory.writeStyleToFile(weightChartStyle, "testWeightedhart",



More information about the Schmitzm-commits mailing list