changeset 2249:997df76c6f58

Create title, subtitle and axes labels for charts from type historical discharge curve. flys-artifacts/trunk@3898 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 03 Feb 2012 13:42:48 +0000 (2012-02-03)
parents e1eaf9c2b5bf
children 40608c82e9cb
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.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 7 files changed, 88 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 03 13:42:48 2012 +0000
@@ -1,3 +1,18 @@
+2012-02-03  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/utils/FLYSUtils.java: Added a function
+	  that returns the name of a reference gauge (for historical discharge
+	  curves).
+
+	* src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java:
+	  Create title, subtitle and axes labels for charts of this type.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added title, subtitle and axes
+	  labels for historical discharge curves.
+
 2012-02-03  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java	Fri Feb 03 13:42:48 2012 +0000
@@ -9,6 +9,7 @@
 
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.title.TextTitle;
 
 import org.jfree.data.general.SeriesException;
 import org.jfree.data.time.Day;
@@ -22,6 +23,7 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.Timerange;
 import de.intevation.flys.artifacts.model.WQTimerange;
+import de.intevation.flys.utils.FLYSUtils;
 
 
 /**
@@ -35,6 +37,22 @@
         Logger.getLogger(HistoricalDischargeCurveGenerator.class);
 
 
+    public static final String I18N_CHART_TITLE =
+        "chart.historical.discharge.title";
+
+    public static final String I18N_CHART_SUBTITLE =
+        "chart.historical.discharge.subtitle";
+
+    public static final String I18N_XAXIS_LABEL =
+        "chart.historical.discharge.xaxis.label";
+
+    public static final String I18N_YAXIS_LABEL =
+        "chart.historical.discharge.yaxis.label";
+
+    public static final String I18N_YAXIS_SECOND_LABEL =
+        "chart.historical.discharge.yaxis.second.label";
+
+
     public static enum YAXIS {
         Q(0);
         protected int idx;
@@ -63,7 +81,17 @@
 
     @Override
     protected String getDefaultChartTitle() {
-        return "TODO: CHART TITLE";
+        return msg(I18N_CHART_TITLE, I18N_CHART_TITLE);
+    }
+
+
+    @Override
+    protected String getDefaultChartSubtitle() {
+        String[] args = new String[] {
+            FLYSUtils.getReferenceGaugeName((FLYSArtifact) master)
+        };
+
+        return msg(I18N_CHART_SUBTITLE, "", args);
     }
 
 
@@ -72,18 +100,30 @@
      */
     @Override
     protected void addSubtitles(JFreeChart chart) {
-        // this chart has no subtitle
+        String subtitle = getChartSubtitle();
+
+        if (subtitle != null && subtitle.length() > 0) {
+            chart.addSubtitle(new TextTitle(subtitle));
+        }
     }
 
 
     @Override
     protected String getDefaultXAxisLabel() {
-        return "TODO: DEFAULT X AXIS LABEL";
+        return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL);
     }
 
     @Override
     protected String getDefaultYAxisLabel(int pos) {
-        return "TODO: DEFAULT Y AXIS LABEL FOR: " + pos;
+        if (pos == 0) {
+            return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL);
+        }
+        else if (pos == 1) {
+            return msg(I18N_YAXIS_SECOND_LABEL, I18N_YAXIS_SECOND_LABEL);
+        }
+        else {
+            return "NO TITLE FOR Y AXIS: " + pos;
+        }
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Fri Feb 03 13:42:48 2012 +0000
@@ -458,6 +458,15 @@
     }
 
 
+    public static String getReferenceGaugeName(FLYSArtifact flys) {
+        Gauge refGauge = getReferenceGauge(flys);
+
+        return refGauge != null
+            ? refGauge.getName()
+            : "-- not found --";
+    }
+
+
     public static Double getValueFromWQ(WQ wq) {
         if (wq == null) {
             return null;
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Fri Feb 03 13:42:48 2012 +0000
@@ -79,6 +79,11 @@
 chart.duration.curve.yaxis.label = W [NN + m]
 chart.duration.curve.curve.w = Waterlevel duration curve for {0}
 chart.duration.curve.curve.q = Discharge duration curve for {0}
+chart.historical.discharge.title = Historical Discharge Curves
+chart.historical.discharge.subtitle = Gauge {0}
+chart.historical.discharge.xaxis.label = Time
+chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
+chart.historical.discharge.yaxis.second.label = W [cm]
 
 chart.w_differences.title = Differences
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 03 13:42:48 2012 +0000
@@ -79,6 +79,11 @@
 chart.duration.curve.yaxis.label = W [NN + m]
 chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0}
 chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0}
+chart.historical.discharge.title = Historische Abflusskurven
+chart.historical.discharge.subtitle = Pegel {0}
+chart.historical.discharge.xaxis.label = Zeit
+chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
+chart.historical.discharge.yaxis.second.label = W [cm]
 
 chart.w_differences.title = Differenzen
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 03 13:42:48 2012 +0000
@@ -79,6 +79,11 @@
 chart.duration.curve.yaxis.label = W [NN + m]
 chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0}
 chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0}
+chart.historical.discharge.title = Historische Abflusskurven
+chart.historical.discharge.subtitle = Pegel {0}
+chart.historical.discharge.xaxis.label = Zeit
+chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
+chart.historical.discharge.yaxis.second.label = W [cm]
 
 chart.w_differences.title = Differenzen
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 03 13:33:58 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 03 13:42:48 2012 +0000
@@ -77,6 +77,11 @@
 chart.duration.curve.yaxis.label = W [NN + m]
 chart.duration.curve.curve.w = Waterlevel duration curve for {0}
 chart.duration.curve.curve.q = Discharge duration curve for {0}
+chart.historical.discharge.title = Historical Discharge Curves for Gauge {0}
+chart.historical.discharge.subtitle = Gauge {0}
+chart.historical.discharge.xaxis.label = Time
+chart.historical.discharge.yaxis.label = Q [m\u00b3/s]
+chart.historical.discharge.yaxis.second.label = W [cm]
 
 chart.w_differences.title = Differences
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}

http://dive4elements.wald.intevation.org