changeset 2243:d70a04cad84d

Improved chart creation for historical discharge curves. flys-artifacts/trunk@3891 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 03 Feb 2012 10:45:12 +0000
parents 7e8e1d5384c0
children 7335c526befd
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java
diffstat 2 files changed, 25 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 03 09:39:22 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 03 10:45:12 2012 +0000
@@ -1,3 +1,9 @@
+2012-02-03  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java:
+	  Improved adding new data for historical discharge curves: skip NaN
+	  values; use JFreeChart's Day TimePeriod instead of Second.
+
 2012-02-03  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java	Fri Feb 03 09:39:22 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java	Fri Feb 03 10:45:12 2012 +0000
@@ -11,7 +11,7 @@
 import org.jfree.chart.axis.NumberAxis;
 
 import org.jfree.data.general.SeriesException;
-import org.jfree.data.time.Minute;
+import org.jfree.data.time.Day;
 import org.jfree.data.time.RegularTimePeriod;
 import org.jfree.data.time.TimeSeries;
 import org.jfree.data.time.TimeSeriesCollection;
@@ -143,7 +143,6 @@
         boolean      visible)
     {
         logger.debug("doHistoricalDischargeOut(): description = " + desc);
-        logger.warn("TODO IMPLEMENT ME");
 
         WQTimerange wqt = (WQTimerange) data;
 
@@ -178,8 +177,21 @@
 
             try {
                 // TODO WHICH (W/Q) IS REQUIRED?
-                series.add(rtp[0], res[1]);
-                series.add(rtp[1], res[1]);
+                double y = res[1];
+
+                if (Double.isNaN(y)) {
+                    logger.warn("Skip TimePeriod because value is NaN.");
+                    continue;
+                }
+
+                series.add(rtp[0], y);
+                series.add(rtp[1], y);
+
+                if (logger.isDebugEnabled()) {
+                    logger.debug("added Item to TimeSeries:");
+                    logger.debug("   TimePeriod: " + rtp[0] + " - " + rtp[1]);
+                    logger.debug("   Value:      " + res[1]);
+                }
             }
             catch (SeriesException se) {
                 logger.warn("Error while adding TimePeriod: " + se);
@@ -201,11 +213,11 @@
      */
     protected RegularTimePeriod[] newRegularTimePeriod(Timerange timerange) {
         Date start = new Date(timerange.getStart());
-        Date end   = new Date(timerange.getEnd() - 1000 * 60);
+        Date end   = new Date(timerange.getEnd() - 1000 * 60 * 60 * 24);
 
         return new RegularTimePeriod[] {
-            new Minute(start),
-            new Minute(end)
+            new Day(start),
+            new Day(end)
         };
     }
 }

http://dive4elements.wald.intevation.org