changeset 1989:156304542edf

Finished the ChartSection part of the chart Settings returned by the XYChartGenerator. flys-artifacts/trunk@3423 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 15 Dec 2011 12:05:06 +0000
parents 158b3aabda2c
children 5c1e7c1e9e09
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.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/WDifferencesCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 7 files changed, 95 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Dec 15 12:05:06 2011 +0000
@@ -1,3 +1,21 @@
+2011-12-15  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Introduced
+	  methods getChartSubtitle() and isGridVisible(). getChartSubtitle() returns
+	  in this implementation null. Concrete subclasses should override this
+	  mehtod if they require subtitles in charts. isGridVisible() determines if
+	  the grid in the chart should be visible or not. This method return always
+	  true in this implementation.
+	  In addition, the Settings object returned by getSettings() will now have a
+	  ChartSection set properly.
+
+	* src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java:
+	  Override getChartSubtitle().
+
 2011-12-15  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Thu Dec 15 12:05:06 2011 +0000
@@ -64,7 +64,7 @@
 
 
     @Override
-    protected void addSubtitles(JFreeChart chart) {
+    protected String getChartSubtitle() {
         double[] dist = getRange();
 
         Object[] args = new Object[] {
@@ -72,7 +72,13 @@
             dist[0]
         };
 
-        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        return msg(I18N_CHART_SUBTITLE, "", args);
+    }
+
+
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+        String subtitle = getChartSubtitle();
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu Dec 15 12:05:06 2011 +0000
@@ -61,11 +61,8 @@
     }
 
 
-    /**
-     * Add localized subtitle to chart.
-     */
     @Override
-    protected void addSubtitles(JFreeChart chart) {
+    protected String getChartSubtitle() {
         double[] dist = getRange();
 
         Object[] args = new Object[] {
@@ -73,7 +70,16 @@
             getKm()
         };
 
-        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        return msg(I18N_CHART_SUBTITLE, "", args);
+    }
+
+
+    /**
+     * Add localized subtitle to chart.
+     */
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+        String subtitle = getChartSubtitle();
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Thu Dec 15 12:05:06 2011 +0000
@@ -107,7 +107,7 @@
 
 
     @Override
-    protected void addSubtitles(JFreeChart chart) {
+    protected String getChartSubtitle() {
         double[] dist  = getRange();
 
         Object[] args = new Object[] {
@@ -115,7 +115,13 @@
             dist[0]
         };
 
-        String subtitle = msg(I18N_CHART_SUBTITLE, "", args);
+        return msg(I18N_CHART_SUBTITLE, "", args);
+    }
+
+
+    @Override
+    protected void addSubtitles(JFreeChart chart) {
+        String subtitle = getChartSubtitle();
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Dec 15 12:05:06 2011 +0000
@@ -115,6 +115,22 @@
     }
 
 
+    @Override
+    protected String getChartSubtitle() {
+        double[] dist = getRange();
+
+        Object[] args = new Object[] {
+            getRiverName(),
+
+            dist[0],
+
+            dist[1]
+        };
+
+        return msg(getChartSubtitleKey(), "", args);
+    }
+
+
     /**
      * Gets key to look up internationalized String for the charts subtitle.
      * @return key to look up translated subtitle.
@@ -130,17 +146,7 @@
      */
     @Override
     protected void addSubtitles(JFreeChart chart) {
-        double[] dist = getRange();
-
-        Object[] args = new Object[] {
-            getRiverName(),
-
-            dist[0],
-
-            dist[1]
-        };
-
-        String subtitle = msg(getChartSubtitleKey(), "", args);
+        String subtitle = getChartSubtitle();
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Thu Dec 15 12:05:06 2011 +0000
@@ -52,6 +52,12 @@
     }
 
 
+    @Override
+    protected String getChartSubtitle() {
+        return getRiverName();
+    }
+
+
     /**
      * Gets key to look up internationalized String for the charts subtitle.
      * @return key to look up translated subtitle.
@@ -69,14 +75,7 @@
      */
     @Override
     protected void addSubtitles(JFreeChart chart) {
-
-        // TODO i18n
-        /*
-        Object[] args = new Object[] {
-            getRiverName()
-        };
-        */
-        String subtitle = getRiverName();
+        String subtitle = getChartSubtitle();
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Dec 15 10:09:02 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Dec 15 12:05:06 2011 +0000
@@ -146,6 +146,29 @@
 
 
     /**
+     * This method always returns null. If a concrete subclass of this class
+     * requires a chart subtitle, this subclass can easily override this method.
+     *
+     * @return always null.
+     */
+    protected String getChartSubtitle() {
+        // overridden this method in subclasses that need subtitles
+        return null;
+    }
+
+
+    /**
+     * This method is used to determine if the resulting chart should display
+     * grid lines or not. <b>Note: this method always returns true!</b>
+     *
+     * @return true, if the chart should display grid lines, otherwise false.
+     */
+    protected boolean isGridVisible() {
+        return true;
+    }
+
+
+    /**
      * Returns the X-Axis label of a chart.
      *
      * @return the X-Axis label of a chart.
@@ -834,11 +857,9 @@
         ChartSettings settings = new ChartSettings();
 
         ChartSection chartSection = new ChartSection();
-        // XXX Before we can do this, the FLYSArtifactCollection needs to call
-        // doOut() for each facet.
-        //chartSection.setTitle(getChartTitle());
-        //chartSection.setSubtitle("TODO SUBTITLE");
-        //chartSection.setDisplayGird(true);
+        chartSection.setTitle(getChartTitle());
+        chartSection.setSubtitle(getChartSubtitle());
+        chartSection.setDisplayGird(isGridVisible());
 
         settings.setChartSection(chartSection);
 

http://dive4elements.wald.intevation.org