changeset 3984:89d7e97e9c9a

Manual points working in fixing Delta W/t char (#462).
author Christian Lins <clins@intevation.de>
date Sat, 29 Sep 2012 20:09:27 +0200
parents 65e369ac4f99
children a4930c43b806
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java
diffstat 3 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sat Sep 29 11:38:38 2012 +0200
+++ b/flys-artifacts/ChangeLog	Sat Sep 29 20:09:27 2012 +0200
@@ -1,3 +1,9 @@
+2012-09-29	Christian Lins	<christian.lins@intevation.de>
+
+	* flys-artifacts/doc/conf/themes.xml,
+	  flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java:
+	  Manual Points working in Fixing Delta W/t chart (#462).
+
 2012-09-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java:
--- a/flys-artifacts/doc/conf/themes.xml	Sat Sep 29 11:38:38 2012 +0200
+++ b/flys-artifacts/doc/conf/themes.xml	Sat Sep 29 20:09:27 2012 +0200
@@ -265,6 +265,7 @@
 		<mapping from="fix_reference_events_ls" to="FixLSReference" />
 		<mapping from="fix_derivate_curve" to="FixingDerivedCurve" />
 		<mapping from="fix_derivate_curve.manualpoints" to="ManualPoints" />
+		<mapping from="fix_deltawt_curve.manualpoints" to="ManualPoints" />
 		<mapping from="qsectors" to="QSectors" />
 	</mappings>
 </themes>
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Sat Sep 29 11:38:38 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java	Sat Sep 29 20:09:27 2012 +0200
@@ -1,6 +1,7 @@
 package de.intevation.flys.exports;
 
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
+import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.jfree.Bounds;
 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
 import de.intevation.flys.jfree.DoubleBounds;
@@ -10,6 +11,8 @@
 
 import java.awt.Color;
 import java.awt.Font;
+import java.text.DateFormat;
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -656,6 +659,20 @@
     }
 
 
+    protected Date decodeXAxisValue(JSONArray array) throws JSONException, ParseException {
+        try {
+            double x = array.getDouble(0);
+            long l = (new Double(x)).longValue();
+            return new Date(l);
+        }
+        catch(JSONException ex) {
+            String str = array.getString(0);
+            DateFormat df = DateFormat.getDateInstance(
+                    DateFormat.MEDIUM, Resources.getLocale(context.getMeta()));
+            return df.parse(str);
+        }
+    }
+
     /**
      * Do Points out.
      */
@@ -677,22 +694,26 @@
             JSONArray points = new JSONArray((String) o);
             for (int i = 0, P = points.length(); i < P; i++) {
                 JSONArray array = points.getJSONArray(i);
-                double x    = array.getDouble(0);
+
                 double y    = array.getDouble(1);
                 String name = array.getString(2);
                 boolean act = array.getBoolean(3);
                 if (!act) {
                     continue;
                 }
-                long l = (new Double(x)).longValue();
-                Date date = new Date(l);
+
+                Date date = decodeXAxisValue(array);
+
                 Day day = new Day(date);
                 series.add(day, y, false);
                 names.put(day, name);
             }
         }
-        catch(JSONException e){
-            logger.error("Could not decode json.");
+        catch(JSONException ex) {
+            logger.error("Could not decode json");
+        }
+        catch(ParseException ex) {
+            logger.error("Could not parse date string");
         }
 
         TimeSeriesCollection tsc = new TimeSeriesCollection();
@@ -703,6 +724,7 @@
             double y = tsc.getYValue(0, i);
             xy.add(new CollisionFreeXYTextAnnotation(
                        names.get(series.getTimePeriod(i)), x, y));
+            logger.debug("doPoints(): x=" + x + " y=" + y);
         }
         FLYSAnnotation annotations =
             new FLYSAnnotation(null, null, null, theme);

http://dive4elements.wald.intevation.org