# HG changeset patch # User Ingo Weinzierl # Date 1323950706 0 # Node ID 156304542edf40b307d5c94f33fcddbedd7aa189 # Parent 158b3aabda2c9f98421ea6d1d6bc04c6af0cf650 Finished the ChartSection part of the chart Settings returned by the XYChartGenerator. flys-artifacts/trunk@3423 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 158b3aabda2c -r 156304542edf flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: diff -r 158b3aabda2c -r 156304542edf flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.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)); } diff -r 158b3aabda2c -r 156304542edf flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java --- 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)); } diff -r 158b3aabda2c -r 156304542edf flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java --- 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)); } diff -r 158b3aabda2c -r 156304542edf flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- 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)); } diff -r 158b3aabda2c -r 156304542edf flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java --- 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)); } diff -r 158b3aabda2c -r 156304542edf flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- 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. Note: this method always returns true! + * + * @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);