# HG changeset patch # User Ingo Weinzierl # Date 1329464727 0 # Node ID c7b0dfa6a52c5fca3aa4e11fb1d0a5f6d0597208 # Parent c7dbe696286c98a3f471ed25ecb967abdbd9c8cc Some refactoring in chart creation; timeseries charts are now able to apply plot specific settings as well. flys-artifacts/trunk@4068 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c7dbe696286c -r c7b0dfa6a52c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Feb 16 12:36:25 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 17 07:45:27 2012 +0000 @@ -1,3 +1,16 @@ +2012-02-17 Ingo Weinzierl + + Part I/III flys/issue497 (Diagrammeigenschaften in Zeitseriendiagrammen) + + * src/main/java/de/intevation/flys/exports/ChartGenerator.java, + src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Moved + adjustPlot() from XYChartGenerator to ChartGenerator which enables the + TimeseriesChartGenerator to call this method as well. + + * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java: + Call adjustPlot() in generateChart() to apply the settings specific to + gridlines in the timeseries plot. + 2012-02-16 Raimund Renkert Refactored the wq data fields. diff -r c7dbe696286c -r c7b0dfa6a52c flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Thu Feb 16 12:36:25 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Fri Feb 17 07:45:27 2012 +0000 @@ -1,8 +1,10 @@ package de.intevation.flys.exports; +import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; +import java.awt.Stroke; import java.awt.TexturePaint; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -33,6 +35,7 @@ import org.jfree.data.Range; import org.jfree.data.general.Series; import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleInsets; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; @@ -908,6 +911,36 @@ /** + * Adjust some Stroke/Grid parameters for plot. The chart + * Settings are applied in this method. + * + * @param plot The XYPlot which is adapted. + */ + 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); + + ChartSettings cs = getChartSettings(); + boolean isGridVisible = cs != null ? isGridVisible(cs) : true; + + plot.setDomainGridlineStroke(gridStroke); + plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR); + plot.setDomainGridlinesVisible(isGridVisible); + + plot.setRangeGridlineStroke(gridStroke); + plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR); + plot.setRangeGridlinesVisible(isGridVisible); + + plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d)); + } + + + /** * This helper mehtod is used to extract the current locale from instance * vairable context. * diff -r c7dbe696286c -r c7b0dfa6a52c flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java Thu Feb 16 12:36:25 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java Fri Feb 17 07:45:27 2012 +0000 @@ -168,6 +168,7 @@ plot.setBackgroundPaint(Color.WHITE); addSubtitles(chart); + adjustPlot(plot); addDatasets(plot); adaptZoom(plot); diff -r c7dbe696286c -r c7b0dfa6a52c flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Thu Feb 16 12:36:25 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Feb 17 07:45:27 2012 +0000 @@ -33,7 +33,6 @@ import org.jfree.data.xy.XYSeriesCollection; import org.jfree.data.xy.XYDataset; -import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import de.intevation.artifactdatabase.state.ArtifactAndFacet; @@ -886,33 +885,6 @@ /** - * Set some Stroke/Grid defaults. - */ - 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); - - ChartSettings cs = getChartSettings(); - boolean isGridVisible = cs != null ? isGridVisible(cs) : true; - - plot.setDomainGridlineStroke(gridStroke); - plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR); - plot.setDomainGridlinesVisible(isGridVisible); - - plot.setRangeGridlineStroke(gridStroke); - plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR); - plot.setRangeGridlinesVisible(isGridVisible); - - plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d)); - } - - - /** * This method walks over all axes (domain and range) of plot and * calls localizeDomainAxis() for domain axes or localizeRangeAxis() for * range axes.