diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2047:0318fa6f0844

Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress. flys-artifacts/trunk@3535 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 23 Dec 2011 08:57:25 +0000
parents 7bc9293de4e6
children 3157a78e6494
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Dec 23 08:51:28 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Dec 23 08:57:25 2011 +0000
@@ -205,23 +205,39 @@
 
     /**
      * This method is used to determine, if the chart's legend is visible or
-     * not. <b>Note: this method always returns true.</b>
+     * not. If a <i>settings</i> instance is set, this instance determines the
+     * visibility otherwise, this method returns true as default if no
+     * <i>settings</i> is set.
      *
      * @return true, if the legend should be visible, otherwise false.
      */
     protected boolean isLegendVisible() {
+        ChartSettings chartSettings = getChartSettings();
+        if (chartSettings != null) {
+            return isLegendVisible(chartSettings);
+        }
+
         return true;
     }
 
 
     /**
-     * This method is used to determine the font size of the chart's legend.
-     * <b>Note: this method always returns 12.</b>
+     * This method is used to determine the font size of the chart's legend. If
+     * a <i>settings</i> instance is set, this instance determines the font
+     * size, otherwise this method returns 12 as default if no <i>settings</i>
+     * is set or if it doesn't provide a legend font size.
      *
-     * @return 12.
+     * @return a legend font size.
      */
     protected int getLegendFontSize() {
-        return 12;
+        Integer fontSize = null;
+
+        ChartSettings chartSettings = getChartSettings();
+        if (chartSettings != null) {
+            fontSize = getLegendFontSize(chartSettings);
+        }
+
+        return fontSize != null ? fontSize : 12;
     }
 
 
@@ -324,7 +340,7 @@
             getYAxisLabel(),
             null,
             PlotOrientation.VERTICAL,
-            true,
+            isLegendVisible(),
             false,
             false);
 
@@ -705,6 +721,8 @@
             return;
         }
 
+        int fontSize = getLegendFontSize();
+
         LegendItemCollection lic = new LegendItemCollection();
         LegendItemCollection old = plot.getFixedLegendItems();
 
@@ -717,6 +735,7 @@
 
             Color color   = themeAccess.parseLineColorField();
             int lineWidth = themeAccess.parseLineWidth();
+
             lic.add(new LegendItem(fa.getLabel(), color));
 
             for (XYTextAnnotation ta: fa.getAnnotations()) {
@@ -776,13 +795,16 @@
             new float[] { 3.0f },
             0.0f);
 
+        ChartSettings      cs = getChartSettings();
+        boolean isGridVisible = cs != null ? isGridVisible(cs) : true;
+
         plot.setDomainGridlineStroke(gridStroke);
         plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR);
-        plot.setDomainGridlinesVisible(true);
+        plot.setDomainGridlinesVisible(isGridVisible);
 
         plot.setRangeGridlineStroke(gridStroke);
         plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR);
-        plot.setRangeGridlinesVisible(true);
+        plot.setRangeGridlinesVisible(isGridVisible);
 
         plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d));
     }
@@ -1018,10 +1040,14 @@
      * @return an instance of <i>ChartSettings</i>.
      */
     public Settings getSettings() {
+        if (this.settings != null) {
+            return this.settings;
+        }
+
         ChartSettings settings = new ChartSettings();
 
-        Section chartSection  = buildChartSection();
-        Section legendSection = buildLegendSection();
+        ChartSection  chartSection  = buildChartSection();
+        LegendSection legendSection = buildLegendSection();
 
         settings.setChartSection(chartSection);
         settings.setLegendSection(legendSection);
@@ -1040,7 +1066,7 @@
      *
      * @return a new <i>ChartSection</i>.
      */
-    protected Section buildChartSection() {
+    protected ChartSection buildChartSection() {
         ChartSection chartSection = new ChartSection();
         chartSection.setTitle(getChartTitle());
         chartSection.setSubtitle(getChartSubtitle());
@@ -1054,7 +1080,7 @@
      *
      * @return a new <i>LegendSection</i>.
      */
-    protected Section buildLegendSection() {
+    protected LegendSection buildLegendSection() {
         LegendSection legendSection = new LegendSection();
         legendSection.setVisibility(isLegendVisible());
         legendSection.setFontSize(getLegendFontSize());

http://dive4elements.wald.intevation.org