diff flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java @ 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
parents d70a04cad84d
children b8df8d1476ba
line wrap: on
line diff
--- 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;
+        }
     }
 
 

http://dive4elements.wald.intevation.org