diff flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java @ 1700:13a9ee6cebef

Fix most labels in w-diff diagrams; refactoring to allow easier adoption of labels in LongitudinalSectionGenerator subclasses. flys-artifacts/trunk@2934 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 11 Oct 2011 10:44:12 +0000
parents 0c9f7cc2cc11
children 6e59208839ae
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Tue Oct 11 10:38:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Tue Oct 11 10:44:12 2011 +0000
@@ -21,7 +21,7 @@
 import de.intevation.flys.utils.DataUtil;
 
 import de.intevation.flys.artifacts.model.WQKms;
-
+import de.intevation.flys.utils.FLYSUtils;
 
 
 /**
@@ -35,33 +35,57 @@
     private static Logger logger =
         Logger.getLogger(WDifferencesCurveGenerator.class);
 
-    public static final String I18N_CHART_TITLE =
-        "chart.w_differences.title";
-
-    public static final String I18N_CHART_SUBTITLE =
-        "chart.w_differences.subtitle";
 
-    public static final String I18N_YAXIS_LABEL =
-        "chart.w_differences.yaxis.label";
-
-    public static final String I18N_2YAXIS_LABEL =
-        "chart.w_differences.yaxis.second.label";
-
-    // TODO proper i18n.
-    public static final String I18N_CHART_TITLE_DEFAULT  = "W-Differenzen";
-    public static final String I18N_XAXIS_LABEL_DEFAULT  = "km";
-    public static final String I18N_YAXIS_LABEL_DEFAULT  = "W [m]";
-    public static final String I18N_2YAXIS_LABEL_DEFAULT = "W [NN + m]";
+    /**
+     * Get internationalized title for chart.
+     */
+    public String getChartTitle() {
+        return msg("chart.w_differences.title", "Differences");
+    }
 
 
     /**
-     * Add a subtitle to Chart.
-     * @param chart Chart to add subtitle to.
+     * Get default value for the second Y-Axis' label (if no translation was
+     * found).
      */
     @Override
-    protected void addSubtitles(JFreeChart chart) {
-        String subtitle = msg(I18N_CHART_SUBTITLE, "");
-        chart.addSubtitle(new TextTitle(subtitle));
+    protected String get2YAxisDefaultLabel() {
+        return "W [NN + m]";
+    }
+
+
+    /**
+     * Gets key to look up internationalized String for the charts subtitle.
+     * @return key to look up translated subtitle.
+     */
+    @Override
+    protected String getChartSubtitleKey() {
+        return "chart.w_differences.subtitle";
+    }
+
+
+    /**
+     * Get key for internationalization of the second Y-Axis' label.
+     */
+    @Override
+    protected String get2YAxisLabelKey() {
+        return "chart.w_differences.yaxis.second.label";
+    }
+
+
+    /**
+     * Get internationalized label for the y axis.
+     */
+    @Override
+    protected String getYAxisLabel() {
+        FLYSArtifact flys = (FLYSArtifact) master;
+
+        String unit = FLYSUtils.getRiver(flys).getWstUnit().getName();
+
+        return msg(
+            "chart.w_differences.yaxis.label",
+            "m",
+            new Object[] { unit });
     }
 
 

http://dive4elements.wald.intevation.org