changeset 4152:5ff3b2f5fb1c

Added evaluation timerange to subtitle of historical discharge curve charts.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 16 Oct 2012 12:42:52 +0200
parents 0182916dcb01
children 3245bb4d600b 1755a1bfe5ce
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 8 files changed, 87 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/ChangeLog	Tue Oct 16 12:42:52 2012 +0200
@@ -1,3 +1,24 @@
+2012-10-16  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue930
+
+	* src/main/java/de/intevation/flys/artifacts/access/Access.java: Added new
+	  method to retrieve long[] values separated with a ';'.
+
+	* src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java:
+	  New. Access class to retrieve information for historical discharge
+	  curves.
+
+	* src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java:
+	  Add the evaluation timerange provided by HistoricalDischargeAccess to
+	  the subtitle of those charts.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties: Added start and end date to
+	  subtitle of historical discharge curve charts.
+
 2012-10-16	Christian Lins	<christian.lins@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java	Tue Oct 16 12:42:52 2012 +0200
@@ -9,6 +9,7 @@
 import de.intevation.flys.utils.FLYSUtils;
 
 import gnu.trove.TDoubleArrayList;
+import gnu.trove.TLongArrayList;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -170,5 +171,24 @@
         }
         return list.toNativeArray();
     }
+
+    protected long [] getLongArray(String key) {
+        StateData sd = artifact.getData(key);
+        if (sd == null) {
+            log.warn("missing '" + key + "'");
+            return null;
+        }
+        String [] parts = ((String)sd.getValue()).split("[\\s;]+");
+        TLongArrayList list = new TLongArrayList(parts.length);
+        for (String part: parts) {
+            try {
+                list.add(Long.parseLong(part));
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("'" + part + "' is not numeric.");
+            }
+        }
+        return list.toNativeArray();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java	Tue Oct 16 12:42:52 2012 +0200
@@ -0,0 +1,33 @@
+package de.intevation.flys.artifacts.access;
+
+import java.util.Date;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.Timerange;
+
+
+public class HistoricalDischargeAccess extends RiverAccess {
+
+    public static final String DATA_EVALUATION_TIME = "year_range";
+
+    private Timerange evaluationTimerange;
+
+    public HistoricalDischargeAccess(FLYSArtifact artifact) {
+        super(artifact);
+    }
+
+    public Timerange getEvaluationTimerange() {
+        if (evaluationTimerange == null) {
+            long[] startend = getLongArray(DATA_EVALUATION_TIME);
+
+            if (startend != null && startend.length > 1) {
+                Date start = new Date(startend[0]);
+                Date end = new Date(startend[1]);
+
+                evaluationTimerange = new Timerange(start, end);
+            }
+        }
+
+        return evaluationTimerange;
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java	Tue Oct 16 12:42:52 2012 +0200
@@ -2,6 +2,7 @@
 
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
 import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.access.HistoricalDischargeAccess;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.HistoricalWQTimerange;
 import de.intevation.flys.artifacts.model.Timerange;
@@ -81,8 +82,14 @@
 
     @Override
     protected String getDefaultChartSubtitle() {
-        String[] args = new String[] {
-            FLYSUtils.getReferenceGaugeName((FLYSArtifact) master)
+        FLYSArtifact flys  = (FLYSArtifact) master;
+        Timerange evalTime =
+            new HistoricalDischargeAccess(flys).getEvaluationTimerange();
+
+        Object[] args = new Object[] {
+            FLYSUtils.getReferenceGaugeName(flys),
+            evalTime.getStart(),
+            evalTime.getEnd()
         };
 
         return msg(I18N_CHART_SUBTITLE, "", args);
--- a/flys-artifacts/src/main/resources/messages.properties	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/src/main/resources/messages.properties	Tue Oct 16 12:42:52 2012 +0200
@@ -156,7 +156,7 @@
 chart.duration.curve.curve.w = Waterlevel duration curve for {0} (km: {1})
 chart.duration.curve.curve.q = Discharge duration curve for {0} (km: {1})
 chart.historical.discharge.title = Historical Discharge Curves
-chart.historical.discharge.subtitle = Gauge {0}
+chart.historical.discharge.subtitle = Gauge {0} {1,date,medium} - {2,date,medium}
 chart.historical.discharge.xaxis.label = Time
 chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
 chart.historical.discharge.yaxis.second.label = W [cm]
--- a/flys-artifacts/src/main/resources/messages_de.properties	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Tue Oct 16 12:42:52 2012 +0200
@@ -155,7 +155,7 @@
 chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} (km:{1})
 chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} (km:{1})
 chart.historical.discharge.title = Historische Abflusskurven
-chart.historical.discharge.subtitle = Pegel {0}
+chart.historical.discharge.subtitle = Pegel {0} {1,date,medium} - {2,date,medium} 
 chart.historical.discharge.xaxis.label = Zeit
 chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
 chart.historical.discharge.yaxis.second.label = W [cm]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Tue Oct 16 12:42:52 2012 +0200
@@ -155,7 +155,7 @@
 chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} (km:{1})
 chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} (km:{1})
 chart.historical.discharge.title = Historische Abflusskurven
-chart.historical.discharge.subtitle = Pegel {0}
+chart.historical.discharge.subtitle = Pegel {0} {1,date,medium} - {2,date,medium} 
 chart.historical.discharge.xaxis.label = Zeit
 chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
 chart.historical.discharge.yaxis.second.label = W [cm]
--- a/flys-artifacts/src/main/resources/messages_en.properties	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Tue Oct 16 12:42:52 2012 +0200
@@ -155,7 +155,7 @@
 chart.duration.curve.curve.w = Waterlevel duration curve for {0} (km: {1})
 chart.duration.curve.curve.q = Discharge duration curve for {0} (km: {1})
 chart.historical.discharge.title = Historical Discharge Curves for Gauge {0}
-chart.historical.discharge.subtitle = Gauge {0}
+chart.historical.discharge.subtitle = Gauge {0} {1,date,medium} - {2,date,medium}
 chart.historical.discharge.xaxis.label = Time
 chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
 chart.historical.discharge.yaxis.second.label = W [cm]

http://dive4elements.wald.intevation.org