[Schmitzm-commits] r871 - in trunk/src/schmitzm/jfree: . feature/style
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri May 28 14:36:53 CEST 2010
Author: mojays
Date: 2010-05-28 14:36:51 +0200 (Fri, 28 May 2010)
New Revision: 871
Modified:
trunk/src/schmitzm/jfree/JFreeChartUtil.java
trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
Log:
Removed out lines from FeatureChartUtil.createXYDataset(.)
Modified: trunk/src/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/JFreeChartUtil.java 2010-05-28 12:07:14 UTC (rev 870)
+++ trunk/src/schmitzm/jfree/JFreeChartUtil.java 2010-05-28 12:36:51 UTC (rev 871)
@@ -82,6 +82,8 @@
import org.jfree.data.general.Dataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.general.PieDataset;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
@@ -535,7 +537,22 @@
}
}
- /**
+ /**
+ * Returns a series from a dataset. If no series exists a new one is created.
+ * @param dataset the dataset
+ * @param seriesKey the key to return the series for
+ * @return never {@code null}
+ */
+ public static TimeSeries getOrAddSeriesFromDataset(TimeSeriesCollection dataset, Comparable seriesKey) {
+ TimeSeries timeSeries = dataset.getSeries(seriesKey);
+ if ( timeSeries == null ) {
+ timeSeries = new TimeSeries(seriesKey);
+ dataset.addSeries( timeSeries );
+ }
+ return timeSeries;
+ }
+
+ /**
* Searchs the renderers of a plot for {@link SelectionRenderer} for a
* {@link Dataset}.
*
Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java 2010-05-28 12:07:14 UTC (rev 870)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java 2010-05-28 12:36:51 UTC (rev 871)
@@ -234,26 +234,11 @@
for (int i = 1; i < attrCount; i++)
statisticsForAggregation[i] = new HashMap<Comparable<?>, QuantileBin1D>();
-//MS-01.so
-//### Because of the potential grouping attribute, the series can
-//### not be prepared anymore
-// // Create a series for each range attribute (note: the 0
-// // array element useless, but it is more comfortable to
-// // use an array of the same size as "attributes"
-// XYSeries[] xySeries = new XYSeries[attrCount];
-// for (int i = 1; i < xySeries.length; i++)
-// // IMPORTANT: Do not use autosort!!
-// xySeries[i] = new XYSeries(chartStyle.getAttributeName(i), false, true);
-//MS-01.eo
// Create a new dataset and insert the series
XYSeriesCollection dataset = new XYSeriesCollection();
Feature2SeriesDatasetMapping mapping = new Feature2SeriesDatasetMapping(fc,
dataset);
dataset.setGroup(new FeatureDatasetMetaData(mapping));
-//MS-01.so
-// for (int i = 1; i < xySeries.length; i++)
-// dataset.addSeries(xySeries[i]);
-//MS-01.eo
// If dataset should be sorted, the features must be sorted first
// according to the domain attribute. The "autoSort" functionality
@@ -323,8 +308,6 @@
// Otherwise fill statistic (dataset is filled later!)
if (chartStyle.getAttributeAggregation(attrIdx) == null) {
// Fill series
-//MS-01.sc
-// xySeries[attrIdx].add(xValue, yValue);
String yAttrName = chartStyle.getAttributeName(attrIdx);
// If grouping series attribute is used, add its value
// to the series ID
@@ -333,7 +316,7 @@
XYSeries xySeries = JFreeChartUtil.getOrAddSeriesFromDataset(dataset, yAttrName, false, true);
xySeries.add(xValue, yValue);
-//MS-01.ec
+
// Mapping between FID and data index in series
mapping.setMapping(f.getID(), yAttrName, datasetIdx++);
} else {
@@ -373,11 +356,8 @@
yValue = normalize(yValue, yAttrName, statisticsForNormalization);
// Fill series
-//MS-01.sc
-// xySeries[attrIdx].add(((Number) xValue), yValue);
XYSeries xySeries = JFreeChartUtil.getOrAddSeriesFromDataset(dataset, yAttrName, false, true);
xySeries.add((Number)xValue, yValue);
-//MS-01.ec
// TODO: Mapping setzen
// Problem: Pro dataset item kann nur EINE FeatureID gesetzt
More information about the Schmitzm-commits
mailing list