[Schmitzm-commits] r752 - in trunk/src/schmitzm/jfree/feature: . style

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 3 16:14:15 CET 2010


Author: alfonx
Date: 2010-03-03 16:14:14 +0100 (Wed, 03 Mar 2010)
New Revision: 752

Modified:
   trunk/src/schmitzm/jfree/feature/AggregationFunction.java
   trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
Log:


Modified: trunk/src/schmitzm/jfree/feature/AggregationFunction.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/AggregationFunction.java	2010-03-03 14:26:40 UTC (rev 751)
+++ trunk/src/schmitzm/jfree/feature/AggregationFunction.java	2010-03-03 15:14:14 UTC (rev 752)
@@ -100,11 +100,9 @@
 		case COUNT:
 			return ((Integer) statistics.size()).doubleValue();
 		case STND_DEV:
-			return statistics.standardDeviation();
+			return statistics.size() > 1 ? statistics.standardDeviation() : 0.;
 		case VARIANCE:
-			return Math.pow(statistics.standardDeviation(), 2);
-			// case MEDIAN:
-			// case SUM_ABS:
+			return statistics.size() > 1 ? statistics.variance() : 0.;
 		}
 		throw new UnsupportedOperationException(
 				"Aggregation function not yet supported: " + this);

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java	2010-03-03 14:26:40 UTC (rev 751)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java	2010-03-03 15:14:14 UTC (rev 752)
@@ -483,6 +483,11 @@
   private static Number normalize(Number yValue, String attrName,
       HashMap<String, QuantileBin1D> statisticsForNormalization) {
     Number zValue;
+    
+    // Variance and SD can only be calculated for n>1 elements in a category. In case of n = 1 it return NaN. We interpretet it as 0.0 here
+    if (Double.isNaN(yValue.doubleValue())){
+    	return 0.;
+    }
 
     if (statisticsForNormalization.get(attrName) == null) {
       throw new IllegalArgumentException(
@@ -693,8 +698,10 @@
           Number yValue = aggrFunc.getResult(aggrStat);
           
           // Normalize the aggregated value
-          if ( chartStyle.isAttributeNormalized(attrIdx) )
-            yValue = normalize(yValue, yAttrName, statisticsForNormalization);
+          if ( chartStyle.isAttributeNormalized(attrIdx) ){
+        	  
+        	  yValue = normalize(yValue, yAttrName, statisticsForNormalization);
+          }
           
           // Fill series
           dataset.addValue(yValue, yAttrName, catValue);



More information about the Schmitzm-commits mailing list