# HG changeset patch # User Christian Lins # Date 1348942167 -7200 # Node ID 89d7e97e9c9a1d8c0fe5a87cce09bb67b712469e # Parent 65e369ac4f9938e14c1b00c03237ef9a49671698 Manual points working in fixing Delta W/t char (#462). diff -r 65e369ac4f99 -r 89d7e97e9c9a flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java: diff -r 65e369ac4f99 -r 89d7e97e9c9a flys-artifacts/doc/conf/themes.xml --- 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 @@ + diff -r 65e369ac4f99 -r 89d7e97e9c9a flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java --- 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);