changeset 414:0385bcc4229a

Added subtitles to the available charts. flys-artifacts/trunk@1878 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 10 May 2011 12:19:17 +0000
parents 8a4c219fd0ee
children 7c018f466d6d
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.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 10 files changed, 102 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 10 12:19:17 2011 +0000
@@ -1,3 +1,21 @@
+2011-05-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Added a
+	  method to add subtitles to charts. The implementation in this class does
+	  not add any subtitle. Concrete subclasses may override this method to
+	  add some.
+
+	* src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java:
+	  Add subtitles to charts.
+
+	* 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 i18n templates for
+	  compound messages (chart subtitles).
+
 2011-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/resources/Resources.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Tue May 10 12:19:17 2011 +0000
@@ -4,6 +4,9 @@
 
 import org.w3c.dom.Document;
 
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.title.TextTitle;
+
 import de.intevation.artifacts.Artifact;
 
 import de.intevation.flys.artifacts.WINFOArtifact;
@@ -25,6 +28,9 @@
     public static final String I18N_CHART_TITLE =
         "chart.computed.discharge.curve.title";
 
+    public static final String I18N_CHART_SUBTITLE =
+        "chart.computed.discharge.curve.subtitle";
+
     public static final String I18N_YAXIS_LABEL =
         "chart.computed.discharge.curve.yaxis.label";
 
@@ -39,6 +45,20 @@
 
 
     @Override
