# HG changeset patch # User Ingo Weinzierl # Date 1305047535 0 # Node ID 4de7d9eac10f415dd6e0a724a4899562afe3bfd0 # Parent e0fec407a28057798f0b6a93063643c1cc91318d Display gridlines in charts. flys-artifacts/trunk@1889 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e0fec407a280 -r 4de7d9eac10f flys-artifacts/ChangeLog --- 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 + + * 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 ISSUE-53 diff -r e0fec407a280 -r 4de7d9eac10f flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- 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 }