changeset 1958:82cefa3f954f

Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents. flys-artifacts/trunk@3359 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 06 Dec 2011 10:26:07 +0000 (2011-12-06)
parents 3b08b8aacfb0
children eace020067da
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 2 files changed, 31 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Dec 06 08:26:24 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Dec 06 10:26:07 2011 +0000
@@ -1,3 +1,15 @@
+2011-12-06	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Partial fix for flys/issue420 (Berechnete Abflusskurve: Kein Diagramm f�r
+	Mosel). Protect axis extent calculation from empty or invalid
+	datasets.
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  (includeRange, includeYRange): Renamed, updated callers.
+	  (includeYRange): Protect from merging extent with NaNs.
+	  (debugDatasets): Be more verbose on the datasets.
+	  (zoom): Doc.
+
 2011-12-06	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Fix flys/issue423 (Diagramm: Hauptwerte bei Abflusskurve am Pegel
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue Dec 06 08:26:24 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue Dec 06 10:26:07 2011 +0000
@@ -88,11 +88,16 @@
         /** Add a dataset, include its range. */
         public void addDataset(XYSeries dataset) {
             this.datasets.add(new XYSeriesCollection(dataset));
-            includeRange(dataset);
+            includeYRange(dataset);
         }
 
         /** Adjust range to include given dataset. */
-        public void includeRange(XYSeries dataset) {
+        public void includeYRange(XYSeries dataset) {
+            // Avoid merging NaNs, as they take min/max place forever.
+            if (Double.isNaN(dataset.getMinY()) ||
+                Double.isNaN(dataset.getMaxY())) {
+                return;
+            }
             mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY()));
         }
 
@@ -258,6 +263,11 @@
                 continue;
             }
             logger.debug("Dataset #" + i + ":" + plot.getDataset(i));
+            XYSeriesCollection series = (XYSeriesCollection) plot.getDataset(i);
+            logger.debug("X-Extend of Dataset: " + series.getSeries(0).getMinX()
+                    + " " + series.getSeries(0).getMaxX());
+            logger.debug("Y-Extend of Dataset: " + series.getSeries(0).getMinY()
+                    + " " + series.getSeries(0).getMaxY());
         }
     }
 
@@ -335,13 +345,16 @@
             datasets.put(index, axisDataset);
         }
 
+        logger.debug("Series-extent x " + series.getMinX() + " : " + series.getMaxX()
+            + " extend y " + series.getMinY() + " : " + series.getMaxY());
+
         if (visible) {
             axisDataset.addDataset(series);
         }
         else {
             // Do this also when not visible to have axis scaled by default such
             // that every data-point could be seen (except for annotations).
-            axisDataset.includeRange(series);
+            axisDataset.includeYRange(series);
         }
 
         combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0);
@@ -491,10 +504,10 @@
     /**
      * Zooms the x axis to the range specified in the attribute document.
      *
-     * @param plot The XYPlot.
-     * @param axis The axis the shoud be modified.
+     * @param plot  The XYPlot.
+     * @param axis  The axis the shoud be modified.
      * @param range The whole range specified by a dataset.
-     * @param x A user defined range (null permitted).
+     * @param x     A user defined range (null permitted).
      *
      * @return true, if a zoom range was specified, otherwise false.
      */

http://dive4elements.wald.intevation.org