+    protected void addSubtitles(JFreeChart chart) {
+        double[] dist  = getRange();
+
+        Object[] args = new Object[] {
+            getRiverName(),
+            dist[0]
+        };
+
+        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        chart.addSubtitle(new TextTitle(subtitle));
+    }
+
+
+    @Override
     protected String getYAxisLabel() {
         return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Tue May 10 12:19:17 2011 +0000
@@ -37,6 +37,9 @@
     public static final String I18N_CHART_TITLE =
         "chart.discharge.curve.title";
 
+    public static final String I18N_CHART_SUBTITLE =
+        "chart.discharge.curve.subtitle";
+
     public static final String I18N_XAXIS_LABEL =
         "chart.discharge.curve.xaxis.label";
 
@@ -64,6 +67,12 @@
     }
 
 
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+
+    }
+
+
     protected String getXAxisLabel() {
         return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Tue May 10 12:19:17 2011 +0000
@@ -7,6 +7,7 @@
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.title.TextTitle;
 import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
 
@@ -42,6 +43,9 @@
     public static final String I18N_CHART_TITLE =
         "chart.duration.curve.title";
 
+    public static final String I18N_CHART_SUBTITLE =
+        "chart.duration.curve.subtitle";
+
     public static final String I18N_XAXIS_LABEL =
         "chart.duration.curve.xaxis.label";
 
@@ -71,6 +75,20 @@
     }
 
 
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+        double[] dist  = getRange();
+
+        Object[] args = new Object[] {
+            getRiverName(),
+            dist[0]
+        };
+
+        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        chart.addSubtitle(new TextTitle(subtitle));
+    }
+
+
     protected String getXAxisLabel() {
         return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue May 10 12:19:17 2011 +0000
@@ -5,6 +5,7 @@
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.title.TextTitle;
 import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
 
@@ -37,6 +38,9 @@
     public static final String I18N_CHART_TITLE =
         "chart.longitudinal.section.title";
 
+    public static final String I18N_CHART_SUBTITLE =
+        "chart.longitudinal.section.subtitle";
+
     public static final String I18N_XAXIS_LABEL =
         "chart.longitudinal.section.xaxis.label";
 
@@ -71,6 +75,21 @@
     }
 
 
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+        double[] dist  = getRange();
+
+        Object[] args = new Object[] {
+            getRiverName(),
+            dist[0],
+            dist[1]
+        };
+
+        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        chart.addSubtitle(new TextTitle(subtitle));
+    }
+
+
     protected String getXAxisLabel() {
         return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue May 10 12:19:17 2011 +0000
@@ -75,7 +75,7 @@
         chart.getPlot().setBackgroundPaint(Color.WHITE);
 
         addDatasets(chart);
-
+        addSubtitles(chart);
         adjustAxes((XYPlot) chart.getPlot());
 
         ChartExportHelper.exportImage(
@@ -96,5 +96,10 @@
 
         yAxis.setAutoRangeIncludesZero(false);
     }
+
+
+    protected void addSubtitles(JFreeChart chart) {
+        // override this method in subclasses that need subtitles
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/resources/messages.properties	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Tue May 10 12:19:17 2011 +0000
@@ -16,6 +16,7 @@
 ld_locations = Location(s)
 
 chart.longitudinal.section.title = W-Longitudinal Section
+chart.longitudinal.section.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.longitudinal.section.xaxis.label = km
 chart.longitudinal.section.yaxis.label = W [NN + m]
 chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
@@ -23,7 +24,9 @@
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
 chart.discharge.curve.yaxis.label = W [cm]
 chart.computed.discharge.curve.title = Discharge Curve
+chart.computed.discharge.curve.subtitle = {0}-km: {1,number,#.###}
 chart.computed.discharge.curve.yaxis.label = W [NN + m]
 chart.duration.curve.title = Duration Curve
+chart.duration.curve.subtitle = {0}-km: {1,number,#.###}
 chart.duration.curve.xaxis.label = Duration of Non-Exceedence [Days]
 chart.duration.curve.yaxis.label = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de.properties	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Tue May 10 12:19:17 2011 +0000
@@ -16,6 +16,7 @@
 ld_locations = Ort(e)
 
 chart.longitudinal.section.title = W-L\u00e4ngsschnitt
+chart.longitudinal.section.subtitle = Bereich: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.longitudinal.section.xaxis.label = km
 chart.longitudinal.section.yaxis.label = W [NN + m]
 chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
@@ -23,7 +24,9 @@
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
 chart.discharge.curve.yaxis.label = W [cm]
 chart.computed.discharge.curve.title = Abflusskurve
+chart.computed.discharge.curve.subtitle = {0}-km: {1,number,#.###}
 chart.computed.discharge.curve.yaxis.label = W [NN + m]
 chart.duration.curve.title = Dauerlinie
+chart.duration.curve.subtitle = {0}-km: {1,number,#.###}
 chart.duration.curve.xaxis.label = Unterschreitungsdauer [Tage]
 chart.duration.curve.yaxis.label = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Tue May 10 12:19:17 2011 +0000
@@ -16,6 +16,7 @@
 ld_locations = Ort(e)
 
 chart.longitudinal.section.title = W-L\u00e4ngsschnitt
+chart.longitudinal.section.subtitle = Bereich: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.longitudinal.section.xaxis.label = km
 chart.longitudinal.section.yaxis.label = W [NN + m]
 chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
@@ -23,7 +24,9 @@
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
 chart.discharge.curve.yaxis.label = W [cm]
 chart.computed.discharge.curve.title = Abflusskurve
+chart.computed.discharge.curve.subtitle = {0}-km: {1,number,#.###}
 chart.computed.discharge.curve.yaxis.label = W [NN + m]
 chart.duration.curve.title = Dauerlinie
+chart.duration.curve.subtitle = {0}-km: {1,number,#.###}
 chart.duration.curve.xaxis.label = Unterschreitungsdauer [Tage]
 chart.duration.curve.yaxis.label = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_en.properties	Tue May 10 11:40:15 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Tue May 10 12:19:17 2011 +0000
@@ -16,6 +16,7 @@
 ld_locations = Location(s)
 
 chart.longitudinal.section.title = W-Longitudinal Section
+chart.longitudinal.section.subtitle = Range: {0}-km {1,number,double} - {2,number,double}
 chart.longitudinal.section.xaxis.label = km
 chart.longitudinal.section.yaxis.label = W [NN + m]
 chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s]
@@ -23,7 +24,9 @@
 chart.discharge.curve.xaxis.label = Q [m\u00b3/s]
 chart.discharge.curve.yaxis.label = W [cm]
 chart.computed.discharge.curve.title = Discharge Curve
+chart.computed.discharge.curve.subtitle = {0}-km: {1,number,#.###}
 chart.computed.discharge.curve.yaxis.label = W [NN + m]
 chart.duration.curve.title = Duration Curve
+chart.duration.curve.subtitle = {0}-km: {1,number,#.###}
 chart.duration.curve.xaxis.label = Duration of Non-Exceedence [Days]
 chart.duration.curve.yaxis.label = W [NN + m]

http://dive4elements.wald.intevation.org