comparison flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java @ 3130:0dd569e9b9f1

Added new methods to add domain and value axis markers to time series plots. flys-artifacts/trunk@4731 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 20 Jun 2012 15:33:32 +0000
parents 4a76da133144
children 5a0aef74c316
comparison
equal deleted inserted replaced
3129:04952869e4fa 3130:0dd569e9b9f1
23 import org.jfree.chart.JFreeChart; 23 import org.jfree.chart.JFreeChart;
24 import org.jfree.chart.axis.ValueAxis; 24 import org.jfree.chart.axis.ValueAxis;
25 import org.jfree.chart.plot.XYPlot; 25 import org.jfree.chart.plot.XYPlot;
26 import org.jfree.chart.annotations.XYTextAnnotation; 26 import org.jfree.chart.annotations.XYTextAnnotation;
27 import org.jfree.chart.LegendItemCollection; 27 import org.jfree.chart.LegendItemCollection;
28 import org.jfree.chart.plot.Marker;
29 import org.jfree.chart.plot.ValueMarker;
30 import org.jfree.ui.Layer;
28 31
29 import org.jfree.data.Range; 32 import org.jfree.data.Range;
30 import org.jfree.data.time.TimeSeriesCollection; 33 import org.jfree.data.time.TimeSeriesCollection;
31 import org.jfree.data.general.Series; 34 import org.jfree.data.general.Series;
32 import org.jfree.data.xy.XYDataset; 35 import org.jfree.data.xy.XYDataset;
33 import org.jfree.data.time.Day; 36 import org.jfree.data.time.Day;
34 import org.jfree.data.time.TimeSeries; 37 import org.jfree.data.time.TimeSeries;
38 import org.jfree.data.time.RegularTimePeriod;
35 39
36 import de.intevation.artifactdatabase.state.ArtifactAndFacet; 40 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
37 import de.intevation.artifactdatabase.state.Facet; 41 import de.intevation.artifactdatabase.state.Facet;
38 42
39 import de.intevation.flys.jfree.Bounds; 43 import de.intevation.flys.jfree.Bounds;
62 66
63 protected Range range; 67 protected Range range;
64 68
65 protected int plotAxisIndex; 69 protected int plotAxisIndex;
66 70
67
68 public TimeseriesAxisDataset(int axisSymbol) { 71 public TimeseriesAxisDataset(int axisSymbol) {
69 this.axisSymbol = axisSymbol; 72 this.axisSymbol = axisSymbol;
70 this.datasets = new ArrayList<TimeSeriesCollection>(); 73 this.datasets = new ArrayList<TimeSeriesCollection>();
71 } 74 }
72 75
143 146
144 147
145 /** List of annotations to insert in plot. */ 148 /** List of annotations to insert in plot. */
146 protected List<FLYSAnnotation> annotations; 149 protected List<FLYSAnnotation> annotations;
147 150
151 protected List<Marker> domainMarker;
152
153 protected List<Marker> valueMarker;
154
155 protected boolean domainZeroLineVisible;
148 156
149 private static final Logger logger = 157 private static final Logger logger =
150 Logger.getLogger(TimeseriesChartGenerator.class); 158 Logger.getLogger(TimeseriesChartGenerator.class);
151 159
152 160
165 public TimeseriesChartGenerator() { 173 public TimeseriesChartGenerator() {
166 super(); 174 super();
167 175
168 xBounds = new HashMap<Integer, Bounds>(); 176 xBounds = new HashMap<Integer, Bounds>();
169 yBounds = new HashMap<Integer, Bounds>(); 177 yBounds = new HashMap<Integer, Bounds>();
178 domainMarker = new ArrayList<Marker>();
179 valueMarker = new ArrayList<Marker>();
170 } 180 }
171 181
172 182
173 183
174 @Override 184 @Override
191 201
192 addSubtitles(chart); 202 addSubtitles(chart);
193 adjustPlot(plot); 203 adjustPlot(plot);
194 addDatasets(plot); 204 addDatasets(plot);
195 adjustAxes(plot); 205 adjustAxes(plot);
196 206 addDomainAxisMarker(plot);
207 addValueAxisMarker(plot);
197 adaptZoom(plot); 208 adaptZoom(plot);
198 209
199 addAnnotationsToRenderer(plot); 210 addAnnotationsToRenderer(plot);
200
201 return chart; 211 return chart;
202 } 212 }
203 213
204 214
205 @Override 215 @Override
646 plot.getRenderer().addAnnotation(ta, org.jfree.ui.Layer.FOREGROUND); 656 plot.getRenderer().addAnnotation(ta, org.jfree.ui.Layer.FOREGROUND);
647 } 657 }
648 } 658 }
649 } 659 }
650 660
661 public void addDomainAxisMarker(XYPlot plot) {
662 logger.debug("domainmarkers: " + domainMarker.size());
663 for (Marker marker: domainMarker) {
664 logger.debug("adding domain marker");
665 plot.addDomainMarker(marker, Layer.BACKGROUND);
666 }
667 domainMarker.clear();
668 }
669
670 public void addValueAxisMarker(XYPlot plot) {
671 for (Marker marker: valueMarker) {
672 logger.debug("adding value marker..");
673 plot.addRangeMarker(marker, Layer.BACKGROUND);
674 }
675 valueMarker.clear();
676 }
651 677
652 /** Two Ranges that span a rectangular area. */ 678 /** Two Ranges that span a rectangular area. */
653 public static class Area { 679 public static class Area {
654 protected Range xRange; 680 protected Range xRange;
655 protected Range yRange; 681 protected Range yRange;

http://dive4elements.wald.intevation.org