Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 3409:97ad960f5579
Add subtitle to Fix W/Q chart and refactor addSubtitle() method(s)
flys-artifacts/trunk@5062 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 12:59:56 +0000 |
parents | 45af081061e7 |
children | 118fe1cc8cc8 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Thu Jul 19 12:55:45 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Thu Jul 19 12:59:56 2012 +0000 @@ -53,6 +53,7 @@ import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.title.TextTitle; import org.jfree.data.Range; import org.jfree.data.general.Series; import org.jfree.data.xy.XYDataset; @@ -570,13 +571,21 @@ /** - * This method should be used by concrete subclasses to add subtitle to - * <i>chart</i>. <b>The method in this implementation is empty</b>. + * This method retrieves the chart subtitle by calling getChartSubtitle() + * and adds it as TextTitle to the chart. + * The default implementation of getChartSubtitle() returns the same + * as getDefaultChartSubtitle() which must be implemented by derived + * classes. If you want to add multiple subtitles to the chart override + * this method and add your subtitles manually. * * @param chart The JFreeChart chart object. */ protected void addSubtitles(JFreeChart chart) { - // do nothing + String subtitle = getChartSubtitle(); + + if (subtitle != null && subtitle.length() > 0) { + chart.addSubtitle(new TextTitle(subtitle)); + } }