annotate flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 1944:21a4d2c677a1

Changed doOut signature, side effect from blackboard feature (to come). flys-artifacts/trunk@3334 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Nov 2011 10:10:42 +0000
parents 06d8d371d244
children 65f9d707caff
rev   line source
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.exports;
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
3 import java.awt.BasicStroke;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.awt.Color;
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
5 import java.awt.Stroke;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.io.IOException;
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
1645
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
9 import java.text.NumberFormat;
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
10
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
11 import java.util.ArrayList;
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
12 import java.util.HashMap;
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
13 import java.util.TreeMap;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
14 import java.util.List;
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
15 import java.util.Map;
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
16 import java.util.SortedMap;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
17
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
18 import org.w3c.dom.Document;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
19
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.Logger;
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import org.jfree.chart.ChartFactory;
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import org.jfree.chart.JFreeChart;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
24 import org.jfree.chart.LegendItem;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
25 import org.jfree.chart.LegendItemCollection;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
26 import org.jfree.chart.annotations.XYTextAnnotation;
1934
e4a516ca2e86 When having axis in diagrams, always have one on the left.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1932
diff changeset
27 import org.jfree.chart.axis.AxisLocation;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import org.jfree.chart.axis.NumberAxis;
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
29 import org.jfree.chart.axis.ValueAxis;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.plot.PlotOrientation;
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import org.jfree.chart.plot.XYPlot;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
32 import org.jfree.chart.renderer.xy.XYItemRenderer;
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
33 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
34 import org.jfree.data.Range;
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
35 import org.jfree.data.xy.XYSeries;
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
36 import org.jfree.data.xy.XYSeriesCollection;
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
37 import org.jfree.data.xy.XYDataset;
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
38
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
39 import org.jfree.ui.RectangleInsets;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
41 import de.intevation.artifactdatabase.state.Facet;
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
42
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 import de.intevation.flys.exports.ChartExportHelper;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
44 import de.intevation.flys.jfree.FLYSAnnotation;
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
45 import de.intevation.flys.jfree.StickyAxisAnnotation;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
1754
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1738
diff changeset
47 import de.intevation.flys.utils.ThemeAccess;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 /**
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 * An abstract base class for creating XY charts.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 *
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
52 * With respect to datasets, ranges and axis, there are following requirements:
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
53 * <ul>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
54 * <li> First in, first drawn: "Early" datasets should be of lower Z-Oder
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
55 * than later ones (only works per-axis). </li>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
56 * <li> Visible axis should initially show the range of all datasets that
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
57 * show data for this axis (even invisible ones). Motivation: Once
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
58 * a dataset (theme) has been activated, it should be on screen. </li>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
59 * <li> There should always be a Y-Axis on the "left". </li>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
60 * </ul>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
61 *
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 public abstract class XYChartGenerator extends ChartGenerator {
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
66 private class AxisDataset {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
67 /** Symbolic integer, but also coding the priority (0 goes first). */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
68 protected int axisSymbol;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
69 /** List of assigned datasets (in order). */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
70 protected List<XYDataset> datasets;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
71 /** Range to use to include all given datasets. */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
72 protected Range range;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
73
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
74 /** Create AxisDataset. */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
75 public AxisDataset(int symb) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
76 this.axisSymbol = symb;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
77 datasets = new ArrayList<XYDataset>();
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
78 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
79
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
80 /** Merge (or create given range with range so far (if any). */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
81 private void mergeRanges(Range subRange) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
82 if (range == null) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
83 range = subRange;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
84 return;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
85 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
86 range = Range.combine(range, subRange);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
87 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
88
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
89 /** Add a dataset, include its range. */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
90 public void addDataset(XYSeries dataset) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
91 this.datasets.add(new XYSeriesCollection(dataset));
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
92 includeRange(dataset);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
93 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
94
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
95 /** Adjust range to include given dataset. */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
96 public void includeRange(XYSeries dataset) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
97 mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY()));
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
98 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
99
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
100 /** True if no datasets given. */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
101 public boolean isEmpty() {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
102 return this.datasets.isEmpty();
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
103 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
104
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
105 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
106
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
107
1048
fd5c70973e0b Picky white-space cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 924
diff changeset
108 /** The logger that is used in this generator. */
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
109 private static Logger logger = Logger.getLogger(XYChartGenerator.class);
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
111 /** Map of datasets ("index"). */
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
112 protected SortedMap<Integer, AxisDataset> datasets;
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
113
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
114 /** List of annotations to insert in plot. */
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
115 protected List<FLYSAnnotation> annotations;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
116
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
117 /** The max X range to include all X values of all series for each axis. */
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
118 protected Map<Integer, Range> xRanges;
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
119
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
120 /** The max Y range to include all Y values of all series for each axis. */
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
121 protected Map<Integer, Range> yRanges;
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
122
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
123 public static final Color DEFAULT_GRID_COLOR = Color.GRAY;
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
124 public static final float DEFAULT_GRID_LINE_WIDTH = 0.3f;
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
125
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
126
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
127 public XYChartGenerator() {
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
128 xRanges = new HashMap<Integer, Range>();
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
129 yRanges = new HashMap<Integer, Range>();
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
130 datasets = new TreeMap<Integer, AxisDataset>();
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
131 }
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
132
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
133
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 /**
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 * Returns the title of a chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 *
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 * @return the title of a chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 protected abstract String getChartTitle();
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
141
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 /**
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 * Returns the X-Axis label of a chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 *
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 * @return the X-Axis label of a chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 protected abstract String getXAxisLabel();
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
149
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 /**
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 * Returns the Y-Axis label of a chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 *
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 * @return the Y-Axis label of a chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 protected abstract String getYAxisLabel();
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
157 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
158 * Generate chart.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
159 */
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 public void generate()
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 throws IOException
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 {
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 logger.debug("XYChartGenerator.generate");
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
165 JFreeChart chart = generateChart();
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
166
1735
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
167 String format = getFormat();
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
168 int[] size = getSize();
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
169
1930
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
170 context.putContextValue("chart.width", size[0]);
1735
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
171 context.putContextValue("chart.height", size[1]);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
172
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
173 if (format.equals(ChartExportHelper.FORMAT_PNG)) {
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
174 context.putContextValue("chart.image.format", "png");
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
175
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
176 ChartExportHelper.exportImage(
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
177 out,
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
178 chart,
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
179 context);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
180 }
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
181 else if (format.equals(ChartExportHelper.FORMAT_PDF)) {
1930
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
182 context.putContextValue("chart.marginLeft", 5f);
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
183 context.putContextValue("chart.marginRight", 5f);
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
184 context.putContextValue("chart.marginTop", 5f);
1735
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
185 context.putContextValue("chart.marginBottom", 5f);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
186 context.putContextValue(
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
187 "chart.page.format",
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
188 ChartExportHelper.DEFAULT_PAGE_SIZE);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
189
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
190 ChartExportHelper.exportPDF(
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
191 out,
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
192 chart,
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
193 context);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
194 }
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
195 else if (format.equals(ChartExportHelper.FORMAT_SVG)) {
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
196 context.putContextValue(
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
197 "chart.encoding",
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
198 ChartExportHelper.DEFAULT_ENCODING);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
199
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
200 ChartExportHelper.exportSVG(
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
201 out,
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
202 chart,
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
203 context);
5966a20fc72c Enabled support for PDF and SVG chart exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1711
diff changeset
204 }
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
205 }
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
206
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
207
1930
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
208 /**
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
209 * Generate the chart anew (including localized axis and all).
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
210 */
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
211 public JFreeChart generateChart() {
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
212 logger.debug("XYChartGenerator.generateChart");
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
213
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 JFreeChart chart = ChartFactory.createXYLineChart(
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 getChartTitle(),
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 getXAxisLabel(),
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 getYAxisLabel(),
375
60f63539d004 Ws and Qs of a longitudinal section chart are mapped to an own range axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 369
diff changeset
218 null,
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 PlotOrientation.VERTICAL,
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 true,
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 false,
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 false);
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
224 XYPlot plot = (XYPlot) chart.getPlot();
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 chart.setBackgroundPaint(Color.WHITE);
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
226 plot.setBackgroundPaint(Color.WHITE);
414
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
227 addSubtitles(chart);
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
228 adjustPlot(plot);
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
229
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
230 //debugAxis(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
231
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
232 addDatasets(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
233
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
234 //debugDatasets(plot);
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
235
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
236 recoverEmptyPlot(plot);
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
237 preparePointRanges(plot);
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
238
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
239 addAnnotationsToRenderer(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
240
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
241 //debugAxis(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
242
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
243 localizeAxes(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
244 adjustAxes(plot);
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
245 autoZoom(plot);
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
246
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
247 return chart;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
248 }
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
249
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
250
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
251 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
252 * Put debug output about datasets.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
253 */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
254 public void debugDatasets(XYPlot plot) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
255 logger.debug("Number of datasets: " + plot.getDatasetCount());
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
256 for (int i = 0; i < plot.getDatasetCount(); i++) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
257 if (plot.getDataset(i) == null) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
258 logger.debug("Dataset #" + i + " is null");
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
259 continue;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
260 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
261 logger.debug("Dataset #" + i + ":" + plot.getDataset(i));
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
262 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
263 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
264
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
265
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
266 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
267 * Put debug output about axes.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
268 */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
269 public void debugAxis(XYPlot plot) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
270 logger.debug("...............");
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
271 for (int i = 0; i < plot.getRangeAxisCount(); i++) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
272 if (plot.getRangeAxis(i) == null)
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
273 logger.debug("Axis #" + i + " == null");
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
274 else {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
275 logger.debug("Axis " + i + " != null [" +
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
276 plot.getRangeAxis(i).getRange().getLowerBound() +
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
277 " " + plot.getRangeAxis(i).getRange().getUpperBound() +
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
278 "]");
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
279 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
280
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
281 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
282 logger.debug("...............");
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 }
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
286 /**
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
287 * Add datasets to plot.
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
288 * @param plot plot to add datasets to.
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
289 */
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
290 protected void addDatasets(XYPlot plot) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
291 // AxisDatasets are sorted, but some might be empty.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
292 // Thus, generate numbering on the fly.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
293 int axisIndex = 0;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
294 int datasetIndex = 0;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
295 for (Map.Entry<Integer, AxisDataset> entry: datasets.entrySet()) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
296 if (!entry.getValue().isEmpty()) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
297 // Add axis and range information.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
298 AxisDataset axisDataset = entry.getValue();
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
299 NumberAxis axis = createYAxis(entry.getKey());
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
300
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
301 plot.setRangeAxis(axisIndex, axis);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
302 if (axis.getAutoRangeIncludesZero()) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
303 axisDataset.range = Range.expandToInclude(axisDataset.range, 0d);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
304 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
305 yRanges.put(axisIndex, expandPointRange(axisDataset.range));
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
306
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
307 // Add contained datasets, mapping to axis.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
308 for (XYDataset dataset: axisDataset.datasets) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
309 plot.setDataset(datasetIndex, dataset);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
310 plot.mapDatasetToRangeAxis(datasetIndex, axisIndex);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
311 applyThemes(plot, (XYSeriesCollection) dataset, datasetIndex);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
312 datasetIndex++;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
313 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
314 axisIndex++;
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
315 }
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
316 }
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
317 }
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
318
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
319
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
320 /**
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
321 * Add given series if visible, if not visible adjust ranges (such that
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
322 * all points in data would be plotted once visible).
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
323 * @param series the dataseries to include in plot.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
324 * @param index index of the series and of its axis.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
325 * @param visible whether or not the data should be plotted.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
326 */
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
327 public void addAxisSeries(XYSeries series, int index, boolean visible) {
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
328 if (series == null) {
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
329 return;
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
330 }
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
331
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
332 AxisDataset axisDataset = datasets.get(index);
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
333
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
334 if (axisDataset == null) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
335 axisDataset = new AxisDataset(index);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
336 datasets.put(index, axisDataset);
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
337 }
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
338
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
339 if (visible) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
340 axisDataset.addDataset(series);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
341 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
342 else {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
343 // Do this also when not visible to have axis scaled by default such
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
344 // that every data-point could be seen (except for annotations).
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
345 axisDataset.includeRange(series);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
346 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
347
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
348 combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0);
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
349 }
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
350
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
351
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
352 /**
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
353 * Effect: extend range of x axis to include given limits.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
354 * @param range the given ("minimal") range.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
355 * @param index index of axis to be merged.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
356 */
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
357 private void combineXRanges(Range range, int index) {
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
358
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
359 Range old = xRanges.get(index);
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
360
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
361 if (old != null) {
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
362 range = Range.combine(old, range);
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
363 }
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
364
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
365 xRanges.put(index, range);
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
366 }
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
367
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
368
1930
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
369 /**
1711
f708120cb7bc Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1699
diff changeset
370 * Adds annotations to list (if visible is true).
f708120cb7bc Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1699
diff changeset
371 */
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
372 public void addAnnotations(FLYSAnnotation annotation, boolean visible) {
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
373 if (!visible) {
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
374 return;
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
375 }
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
376
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
377 if (annotations == null) {
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
378 annotations = new ArrayList<FLYSAnnotation>();
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
379 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
380
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
381 annotations.add(annotation);
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
382 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
383
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
384
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
385 /**
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
386 * Create Y (range) axis for given index.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
387 * Shall be overriden by subclasses.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
388 */
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
389 protected NumberAxis createYAxis(int index) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
390 NumberAxis axis = new NumberAxis(getYAxisLabel());
1943
06d8d371d244 Fix compilation, default 0-excluding behavior of axes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1940
diff changeset
391 axis.setAutoRangeIncludesZero(false);
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
392 return axis;
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
393 }
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
394
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
395
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
396 /**
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
397 * If no data is visible, draw at least empty axis.
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
398 */
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
399 private void recoverEmptyPlot(XYPlot plot) {
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
400 if (plot.getRangeAxis() == null) {
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
401 logger.debug("debug: No range axis");
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
402 plot.setRangeAxis(createYAxis(0));
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
403 }
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
404 }
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
405
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
406
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
407 /**
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
408 * Expands a given range if it collapses into one point.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
409 */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
410 private Range expandPointRange(Range range) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
411 if (range.getLowerBound() == range.getUpperBound()) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
412 return expandRange(range, 5);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
413 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
414 return range;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
415 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
416
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
417
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
418 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
419 * Expands X axes if only a point is shown.
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
420 */
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
421 private void preparePointRanges(XYPlot plot) {
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
422 for (int i = 0, num = plot.getDomainAxisCount(); i < num; i++) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
423 logger.debug("Check whether to expand a x axis.");
1698
6e935087f6a1 XYChartGenerator: s/new Integer(small)/Integer.valueOf(small)/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1688
diff changeset
424 Integer key = Integer.valueOf(i);
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
425
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
426 Range r = xRanges.get(key);
1687
19c4cf5163e8 Take care on empty ranges (null) while preparing single point ranges.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1686
diff changeset
427 if (r != null && r.getLowerBound() == r.getUpperBound()) {
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
428 xRanges.put(key, expandRange(r, 5));
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
429 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
430 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
431 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
432
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
433
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
434 /**
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
435 * Expand range by percent.
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
436 */
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
437 public static Range expandRange(Range range, double percent) {
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
438 if (range == null) {
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
439 return null;
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
440 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
441
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
442 double value = range.getLowerBound();
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
443 double expand = value / 100 * percent;
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
444
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
445 return expand != 0
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
446 ? new Range(value-expand, value+expand)
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
447 : new Range(-0.01 * percent, 0.01 * percent);
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
448 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
449
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
450
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
451 /**
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
452 * This method zooms the plot to the specified ranges in the attribute
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
453 * document or to the ranges specified by the min/max values in the
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
454 * datasets. <b>Note:</b> We determine the range manually if no zoom ranges
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
455 * are given, because JFreeCharts auto-zoom adds a margin to the left and
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
456 * right of the data area.
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
457 *
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
458 * @param plot The XYPlot.
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
459 */
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
460 protected void autoZoom(XYPlot plot) {
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
461 logger.debug("Zoom to specified ranges.");
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
462
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
463 Range xrange = getDomainAxisRange();
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
464 Range yrange = getValueAxisRange();
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
465
1699
608859aa5a7e Bugfix: #383 Add further y-axes before adjusting the ranges for each y-axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1698
diff changeset
466 zoomX(plot, plot.getDomainAxis(), xRanges.get(0), xrange);
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
467
1699
608859aa5a7e Bugfix: #383 Add further y-axes before adjusting the ranges for each y-axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1698
diff changeset
468 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
469 ValueAxis yaxis = plot.getRangeAxis(i);
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
470
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
471 if (yaxis == null) {
1699
608859aa5a7e Bugfix: #383 Add further y-axes before adjusting the ranges for each y-axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1698
diff changeset
472 logger.debug("Zoom problem: no Y Axis for index: " + i);
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
473 continue;
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
474 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
475
1699
608859aa5a7e Bugfix: #383 Add further y-axes before adjusting the ranges for each y-axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1698
diff changeset
476 logger.debug("Prepare zoom settings for y axis at index: " + i);
608859aa5a7e Bugfix: #383 Add further y-axes before adjusting the ranges for each y-axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1698
diff changeset
477 zoomY(plot, yaxis, yRanges.get(Integer.valueOf(i)), yrange);
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
478 }
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
479 }
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
480
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
481
718
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
482 protected boolean zoomX(XYPlot plot, ValueAxis axis, Range range, Range x) {
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
483 return zoom(plot, axis, range, x);
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
484 }
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
485
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
486
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
487 protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) {
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
488 return zoom(plot, axis, range, x);
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
489 }
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
490
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
491
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
492 /**
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
493 * Zooms the x axis to the range specified in the attribute document.
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
494 *
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
495 * @param plot The XYPlot.
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
496 * @param axis The axis the shoud be modified.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
497 * @param range The whole range specified by a dataset.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
498 * @param x A user defined range (null permitted).
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
499 *
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
500 * @return true, if a zoom range was specified, otherwise false.
653
67c7020f4ed3 Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 652
diff changeset
501 */
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
502 protected boolean zoom(XYPlot plot, ValueAxis axis, Range range, Range x) {
1736
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
503
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
504 if (range == null) {
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
505 return false;
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
506 }
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
507
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
508 if (x != null) {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
509 double min = range.getLowerBound();
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
510 double max = range.getUpperBound();
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
511 double diff = max > min ? max - min : min - max;
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
512
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
513 Range computed = new Range(
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
514 min + x.getLowerBound() * diff,
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
515 min + x.getUpperBound() * diff);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
516
717
be4709640aac #90 Added a margin between chart data and chart axes to avoid displaying curves on the chart border.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 673
diff changeset
517 axis.setRangeWithMargins(computed);
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
518
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 667
diff changeset
519 logger.debug("Zoom axis to: " + computed);
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
520
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
521 return true;
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
522 }
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
523
717
be4709640aac #90 Added a margin between chart data and chart axes to avoid displaying curves on the chart border.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 673
diff changeset
524 axis.setRangeWithMargins(range);
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
525 return false;
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
526 }
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
527
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
528
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
529 /**
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
530 * This method extracts the minimum and maximum values for x and y axes
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
531 * which are stored in <i>xRanges</i> and <i>yRanges</i>.
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
532 *
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
533 * @param index The index of the y-Axis.
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
534 *
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
535 * @return a Range[] as follows: [x-Range, y-Range].
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
536 */
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1943
diff changeset
537 public Range[] getRangesForAxis(int index) {
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1943
diff changeset
538 logger.debug("getRangesForAxis " + index);
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
539 return new Range[] {
1698
6e935087f6a1 XYChartGenerator: s/new Integer(small)/Integer.valueOf(small)/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1688
diff changeset
540 xRanges.get(Integer.valueOf(0)),
6e935087f6a1 XYChartGenerator: s/new Integer(small)/Integer.valueOf(small)/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1688
diff changeset
541 yRanges.get(Integer.valueOf(index))
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1679
diff changeset
542 };
652
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
543 }
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
544
8fa4c5c9cd1a Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 423
diff changeset
545
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
546 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
547 * Add annotations to Renderer.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
548 */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
549 protected void addAnnotationsToRenderer(XYPlot plot) {
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
550 plot.clearAnnotations();
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
551
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
552 if (annotations == null) {
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
553 logger.debug("No Annotations given.");
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
554 return;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
555 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
556
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
557 LegendItemCollection lic = new LegendItemCollection();
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
558 LegendItemCollection old = plot.getFixedLegendItems();
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
559
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
560 XYItemRenderer renderer = plot.getRenderer(0);
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
561
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
562 for (FLYSAnnotation fa: annotations) {
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
563 Document theme = fa.getTheme();
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
564
1754
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1738
diff changeset
565 ThemeAccess themeAccess = new ThemeAccess(theme);
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
566
1754
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1738
diff changeset
567 Color color = themeAccess.parseLineColorField();
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1738
diff changeset
568 int lineWidth = themeAccess.parseLineWidth();
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
569 lic.add(new LegendItem(fa.getLabel(), color));
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
570
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
571 for (XYTextAnnotation ta: fa.getAnnotations()) {
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
572 if(ta instanceof StickyAxisAnnotation) {
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
573 StickyAxisAnnotation sta = (StickyAxisAnnotation)ta;
1754
8e6615ad60b8 Added some simple caching for themes. Only used in sticky annotations by now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1738
diff changeset
574 sta.applyTheme(themeAccess);
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
575 renderer.addAnnotation(sta);
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
576 }
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
577 else {
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
578 ta.setPaint(color);
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
579 ta.setOutlineStroke(new BasicStroke((float) lineWidth));
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
580 renderer.addAnnotation(ta);
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
581 }
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
582 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
583
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
584 }
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
585
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
586 // (Re-)Add prior legend entries.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
587 if (old != null) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
588 old.addAll(lic);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
589 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
590 else {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
591 old = lic;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
592 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
593
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
594 plot.setFixedLegendItems(old);
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
595 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
596
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
597
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
598 /**
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
599 * Adjusts the axes of a plot (the first axis does not include zero).
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
600 * To be overridden by children.
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
601 * @param plot The XYPlot of the chart.
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
602 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
603 protected void adjustAxes(XYPlot plot) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
604 /*
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
605 NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
1931
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
606 if (yAxis == null) {
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
607 logger.warn("No Axis to setAutoRangeIncludeZero.");
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
608 }
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
609 else {
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
610 yAxis.setAutoRangeIncludesZero(false);
7c52e9cb2a72 Allow more than two datasets and more flexibility with axes in plots. Based on patch by S. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1930
diff changeset
611 }
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
612 */
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
613 }
414
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
614
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
615
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
616 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
617 * Set some Stroke/Grid defaults.
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
618 */
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
619 protected void adjustPlot(XYPlot plot) {
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
620 Stroke gridStroke = new BasicStroke(
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
621 DEFAULT_GRID_LINE_WIDTH,
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
622 BasicStroke.CAP_BUTT,
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
623 BasicStroke.JOIN_MITER,
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
624 3.0f,
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
625 new float[] { 3.0f },
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
626 0.0f);
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
627
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
628 plot.setDomainGridlineStroke(gridStroke);
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
629 plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR);
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
630 plot.setDomainGridlinesVisible(true);
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
631
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
632 plot.setRangeGridlineStroke(gridStroke);
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
633 plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR);
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
634 plot.setRangeGridlinesVisible(true);
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
635
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
636 plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d));
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
637 }
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
638
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
639
414
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
640 protected void addSubtitles(JFreeChart chart) {
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
641 // override this method in subclasses that need subtitles
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
642 }
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
643
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
644
1645
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
645 /**
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
646 * This method walks over all axes (domain and range) of <i>plot</i> and
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
647 * calls localizeDomainAxis() for domain axes or localizeRangeAxis() for
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
648 * range axes.
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
649 *
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
650 * @param plot The XYPlot.
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
651 */
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
652 private void localizeAxes(XYPlot plot) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
653 for (int i = 0, num = plot.getDomainAxisCount(); i < num; i++) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
654 ValueAxis axis = plot.getDomainAxis(i);
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
655
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
656 if (axis != null) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
657 localizeDomainAxis(axis);
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
658 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
659 else {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
660 logger.warn("Domain axis at " + i + " is null.");
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
661 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
662 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
663
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
664 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
665 ValueAxis axis = plot.getRangeAxis(i);
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
666
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
667 if (axis != null) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
668 localizeRangeAxis(axis);
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
669 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
670 else {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
671 logger.warn("Range axis at " + i + " is null.");
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
672 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
673 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
674 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
675
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
676
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
677 /**
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
678 * Overrides the NumberFormat with the NumberFormat for the current locale
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
679 * that is provided by getLocale().
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
680 *
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
681 * @param domainAxis The domain axis that needs localization.
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
682 */
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
683 protected void localizeDomainAxis(ValueAxis domainAxis) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
684 NumberFormat nf = NumberFormat.getInstance(getLocale());
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
685 ((NumberAxis) domainAxis).setNumberFormatOverride(nf);
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
686 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
687
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
688
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
689 /**
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
690 * Overrides the NumberFormat with the NumberFormat for the current locale
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
691 * that is provided by getLocale().
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
692 *
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
693 * @param domainAxis The domain axis that needs localization.
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
694 */
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
695 protected void localizeRangeAxis(ValueAxis rangeAxis) {
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
696 NumberFormat nf = NumberFormat.getInstance(getLocale());
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
697 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf);
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
698 }
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
699
4a8251eae217 Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1623
diff changeset
700
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
701 /**
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
702 * @param idx "index" of dataset/series (first dataset to be drawn has
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
703 * index 0), correlates with renderer index.
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
704 * @return idx increased by number of items addded.
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
705 */
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
706 protected int applyThemes(XYPlot plot, XYSeriesCollection series, int idx) {
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
707 LegendItemCollection lic = new LegendItemCollection();
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
708 LegendItemCollection anno = plot.getFixedLegendItems();
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
709
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
710 XYLineAndShapeRenderer renderer = getRenderer(plot, idx);
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
711 int retidx = idx;
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
712
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
713 for (int s = 0, num = series.getSeriesCount(); s < num; s++) {
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
714 XYSeries serie = series.getSeries(s);
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
715
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
716 if (serie instanceof StyledXYSeries) {
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
717 ((StyledXYSeries) serie).applyTheme(renderer, s);
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
718 }
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
719
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
720 // special case: if there is just one single item, we need to enable
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
721 // points for this series, otherwise we would not see anything in
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
722 // the chart area.
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
723 if (serie.getItemCount() == 1) {
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
724 renderer.setSeriesShapesVisible(s, true);
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
725 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
726
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
727 LegendItem li = renderer.getLegendItem(idx, s);
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
728 if (li != null) {
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
729 lic.add(li);
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
730 }
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
731 else {
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
732 logger.warn("Could not get LegentItem for renderer: "
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
733 + idx + ", series-idx " + s);
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
734 }
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
735 retidx++;
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
736 }
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
737
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
738 if (anno != null) {
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
739 lic.addAll(anno);
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
740 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
741
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
742 plot.setFixedLegendItems(lic);
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
743
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
744 plot.setRenderer(idx, renderer);
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
745
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
746 return retidx;
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
747 }
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
748
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
749
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
750 /**
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
751 * Get renderer, from plot or cloned default renderer otherwise.
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
752 */
924
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
753 protected XYLineAndShapeRenderer getRenderer(XYPlot plot, int idx) {
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
754 XYLineAndShapeRenderer r =
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
755 (XYLineAndShapeRenderer) plot.getRenderer(idx);
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
756
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
757 if (r != null) {
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
758 return r;
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
759 }
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
760
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
761 if (idx == 0) {
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
762 logger.warn("No default renderer set!");
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
763 return new XYLineAndShapeRenderer();
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
764 }
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
765
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
766 r = (XYLineAndShapeRenderer) plot.getRenderer(0);
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
767
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
768 try {
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
769 return (XYLineAndShapeRenderer) r.clone();
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
770 }
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
771 catch (CloneNotSupportedException cnse) {
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
772 logger.warn(cnse, cnse);
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
773 }
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
774
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
775 logger.warn("No applicalable renderer found!");
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
776
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
777 return new XYLineAndShapeRenderer();
f7761914f745 An initial implementation to render chart series based on the XML configuration in themes.xml.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 923
diff changeset
778 }
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
779
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
780
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
781 /**
1861
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
782 * Register annotations like MainValues for later plotting
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
783 *
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
784 * @param o list of annotations (data of facet).
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
785 * @param facet The facet. This facet does NOT support any data objects. Use
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
786 * FLYSArtifact.getNativeFacet() instead to retrieve a Facet which supports
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
787 * data.
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
788 * @param theme Theme document for given annotations.
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
789 * @param visible The visibility of the annotations.
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
790 */
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
791 protected void doAnnotations(
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
792 FLYSAnnotation annotations,
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
793 Facet facet,
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
794 Document theme,
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
795 boolean visible
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
796 ){
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
797 logger.debug("doAnnotations");
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
798
1861
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
799 // Add all annotations to our annotation pool.
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
800 annotations.setTheme(theme);
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
801 annotations.setLabel(facet.getDescription());
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
802 addAnnotations(annotations, visible);
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
803 }
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
804 }
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
805 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org