Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 1990:5c1e7c1e9e09
Improved the ChartSettings returned by charts - it now contains a legend specific section.
flys-artifacts/trunk@3426 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 15 Dec 2011 15:58:56 +0000 |
parents | 156304542edf |
children | 0bd7c3cf0af1 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Thu Dec 15 12:05:06 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Thu Dec 15 15:58:56 2011 +0000 @@ -38,6 +38,7 @@ import org.jfree.ui.RectangleInsets; import de.intevation.artifactdatabase.state.Facet; +import de.intevation.artifactdatabase.state.Section; import de.intevation.artifactdatabase.state.Settings; import de.intevation.flys.exports.ChartExportHelper; @@ -158,6 +159,28 @@ /** + * This method is used to determine, if the chart's legend is visible or + * not. <b>Note: this method always returns true.</b> + * + * @return true, if the legend should be visible, otherwise false. + */ + protected boolean isLegendVisible() { + return true; + } + + + /** + * This method is used to determine the font size of the chart's legend. + * <b>Note: this method always returns 12.</b> + * + * @return 12. + */ + protected int getLegendFontSize() { + return 12; + } + + + /** * This method is used to determine if the resulting chart should display * grid lines or not. <b>Note: this method always returns true!</b> * @@ -856,14 +879,40 @@ public Settings getSettings() { ChartSettings settings = new ChartSettings(); + Section chartSection = buildChartSection(); + Section legendSection = buildLegendSection(); + + settings.setChartSection(chartSection); + settings.setLegendSection(legendSection); + + return settings; + } + + + /** + * Creates a new <i>ChartSection</i>. + * + * @return a new <i>ChartSection</i>. + */ + protected Section buildChartSection() { ChartSection chartSection = new ChartSection(); chartSection.setTitle(getChartTitle()); chartSection.setSubtitle(getChartSubtitle()); chartSection.setDisplayGird(isGridVisible()); + return chartSection; + } - settings.setChartSection(chartSection); - return settings; + /** + * Creates a new <i>LegendSection</i>. + * + * @return a new <i>LegendSection</i>. + */ + protected Section buildLegendSection() { + LegendSection legendSection = new LegendSection(); + legendSection.setVisibility(isLegendVisible()); + legendSection.setFontSize(getLegendFontSize()); + return legendSection; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :