changeset 419:4de7d9eac10f

Display gridlines in charts. flys-artifacts/trunk@1889 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 10 May 2011 17:12:15 +0000
parents e0fec407a280
children a0afdda4d4b9
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 2 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 10 16:10:01 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 10 17:12:15 2011 +0000
@@ -1,3 +1,8 @@
+2011-05-10  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  Adjusted the plot of xy charts - the gridlines are displayed now.
+
 2011-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	  ISSUE-53
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue May 10 16:10:01 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue May 10 17:12:15 2011 +0000
@@ -1,6 +1,8 @@
 package de.intevation.flys.exports;
 
+import java.awt.BasicStroke;
 import java.awt.Color;
+import java.awt.Stroke;
 
 import java.io.IOException;
 
@@ -26,6 +28,10 @@
     private static Logger logger = Logger.getLogger(ChartGenerator.class);
 
 
+    public static final Color DEFAULT_GRID_COLOR      = Color.GRAY;
+    public static final float DEFAULT_GRID_LINE_WIDTH = 0.3f;
+
+
     /**
      * Returns the title of a chart.
      *
@@ -74,9 +80,12 @@
         chart.setBackgroundPaint(Color.WHITE);
         chart.getPlot().setBackgroundPaint(Color.WHITE);
 
+        XYPlot plot = (XYPlot) chart.getPlot();
+
         addDatasets(chart);
         addSubtitles(chart);
-        adjustAxes((XYPlot) chart.getPlot());
+        adjustPlot(plot);
+        adjustAxes(plot);
 
         ChartExportHelper.exportImage(
             out,
@@ -98,6 +107,25 @@
     }
 
 
+    protected void adjustPlot(XYPlot plot) {
+        Stroke gridStroke = new BasicStroke(
+            DEFAULT_GRID_LINE_WIDTH,
+            BasicStroke.CAP_BUTT,
+            BasicStroke.JOIN_MITER,
+            3.0f,
+            new float[] { 3.0f },
+            0.0f);
+
+        plot.setDomainGridlineStroke(gridStroke);
+        plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR);
+        plot.setDomainGridlinesVisible(true);
+
+        plot.setRangeGridlineStroke(gridStroke);
+        plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR);
+        plot.setRangeGridlinesVisible(true);
+    }
+
+
     protected void addSubtitles(JFreeChart chart) {
         // override this method in subclasses that need subtitles
     }

http://dive4elements.wald.intevation.org