[Schmitzm-commits] r668 - branches/2.0-RC2/src/schmitzm/jfree/feature/style
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Feb 3 19:24:17 CET 2010
Author: alfonx
Date: 2010-02-03 19:24:13 +0100 (Wed, 03 Feb 2010)
New Revision: 668
Modified:
branches/2.0-RC2/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
Log:
Added
// Filter out NoDataValues
yValue = chartStyle.filterNoDataValue(attrIdx, yValue);
if (yValue == null)
continue;
to all createDataset methods
Modified: branches/2.0-RC2/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/jfree/feature/style/FeatureChartUtil.java 2010-02-03 18:16:13 UTC (rev 667)
+++ branches/2.0-RC2/src/schmitzm/jfree/feature/style/FeatureChartUtil.java 2010-02-03 18:24:13 UTC (rev 668)
@@ -56,7 +56,6 @@
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
-import org.opengis.feature.type.GeometryDescriptor;
import org.opengis.feature.type.Name;
import schmitzm.geotools.feature.FeatureUtil;
@@ -69,8 +68,6 @@
import schmitzm.jfree.feature.Feature2SeriesDatasetMapping;
import schmitzm.jfree.feature.FeatureDatasetMetaData;
import schmitzm.jfree.feature.FeatureDatasetSelectionModel;
-import skrueger.AttributeMetadata;
-import skrueger.geotools.AttributeMetadataMap;
/**
* This class contains static utility methods related to chart styles based on
@@ -187,7 +184,7 @@
* attribute existing is checked!)
*/
private static void checkAttributeType(SimpleFeatureType fType,
- String aName, Class typeToCheck, String... errDesc) {
+ String aName, Class<?> typeToCheck, String... errDesc) {
AttributeDescriptor aDesc = fType.getDescriptor(aName);
if (aDesc == null)
throw new UnsupportedOperationException("Unknown attribute: "
@@ -286,13 +283,11 @@
for (int attrIdx = 1; attrIdx < attrCount; attrIdx++) {
String yAttrName = chartStyle.getAttributeName(attrIdx);
Number yValue = (Number) f.getAttribute(yAttrName);
- // // TODO: here maybe filtering the several NULL aliases
- // if ( yValue is a NULL alias )
- // yValue = null;
- // // TODO: her maybe ignore NULL values completely
- // if ( yValue == null )
- // continue;
+ // Filter out NoDataValues
+ yValue = chartStyle.filterNoDataValue(attrIdx, yValue);
+ if (yValue == null)
+ continue;
/* Normalization of a range axis value */
if (chartStyle.isAttributeNormalized(attrIdx))
@@ -367,19 +362,23 @@
if (chartStyle.isAttributeNormalized(attrIdx)) {
String attrName = chartStyle
.getAttributeName(attrIdx);
-
+
StaticBin1D stat = attribStats.get(attrName);
if (stat == null) {
stat = new DynamicBin1D();
attribStats.put(attrName, stat);
}
- // // TODO: here also filtering the several NULL
- // aliases and do not
- // // insert them into the statistics calculation
- // // if ( yValue is a NULL alias )
- // // yValue = null;
- final Double doubleValue = new Double(((Number) f
- .getAttribute(attrName)).doubleValue());
+
+ Object rawValue = f.getAttribute(attrName);
+
+ // Filter out NoDataValues
+ rawValue = chartStyle.filterNoDataValue(attrIdx,
+ rawValue);
+ if (rawValue == null)
+ continue;
+
+ final Double doubleValue = new Double(
+ ((Number) rawValue).doubleValue());
stat.add(doubleValue);
// LOGGER.debug("Adding "+doubleValue+" and sd = "+stat.standardDeviation()+" and mean = "+stat.mean());
}
@@ -493,14 +492,11 @@
String yAttrName = chartStyle.getAttributeName(attrIdx);
Number yValue = (Number) f.getAttribute(yAttrName);
- // TODO: here maybe filtering the several NULL aliases
- // if ( yValue is a NULL alias )
- // yValue = null;
+ // Filter out NoDataValues
+ yValue = chartStyle.filterNoDataValue(attrIdx, yValue);
+ if (yValue == null)
+ continue;
- // TODO: here maybe ignore NULL values completely.
- // if ( yValue == null )
- // continue;
-
/* Normalization of a range axis value */
if (chartStyle.isAttributeNormalized(attrIdx))
yValue = normalize(yValue, yAttrName,
@@ -523,18 +519,20 @@
return dataset;
}
-
/**
- * After loading from XML, the ChartStyle contains whatever is written
- * in the XML. But the DBF Schema can change quickly by accident! This method checks an
- * {@link FeatureChartStyle} against a schema and also corrects
- * upperCase/lowerCase problems.
+ * After loading from XML, a {@link FeatureChartStyle} contains whatever is
+ * written in the XML. But the DBF Schema can change quickly by accident!
+ * This method checks an {@link FeatureChartStyle} against a schema and
+ * corrects upperCase/lowerCase problems where possible.
*
- * Returns false if attributes had to be removed from the {@link FeatureChartStyle}.
+ * Returns <code>false</code> if attributes had to be removed from the
+ * {@link FeatureChartStyle}.
+ *
+ * @author SK
*/
- public static boolean correctAttributeNames(FeatureChartStyle featureChartStyle,
- SimpleFeatureType schema) {
+ public static boolean correctAttributeNames(
+ FeatureChartStyle featureChartStyle, SimpleFeatureType schema) {
ArrayList<Integer> willRemove = new ArrayList<Integer>();
@@ -544,7 +542,7 @@
for (int idx = 0; idx < featureChartStyle.getAttributeCount(); idx++) {
String attributeName = featureChartStyle.getAttributeName(idx);
-
+
AttributeDescriptor foundDescr = schema
.getDescriptor(attributeName);
if (foundDescr == null) {
@@ -553,8 +551,9 @@
if (bestMatch == null)
willRemove.add(idx);
else
- featureChartStyle.setAttributeName(idx,bestMatch.getLocalPart());
- }
+ featureChartStyle.setAttributeName(idx, bestMatch
+ .getLocalPart());
+ }
}
// Remove the ones that were not findable in the schema
@@ -562,7 +561,8 @@
featureChartStyle.removeAttribute(removeIdx);
}
- // * Returns false if attributes had to be removed from the {@link FeatureChartStyle}.
+ // * Returns false if attributes had to be removed from the {@link
+ // FeatureChartStyle}.
return willRemove.isEmpty();
}
}
More information about the Schmitzm-commits
mailing list