diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2048:3157a78e6494

Improved chart title and subtitle creation in ChartGenerators - all ChartGenerators make now use of title and subtitle provided by ChartSettings. flys-artifacts/trunk@3538 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 23 Dec 2011 14:24:57 +0000
parents 0318fa6f0844
children 2d5f2bc68cc6
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Dec 23 08:57:25 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Dec 23 14:24:57 2011 +0000
@@ -184,21 +184,54 @@
 
 
     /**
-     * Returns the title of a chart.
+     * Returns the title of a chart. The return value depends on the existence
+     * of ChartSettings: if there are ChartSettings set, this method returns the
+     * chart title provided by those settings. Otherwise, this method returns
+     * getDefaultChartTitle().
      *
      * @return the title of a chart.
      */
-    protected abstract String getChartTitle();
+    protected String getChartTitle() {
+        ChartSettings chartSettings = getChartSettings();
+
+        if (chartSettings != null) {
+            return getChartTitle(chartSettings);
+        }
+
+        return getDefaultChartTitle();
+    }
+
+
+    protected abstract String getDefaultChartTitle();
 
 
     /**
-     * This method always returns null. If a concrete subclass of this class
-     * requires a chart subtitle, this subclass can easily override this method.
+     * Returns the subtitle of a chart. The return value depends on the
+     * existence of ChartSettings: if there are ChartSettings set, this method
+     * returns the chart title provided by those settings. Otherwise, this
+     * method returns getDefaultChartSubtitle().
      *
-     * @return always null.
+     * @return the subtitle of a chart.
      */
     protected String getChartSubtitle() {
-        // overridden this method in subclasses that need subtitles
+        ChartSettings chartSettings = getChartSettings();
+
+        if (chartSettings != null) {
+            return getChartSubtitle(chartSettings);
+        }
+
+        return getDefaultChartSubtitle();
+    }
+
+
+    /**
+     * This method always returns null. Override it in subclasses that require
+     * subtitles.
+     *
+     * @return null.
+     */
+    protected String getDefaultChartSubtitle() {
+        // Override this method in subclasses
         return null;
     }
 

http://dive4elements.wald.intevation.org