annotate flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 3076:5642a83420f2

FLYS artifacts: Removed trailing whitespace. flys-artifacts/trunk@4670 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 15 Jun 2012 09:30:07 +0000
parents 478e8d9d88ba
children 8ad8a227d983
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;
2053
f9a972d375ba Use the user defined font size to set Y axes label fonts sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2052
diff changeset
5 import java.awt.Font;
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
6 import java.awt.Paint;
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
7 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
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;
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
13 import java.util.Iterator;
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;
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
15 import java.util.LinkedHashMap;
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
16 import java.util.Map;
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;
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
24 import org.jfree.chart.LegendItem;
1679
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;
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
26 import org.jfree.chart.annotations.XYBoxAnnotation;
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
27 import org.jfree.chart.annotations.XYLineAnnotation;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
28 import org.jfree.chart.annotations.XYTextAnnotation;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 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
30 import org.jfree.chart.axis.ValueAxis;
3064
478e8d9d88ba Add missing imports.
Christian Lins <christian.lins@intevation.de>
parents: 3063
diff changeset
31 import org.jfree.chart.plot.Marker;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 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
33 import org.jfree.chart.plot.XYPlot;
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;
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
35 import org.jfree.data.general.Series;
923
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.XYSeries;
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
37 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
38 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
39
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
40 import org.jfree.ui.TextAnchor;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
2325
1fcaeced48f2 #485 Fixed broken renaming of chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2300
diff changeset
42 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
43 import de.intevation.artifactdatabase.state.Facet;
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
44
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
45 import de.intevation.flys.jfree.Bounds;
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
46 import de.intevation.flys.jfree.DoubleBounds;
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
47 import de.intevation.flys.jfree.FLYSAnnotation;
1738
6cdc7a77d3d4 Apply theme attributes to axis annotation.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1736
diff changeset
48 import de.intevation.flys.jfree.StickyAxisAnnotation;
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
49 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
2074
a026d005accd Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2072
diff changeset
50 import de.intevation.flys.jfree.StyledAreaSeriesCollection;
a026d005accd Moved JFreeChart specific classes to de.intevation.flys.jfree and added required imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2072
diff changeset
51 import de.intevation.flys.jfree.StyledXYSeries;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52
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
53 import de.intevation.flys.utils.ThemeAccess;
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
54 import de.intevation.flys.utils.ThemeUtil;
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
56 import de.intevation.flys.artifacts.model.HYKFactory;
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
57
2206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
58 import org.json.JSONArray;
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
59 import org.json.JSONException;
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
60
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
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 /**
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 * 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
64 *
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
65 * 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
66 * <ul>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
67 * <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
68 * 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
69 * <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
70 * 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
71 * 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
72 * <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
73 * </ul>
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
74 *
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 * @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
76 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 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
78
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
79 // TODO Consider storing the renderer here.
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
80 private class XYAxisDataset implements AxisDataset {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
81 /** 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
82 protected int axisSymbol;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
83 /** 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
84 protected List<XYDataset> datasets;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
85 /** 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
86 protected Range range;
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
87 /** Index of axis in plot. */
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
88 protected int plotAxisIndex;
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
89
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
90 /** Create AxisDataset. */
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
91 public XYAxisDataset(int symb) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
92 this.axisSymbol = symb;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
93 datasets = new ArrayList<XYDataset>();
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
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
96 /** 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
97 private void mergeRanges(Range subRange) {
1959
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
98 // Avoid merging NaNs, as they take min/max place forever.
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
99 if (subRange == null ||
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
100 Double.isNaN(subRange.getLowerBound()) ||
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
101 Double.isNaN(subRange.getUpperBound())) {
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
102 return;
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
103 }
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
104 if (range == null) {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
105 range = subRange;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
106 return;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
107 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
108 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
109 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
110
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
111
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
112 /** Add a dataset to internal list for this axis. */
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
113 @Override
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
114 public void addDataset(XYDataset dataset) {
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
115 datasets.add(dataset);
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
116 includeYRange(((XYSeriesCollection) dataset).getSeries(0));
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
117 }
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
118
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
119 /** Add a dataset, include its range. */
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
120 public void addDataset(XYSeries series) {
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
121 addDataset(new XYSeriesCollection(series));
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
122 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
123
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
124
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
125 /** Set Range for this axis. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
126 @Override
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
127 public void setRange(Range range) {
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
128 this.range = range;
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
129 }
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
130
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
131
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
132 /** Get Range for this axis. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
133 @Override
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
134 public Range getRange() {
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
135 return range;
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
136 }
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
137
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
138
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
139 /** Get Array of Datasets. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
140 @Override
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
141 public XYDataset[] getDatasets() {
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
142 return (XYDataset[])
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
143 datasets.toArray(new XYDataset[datasets.size()]);
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
144 }
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
145
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
146
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
147 /** Add a Dataset that describes an area. */
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
148 public void addArea(StyledAreaSeriesCollection series) {
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
149 this.datasets.add(series);
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
150 }
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
151
2574
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
152 // TODO obsolete?
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
153 /** True if to be rendered as area. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
154 @Override
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
155 public boolean isArea(XYDataset series) {
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
156 return (series instanceof StyledAreaSeriesCollection);
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
157 }
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
158
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
159 /** Adjust range to include given dataset. */
1958
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
160 public void includeYRange(XYSeries dataset) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
161 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
162 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
163
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
164 /** True if no datasets given. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
165 @Override
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
166 public boolean isEmpty() {
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
167 return this.datasets.isEmpty();
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
168 }
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
169
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
170 /** Set the 'real' axis index that this axis is mapped to. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
171 @Override
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
172 public void setPlotAxisIndex(int axisIndex) {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
173 this.plotAxisIndex = axisIndex;
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
174 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
175
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
176 /** Get the 'real' axis index that this axis is mapped to. */
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
177 @Override
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
178 public int getPlotAxisIndex() {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
179 return this.plotAxisIndex;
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
180 }
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
181 } // class AxisDataset
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
182
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
183 /** Enumerator over existing axes. */
2246
99ef93ce18bd Doc added and fix getAxisWalker-issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2242
diff changeset
184 protected abstract YAxisWalker getYAxisWalker();
2000
e71719483546 Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1997
diff changeset
185
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
186 protected static float ANNOTATIONS_AXIS_OFFSET = 0.02f;
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
187
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
188 public static final int AXIS_SPACE = 5;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
189
1048
fd5c70973e0b Picky white-space cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 924
diff changeset
190 /** 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
191 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
192
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
193 /** 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
194 protected List<FLYSAnnotation> annotations;
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
195
3064
478e8d9d88ba Add missing imports.
Christian Lins <christian.lins@intevation.de>
parents: 3063
diff changeset
196 protected List<Marker> domainMarkers = new ArrayList<Marker>();
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3064
diff changeset
197
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
198 /** The max X range to include all X values of all series for each axis. */
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
199 protected Map<Integer, Bounds> xBounds;
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
200
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
201 /** The max Y range to include all Y values of all series for each axis. */
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
202 protected Map<Integer, Bounds> yBounds;
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
203
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
204
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
205 public XYChartGenerator() {
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
206 super();
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
207
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
208 xBounds = new HashMap<Integer, Bounds>();
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
209 yBounds = new HashMap<Integer, Bounds>();
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
210 }
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
211
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
212
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 /**
1930
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
214 * Generate the chart anew (including localized axis and all).
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
215 */
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
216 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
217 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
218
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 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
220 getChartTitle(),
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 getXAxisLabel(),
2051
4ba5036109d2 Make use of user defined axes labels during chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2050
diff changeset
222 getYAxisLabel(0),
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
223 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
224 PlotOrientation.VERTICAL,
2047
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2034
diff changeset
225 isLegendVisible(),
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 false,
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 false);
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228
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
229 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
230 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
231 plot.setBackgroundPaint(Color.WHITE);
414
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
232 addSubtitles(chart);
419
4de7d9eac10f Display gridlines in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 414
diff changeset
233 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
234
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
235 //debugAxis(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
236
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
237 addDatasets(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
238
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
239 //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
240
3063
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
241 addMarkers(plot);
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
242
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
243 recoverEmptyPlot(plot);
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
244 preparePointRanges(plot);
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
245
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
246 //debugAxis(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
247
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
248 localizeAxes(plot);
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
249 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
250 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
251
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
252 // These have to go after the autozoom.
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
253 addAnnotationsToRenderer(plot);
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
254
2706
d8444fcb4e44 Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2654
diff changeset
255 //aggregateLegendEntries(plot);
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
256
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
257 return chart;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
258 }
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
259
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
260
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
261 @Override
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
262 protected Series getSeriesOf(XYDataset dataset, int idx) {
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
263 return ((XYSeriesCollection) dataset).getSeries(idx);
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
264 }
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
265
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
266
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
267 @Override
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
268 protected AxisDataset createAxisDataset(int idx) {
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
269 logger.debug("Create new XYAxisDataset for index: " + idx);
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
270 return new XYAxisDataset(idx);
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
271 }
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
272
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
273
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
274 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
275 * 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
276 */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
277 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
278 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
279 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
280 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
281 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
282 continue;
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
283 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
284 logger.debug("Dataset #" + i + ":" + plot.getDataset(i));
1958
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
285 XYSeriesCollection series = (XYSeriesCollection) plot.getDataset(i);
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
286 logger.debug("X-Extend of Dataset: " + series.getSeries(0).getMinX()
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
287 + " " + series.getSeries(0).getMaxX());
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
288 logger.debug("Y-Extend of Dataset: " + series.getSeries(0).getMinY()
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
289 + " " + series.getSeries(0).getMaxY());
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
290 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
291 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
292
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
293
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
294 /**
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
295 * 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
296 */
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
297 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
298 logger.debug("...............");
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
299 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
300 if (plot.getRangeAxis(i) == null)
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
301 logger.debug("Range-Axis #" + i + " == null");
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
302 else {
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
303 logger.debug("Range-Axis " + i + " != null [" +
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
304 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
305 " " + 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
306 "]");
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
307 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
308
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
309 }
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
310 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
311 }
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
312
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
313
1685
022f62c75878 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
314 /**
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
315 * Registers an area to be drawn.
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
316 * @param area Area to be drawn.
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
317 * @param index 'axis index'
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
318 * @param visible Whether or not to be visible (important for range calculations).
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
319 */
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
320 public void addAreaSeries(StyledAreaSeriesCollection area, int index, boolean visible) {
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
321 if (area == null) {
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
322 logger.warn("Cannot yet render above/under curve.");
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
323 return;
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
324 }
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
325
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
326 XYAxisDataset axisDataset = (XYAxisDataset) getAxisDataset(index);
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
327
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
328 if (visible) {
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
329 axisDataset.addArea(area);
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
330 }
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
331 else {
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
332 // TODO only range merging.
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
333 }
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
334 //TODO range merging.
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
335 }
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
336
2020
4f7f781e4481 Improved area rendering workflow.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2005
diff changeset
337
2005
79b15491177a Added simple area registering functions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2000
diff changeset
338 /**
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
339 * 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
340 * 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
341 * @param series the dataseries to include in plot.
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
342 * @param index ('symbolic') index of the series and of its axis.
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
343 * @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
344 */
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
345 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
346 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
347 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
348 }
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
349
2242
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
350 logger.debug("Y Range of XYSeries: " +
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
351 series.getMinY() + " | " + series.getMaxY());
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
352
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
353 addAxisDataset(new XYSeriesCollection(series), index, visible);
7e8e1d5384c0 Further refactoring of XYChartGenerator / ChartGenerator with the result, that timerange charts are now able to display lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2238
diff changeset
354
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
355 XYAxisDataset axisDataset = (XYAxisDataset) getAxisDataset(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
356
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
357 if (!visible) {
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
358 // 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
359 // that every data-point could be seen (except for annotations).
1958
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
360 axisDataset.includeYRange(series);
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
361 }
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
362 }
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
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3064
diff changeset
364
3063
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
365 /**
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
366 * Add the given vertical marker to the chart.
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
367 */
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
368 public void addDomainMarker(Marker marker) {
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
369 if (marker == null) {
3064
478e8d9d88ba Add missing imports.
Christian Lins <christian.lins@intevation.de>
parents: 3063
diff changeset
370 return;
3063
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
371 }
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
372
3064
478e8d9d88ba Add missing imports.
Christian Lins <christian.lins@intevation.de>
parents: 3063
diff changeset
373 domainMarkers.add(marker);
3063
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
374 }
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
375
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
376
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
377 protected void addMarkers(XYPlot plot) {
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
378 for(Marker marker : domainMarkers) {
3064
478e8d9d88ba Add missing imports.
Christian Lins <christian.lins@intevation.de>
parents: 3063
diff changeset
379 plot.addDomainMarker(marker);
3063
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
380 }
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
381 }
33c167d6fff6 Move marker generation to XYChartGenerator
Christian Lins <christian.lins@intevation.de>
parents: 2998
diff changeset
382
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
383
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
384 /**
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 * Effect: extend range of x axis to include given limits.
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
386 *
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
387 * @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
388 * @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
389 */
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
390 @Override
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
391 protected void combineXBounds(Bounds bounds, int index) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
392 if (!(bounds instanceof DoubleBounds)) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
393 logger.warn("Unsupported Bounds type: " + bounds.getClass());
1959
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
394 return;
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
395 }
eace020067da Further flys/issue420 fix, NaN-guard X axis extent.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1958
diff changeset
396
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
397 DoubleBounds dBounds = (DoubleBounds) bounds;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
398
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
399 if (dBounds == null
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
400 || Double.isNaN((Double) dBounds.getLower())
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
401 || Double.isNaN((Double) dBounds.getUpper())) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
402 return;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
403 }
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
404
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
405 Bounds old = getXBounds(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
406
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 if (old != null) {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
408 dBounds = (DoubleBounds) dBounds.combine(old);
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
409 }
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
410
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
411 setXBounds(index, dBounds);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
412 }
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
413
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
414
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
415 @Override
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
416 protected void combineYBounds(Bounds bounds, int index) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
417 if (!(bounds instanceof DoubleBounds)) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
418 logger.warn("Unsupported Bounds type: " + bounds.getClass());
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
419 return;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
420 }
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
421
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
422 DoubleBounds dBounds = (DoubleBounds) bounds;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
423
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
424 if (dBounds == null
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
425 || Double.isNaN((Double) dBounds.getLower())
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
426 || Double.isNaN((Double) dBounds.getUpper())) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
427 return;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
428 }
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
429
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
430 Bounds old = getYBounds(index);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
431
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
432 if (old != null) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
433 dBounds = (DoubleBounds) dBounds.combine(old);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
434 }
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
435
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
436 setYBounds(index, dBounds);
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
437 }
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
438
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
439
1930
de0c2bbb27f9 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1861
diff changeset
440 /**
1711
f708120cb7bc Fix flys/issue363 (W-INFO/ Abflusskurve, Extremwert-Rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1699
diff changeset
441 * 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
442 */
2772
5e8e42a36a90 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2767
diff changeset
443 public void addVisibleAnnotations(FLYSAnnotation annotation) {
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
444 if (annotations == null) {
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
445 annotations = new ArrayList<FLYSAnnotation>();
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
446 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
447
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
448 annotations.add(annotation);
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
449 }
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
450
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
451
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
452 /**
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
453 * 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
454 */
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
455 private void recoverEmptyPlot(XYPlot plot) {
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
456 if (plot.getRangeAxis() == null) {
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
457 logger.debug("debug: No range axis");
2414
b5f5af53a526 Make it compileable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2411
diff changeset
458 plot.setRangeAxis(createYAxis(0));
1935
5b51f5232661 Added handling of empty plots.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1934
diff changeset
459 }
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
460 }
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
461
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
462
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
463 /**
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
464 * 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
465 */
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
466 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
467 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
468 logger.debug("Check whether to expand a x axis.");
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
469
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
470 Integer key = Integer.valueOf(i);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
471 Bounds b = getXBounds(key);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
472
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
473 if (b != null && b.getLower() == b.getUpper()) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
474 double lo = (Double) b.getLower();
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
475 double hi = (Double) b.getUpper();
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
476 double add = (hi - lo) / 100 * 5;
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
477
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
478 setXBounds(key, new DoubleBounds(lo-add, hi+add));
1686
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
479 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
480 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
481 }
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
482
e8d1e531687a Bugfix: #114 Enabled rendering charts with a single data point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1685
diff changeset
483
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
484 /**
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
485 * 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
486 * 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
487 * 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
488 * 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
489 * 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
490 *
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
491 * @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
492 */
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
493 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
494 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
495
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 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
497 Range yrange = getValueAxisRange();
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
498
2050
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
499 ValueAxis xAxis = plot.getDomainAxis();
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
500
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
501 Range fixedXRange = getRangeForAxisFromSettings("X");
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
502 if (fixedXRange != null) {
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
503 xAxis.setRange(fixedXRange);
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
504 }
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
505 else {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
506 zoomX(plot, xAxis, getXBounds(0), xrange);
2050
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
507 }
923
7ca4a287cd0e #135 Modified the way to store datasets for different chart axes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 718
diff changeset
508
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
509 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
510 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
511
2049
2d5f2bc68cc6 Centralized the creation of new NumberAxis - new NumberAxis instances in FLYS will be from type IdentifiableNumberAxis which subclasses JFreeChart's NumberAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2048
diff changeset
512 if (yaxis instanceof IdentifiableNumberAxis) {
2050
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
513 IdentifiableNumberAxis idAxis = (IdentifiableNumberAxis) yaxis;
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
514
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
515 Range fixedRange = getRangeForAxisFromSettings(idAxis.getId());
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
516 if (fixedRange != null) {
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
517 yaxis.setRange(fixedRange);
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
518 continue;
c4e0e433f825 Use axes ranges specified in ChartSettings for zooming in charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2049
diff changeset
519 }
2049
2d5f2bc68cc6 Centralized the creation of new NumberAxis - new NumberAxis instances in FLYS will be from type IdentifiableNumberAxis which subclasses JFreeChart's NumberAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2048
diff changeset
520 }
2d5f2bc68cc6 Centralized the creation of new NumberAxis - new NumberAxis instances in FLYS will be from type IdentifiableNumberAxis which subclasses JFreeChart's NumberAxis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2048
diff changeset
521
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
522 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
523 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
524 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
525 }
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
526
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
527 logger.debug("Prepare zoom settings for y axis at index: " + i);
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
528 zoomY(plot, yaxis, getYBounds(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
529 }
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
530 }
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
531
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
532
2395
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
533 protected Range getDomainAxisRange() {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
534 String[] ranges = getDomainAxisRangeFromRequest();
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
535
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
536 if (ranges == null || ranges.length < 2) {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
537 logger.debug("No zoom range for domain axis specified.");
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
538 return null;
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
539 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
540
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
541 if (ranges[0].length() > 0 && ranges[1].length() > 0) {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
542 try {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
543 double from = Double.parseDouble(ranges[0]);
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
544 double to = Double.parseDouble(ranges[1]);
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
545
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
546 if (from == 0 && to == 0) {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
547 logger.debug("No range specified. Lower and upper X == 0");
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
548 return null;
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
549 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
550
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
551 if (from > to) {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
552 double tmp = to;
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
553 to = from;
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
554 from = tmp;
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
555 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
556
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
557 return new Range(from, to);
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
558 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
559 catch (NumberFormatException nfe) {
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
560 logger.warn("Wrong values for domain axis range.");
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
561 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
562 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
563
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
564 return null;
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
565 }
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
566
cd4fb19ab892 Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2325
diff changeset
567
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
568 protected Range getValueAxisRange() {
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
569 String[] ranges = getValueAxisRangeFromRequest();
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
570
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
571 if (ranges == null || ranges.length < 2) {
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
572 logger.debug("No range specified. Lower and upper Y == 0");
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
573 return null;
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
574 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
575
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
576 if (ranges[0].length() > 0 && ranges[1].length() > 0) {
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
577 try {
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
578 double from = Double.parseDouble(ranges[0]);
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
579 double to = Double.parseDouble(ranges[1]);
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
580
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
581 if (from == 0 && to == 0) {
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
582 logger.debug("No range specified. Lower and upper Y == 0");
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
583 return null;
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
584 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
585
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
586 return from > to
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
587 ? new Range(to, from)
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
588 : new Range(from, to);
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
589 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
590 catch (NumberFormatException nfe) {
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
591 logger.warn("Wrong values for value axis range.");
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
592 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
593 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
594
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
595 return null;
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
596 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
597
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
598
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
599 protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
600 return zoom(plot, axis, bounds, x);
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
601 }
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
602
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
603
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
604 protected boolean zoomY(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
605 return zoom(plot, axis, bounds, x);
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
606 }
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
607
f3fd8c9b7f51 #157 Computed discharge curve charts always have a lower bound set to 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 717
diff changeset
608
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
609 /**
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
610 * 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
611 *
1958
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
612 * @param plot The XYPlot.
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
613 * @param axis The axis the shoud be modified.
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
614 * @param range The whole range specified by a dataset.
1958
82cefa3f954f Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1948
diff changeset
615 * @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
616 *
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
617 * @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
618 */
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
619 protected boolean zoom(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
1736
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
620
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
621 if (bounds == null) {
1736
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
622 return false;
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
623 }
0155cbaba182 XYChartGenerator: Do not crash if no zoom axis given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1735
diff changeset
624
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
625 if (x != null) {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
626 double min = bounds.getLower().doubleValue();
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
627 double max = bounds.getUpper().doubleValue();
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
628
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
629 if (logger.isDebugEnabled()) {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
630 logger.debug("Minimum is: " + min);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
631 logger.debug("Maximum is: " + max);
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
632 logger.debug("Lower zoom is: " + x.getLowerBound());
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
633 logger.debug("Upper zoom is: " + x.getUpperBound());
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
634 }
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
635
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
636 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
637
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
638 DoubleBounds computed = new DoubleBounds(
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
639 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
640 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
641
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
642 computed.applyBounds(axis, AXIS_SPACE);
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
643
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
644 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
645
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
646 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
647 }
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
648
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
649 bounds.applyBounds(axis, AXIS_SPACE);
654
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
650 return false;
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
651 }
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
652
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
653
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
654 /**
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
655 * Extract the minimum and maximum values for x and y axes
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
656 * 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
657 *
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
658 * @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
659 *
bbc966c81809 #90 Removed margins between data area border and curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 653
diff changeset
660 * @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
661 */
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2246
diff changeset
662 @Override
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1943
diff changeset
663 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
664 logger.debug("getRangesForAxis " + index);
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
665
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
666 Bounds rx = getXBounds(Integer.valueOf(0));
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
667 Bounds ry = getYBounds(Integer.valueOf(index));
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
668
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
669 if (rx == null) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
670 logger.warn("Range for x axis not set." +
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
671 " Using default values: 0 - 1.");
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
672 rx = new DoubleBounds(0, 1);
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
673 }
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
674 if (ry == null) {
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
675 logger.warn("Range for y" + index +
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
676 " axis not set. Using default values: 0 - 1.");
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
677 ry = new DoubleBounds(0, 1);
2132
e8fc770d2f8c 'New Chart' for computed discharge curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2110
diff changeset
678 }
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
679
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
680 return new Range[] {
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
681 new Range(rx.getLower().doubleValue(), rx.getUpper().doubleValue()),
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
682 new Range(ry.getLower().doubleValue(), ry.getUpper().doubleValue())
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
683 };
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
684 }
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
685
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
686
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
687 /** Get X (usually horizontal) extent for given axis. */
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
688 @Override
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
689 public Bounds getXBounds(int axis) {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
690 return xBounds.get(axis);
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
691 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
692
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
693
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
694 /** Set X (usually horizontal) extent for given axis. */
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
695 @Override
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
696 protected void setXBounds(int axis, Bounds bounds) {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
697 xBounds.put(axis, bounds);
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
698 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
699
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
700
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
701 /** Get Y (usually vertical) extent for given axis. */
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
702 @Override
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
703 public Bounds getYBounds(int axis) {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
704 return yBounds.get(axis);
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
705 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
706
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
707
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
708 /** Set Y (usually vertical) extent for given axis. */
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
709 @Override
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
710 protected void setYBounds(int axis, Bounds bounds) {
2587
bece6f604899 Removed references to Range and replaced those with references to Bounds in ChartGenerators.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2584
diff changeset
711 yBounds.put(axis, bounds);
2398
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
712 }
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
713
5d8d24984819 New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2395
diff changeset
714
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
715 /** Get color for hyk zones by their type (which is the name). */
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
716 public Paint colorForHYKZone(String zoneName) {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
717 if (zoneName.startsWith("R")) {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
718 // Brownish.
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
719 return new Color(153, 60, 0);
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
720 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
721 else if (zoneName.startsWith("V")) {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
722 // Greenish.
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
723 return new Color(0, 255, 0);
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
724 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
725 else if (zoneName.startsWith("B")) {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
726 // Grayish.
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
727 return new Color(128, 128, 128);
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
728 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
729 else if (zoneName.startsWith("H")) {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
730 // Blueish.
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
731 return new Color(0, 0, 255);
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
732 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
733 else {
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
734 // Default.
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
735 logger.debug("Unknown zone type found.");
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
736 return new Color(255, 0, 0);
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
737 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
738 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
739
2997
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
740
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
741 /**
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
742 * Create annotation that sticks to "ground" (X) axis.
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
743 * @param area helper to calculate coordinates
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
744 * @param pos one-dimensional position (distance from axis)
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
745 * @param lineStyle the line style to use for the line.
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
746 */
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
747 protected static XYLineAnnotation createGroundStickAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
748 Area area, float pos, ThemeAccess.LineStyle lineStyle
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
749 ) {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
750 // Style the line.
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
751 if (lineStyle != null) {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
752 return new XYLineAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
753 pos, area.atGround(),
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
754 pos, area.ofGround(ANNOTATIONS_AXIS_OFFSET),
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
755 new BasicStroke(lineStyle.getWidth()),lineStyle.getColor());
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
756 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
757 else {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
758 return new XYLineAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
759 pos, area.atGround(),
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
760 pos, area.ofGround(ANNOTATIONS_AXIS_OFFSET));
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
761 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
762 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
763
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
764
2997
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
765 /**
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
766 * Create annotation that sticks to the second Y axis ("right").
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
767 * @param area helper to calculate coordinates
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
768 * @param pos one-dimensional position (distance from axis)
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
769 * @param lineStyle the line style to use for the line.
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
770 */
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
771 protected static XYLineAnnotation createRightStickAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
772 Area area, float pos, ThemeAccess.LineStyle lineStyle
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
773 ) {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
774 // Style the line.
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
775 if (lineStyle != null) {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
776 return new XYLineAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
777 area.ofRight(ANNOTATIONS_AXIS_OFFSET), pos,
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
778 area.atRight(), pos,
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
779 new BasicStroke(lineStyle.getWidth()), lineStyle.getColor());
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
780 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
781 else {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
782 return new XYLineAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
783 area.atRight(), pos,
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
784 area.ofRight(ANNOTATIONS_AXIS_OFFSET), pos);
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
785 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
786 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
787
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
788
2997
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
789 /**
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
790 * Create annotation that sticks to the second Y axis ("right").
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
791 * @param area helper to calculate coordinates
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
792 * @param pos one-dimensional position (distance from axis)
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
793 * @param lineStyle the line style to use for the line.
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
794 */
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
795 protected static XYLineAnnotation createLeftStickAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
796 Area area, float pos, ThemeAccess.LineStyle lineStyle
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
797 ) {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
798 // Style the line.
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
799 if (lineStyle != null) {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
800 return new XYLineAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
801 area.atLeft(), pos,
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
802 area.ofLeft(ANNOTATIONS_AXIS_OFFSET), pos,
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
803 new BasicStroke(lineStyle.getWidth()), lineStyle.getColor());
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
804 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
805 else {
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
806 return new XYLineAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
807 area.atLeft(), pos,
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
808 area.ofLeft(ANNOTATIONS_AXIS_OFFSET), pos);
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
809 }
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
810 }
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
811
2997
60f13d966ee3 Doc and TODOs added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2996
diff changeset
812
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
813 /**
2998
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
814 * Create a line from a axis to a given point.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
815 * @param axis The "simple" axis.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
816 * @param fromD1 from-location in first dimension.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
817 * @param toD2 to-location in second dimension.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
818 * @param area helper to calculate offsets.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
819 * @param lineStyle optional line style.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
820 */
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
821 protected static XYLineAnnotation createStickyLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
822 StickyAxisAnnotation.SimpleAxis axis, float fromD1, float toD2,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
823 Area area, ThemeAccess.LineStyle lineStyle
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
824 ) {
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
825 double anchorX1 = 0d, anchorX2 = 0d, anchorY1 = 0d, anchorY2 = 0d;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
826 switch(axis) {
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
827 case X_AXIS:
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
828 anchorX1 = fromD1;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
829 anchorX2 = fromD1;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
830 anchorY1 = area.atGround();
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
831 anchorY2 = toD2;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
832 break;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
833 case Y_AXIS:
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
834 anchorX1 = area.atLeft();
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
835 anchorX2 = toD2;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
836 anchorY1 = fromD1;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
837 anchorY2 = fromD1;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
838 break;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
839 case Y_AXIS2:
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
840 anchorX1 = area.atRight();
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
841 anchorX2 = toD2;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
842 anchorY1 = fromD1;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
843 anchorY2 = fromD1;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
844 break;
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
845 }
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
846 // Style the line.
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
847 if (lineStyle != null) {
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
848 return new XYLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
849 anchorX1, anchorY1,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
850 anchorX2, anchorY2,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
851 new BasicStroke(lineStyle.getWidth()), lineStyle.getColor());
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
852 }
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
853 else {
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
854 return new XYLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
855 anchorX1, anchorY1,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
856 anchorX2, anchorY2);
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
857 }
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
858 }
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
859
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
860
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
861 /**
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
862 * Add a text and a line annotation.
2775
5016609663e2 Draw line from w-annotation to duration curve, rough version.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2772
diff changeset
863 * @param area convenience to determine positions in plot.
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
864 * @param theme (optional) theme document
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
865 */
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
866 public void addStickyAnnotation(
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
867 StickyAxisAnnotation annotation,
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
868 XYPlot plot,
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
869 Area area,
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
870 ThemeAccess.LineStyle lineStyle,
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
871 ThemeAccess.TextStyle textStyle,
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
872 Document theme
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
873 ) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
874 // OPTIMIZE pre-calculate area-related values
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
875 final float TEXT_OFF = 0.03f;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
876
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
877 XYLineAnnotation lineAnnotation = null;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
878 XYTextAnnotation textAnnotation = null;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
879
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
880 int rendererIndex = 0;
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
881
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
882 if (annotation.atX()) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
883 textAnnotation = new CollisionFreeXYTextAnnotation(
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
884 annotation.getText(), annotation.getPos(), area.ofGround(TEXT_OFF));
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
885 // OPTIMIZE externalize the calculation involving PI.
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
886 textAnnotation.setRotationAngle(270f*Math.PI/180f);
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
887 lineAnnotation = createGroundStickAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
888 area, annotation.getPos(), lineStyle);
2416
5144369d5961 Partial Fix flys/issue500: text-orientation for texts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2414
diff changeset
889 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT);
5144369d5961 Partial Fix flys/issue500: text-orientation for texts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2414
diff changeset
890 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT);
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
891 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
892 else {
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
893 // Do the more complicated case where we stick to the Y-Axis.
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
894 // There is one nasty case (duration curves, where annotations
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
895 // might stick to the second y-axis).
2238
23c7c51df772 Some more refactoring in XYChartGenerator and ChartGenerator; implemented necessary stuff in TimeseriesChartGenerator and return new empty instances of timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2236
diff changeset
896 XYAxisDataset dataset = (XYAxisDataset) getAxisDataset(
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
897 new Integer(annotation.getAxisSymbol()));
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
898 if (dataset == null) {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
899 logger.warn("Annotation should stick to unfindable y-axis: "
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
900 + annotation.getAxisSymbol());
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
901 rendererIndex = 0;
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
902 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
903 else {
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
904 rendererIndex = dataset.getPlotAxisIndex();
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
905 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
906
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
907 // Stick to the "right" (opposed to left) Y-Axis.
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
908 if (rendererIndex != 0) {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
909 // OPTIMIZE: Pass a different area to this function,
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
910 // do the adding to renderer outside (let this
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
911 // function return the annotations).
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
912 // Note that this path is travelled rarely.
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
913 Area area2 = new Area(plot.getDomainAxis(), plot.getRangeAxis(rendererIndex));
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
914 textAnnotation = new CollisionFreeXYTextAnnotation(
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
915 annotation.getText(), area2.ofRight(TEXT_OFF), annotation.getPos());
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
916 textAnnotation.setRotationAnchor(TextAnchor.CENTER_RIGHT);
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
917 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT);
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
918 lineAnnotation = createRightStickAnnotation(
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
919 area2, annotation.getPos(), lineStyle);
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
920 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) {
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
921 // New line annotation to hit curve.
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
922 if (ThemeUtil.parseShowVerticalLine(theme)) {
2998
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
923 XYLineAnnotation hitLineAnnotation =
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
924 createStickyLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
925 StickyAxisAnnotation.SimpleAxis.X_AXIS,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
926 annotation.getPos(), annotation.getHitPoint(),
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
927 area, lineStyle);
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
928 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
929 org.jfree.ui.Layer.BACKGROUND);
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
930 }
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
931 if (ThemeUtil.parseShowHorizontalLine(theme)) {
2998
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
932 XYLineAnnotation lineBackAnnotation =
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
933 createStickyLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
934 StickyAxisAnnotation.SimpleAxis.Y_AXIS2,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
935 annotation.getPos(), annotation.getHitPoint(),
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
936 area, lineStyle);
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
937 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation,
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
938 org.jfree.ui.Layer.BACKGROUND);
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
939 }
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
940 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
941 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
942 else {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
943 textAnnotation = new CollisionFreeXYTextAnnotation(
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
944 annotation.getText(), area.ofLeft(TEXT_OFF), annotation.getPos());
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
945 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT);
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
946 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT);
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
947 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle);
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
948 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) {
2780
772d0c8100d3 Improved 'line-to-curve' rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2777
diff changeset
949 // New line annotation to hit curve.
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
950 if (ThemeUtil.parseShowHorizontalLine(theme)) {
2998
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
951 XYLineAnnotation hitLineAnnotation =
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
952 createStickyLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
953 StickyAxisAnnotation.SimpleAxis.Y_AXIS,
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
954 annotation.getPos(), annotation.getHitPoint(),
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
955 area, lineStyle);
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
956 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
957 org.jfree.ui.Layer.BACKGROUND);
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
958 }
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
959 if (ThemeUtil.parseShowVerticalLine(theme)) {
2998
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
960 XYLineAnnotation lineBackAnnotation =
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
961 createStickyLineAnnotation(
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
962 StickyAxisAnnotation.SimpleAxis.X_AXIS,
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3064
diff changeset
963 annotation.getHitPoint(), annotation.getPos(),
2998
4b6fb6d91192 issue417: duration curve main values as line(s) to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2997
diff changeset
964 area, lineStyle);
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
965 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation,
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
966 org.jfree.ui.Layer.BACKGROUND);
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
967 }
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
968 }
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
969 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
970 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
971
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
972 // Style the text.
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
973 if (textStyle != null) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
974 textStyle.apply(textAnnotation);
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
975 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
976
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
977 // Add the Annotations to renderer.
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
978 plot.getRenderer(rendererIndex).addAnnotation(textAnnotation,
2300
a3dd443976bc Put line and text annotations placed at x and y axes into foreground.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
979 org.jfree.ui.Layer.FOREGROUND);
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
980 plot.getRenderer(rendererIndex).addAnnotation(lineAnnotation,
2300
a3dd443976bc Put line and text annotations placed at x and y axes into foreground.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
981 org.jfree.ui.Layer.FOREGROUND);
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
982 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
983
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
984
2654
884ae61def58 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2590
diff changeset
985 /**
884ae61def58 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2590
diff changeset
986 * Add the annotations (Sticky, Text and hyk zones) stored
884ae61def58 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2590
diff changeset
987 * in the annotations field.
884ae61def58 Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2590
diff changeset
988 */
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
989 public void addAnnotationsToRenderer(XYPlot plot) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
990 logger.debug("XYChartGenerator.addAnnotationsToRenderer");
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
991
2143
c5d24e0587ce Minor hyk-handling improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
992 if (annotations == null) {
2775
5016609663e2 Draw line from w-annotation to duration curve, rough version.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2772
diff changeset
993 logger.debug("XYChartGenerator.addAnnotationsToRenderer: no annotations.");
2143
c5d24e0587ce Minor hyk-handling improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
994 return;
c5d24e0587ce Minor hyk-handling improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
995 }
c5d24e0587ce Minor hyk-handling improvements.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2138
diff changeset
996
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
997 // Paints for the boxes/lines.
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
998 Stroke basicStroke = new BasicStroke(1.0f);
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
999
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1000 Paint linePaint = new Color(255, 0,0,60);
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1001 Paint fillPaint = new Color(0, 255,0,60);
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1002 Paint tranPaint = new Color(0, 0,0, 0);
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1003
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1004 // OPTMIMIZE: Pre-calculate positions
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1005 Area area = new Area(
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1006 plot.getDomainAxis(0).getRange(),
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1007 plot.getRangeAxis().getRange());
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1008
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1009 // Walk over all Annotation sets.
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1010 for (FLYSAnnotation fa: annotations) {
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1011
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1012 // Access text styling, if any.
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1013 Document theme = fa.getTheme();
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1014 ThemeAccess.TextStyle textStyle = null;
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1015 ThemeAccess.LineStyle lineStyle = null;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1016
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1017 // Get Themeing information and add legend item.
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1018 if (theme != null) {
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1019 ThemeAccess themeAccess = new ThemeAccess(theme);
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1020 textStyle = themeAccess.parseTextStyle();
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1021 lineStyle = themeAccess.parseLineStyle();
2184
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1022 if (fa.getLabel() != null) {
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1023 LegendItemCollection lic = new LegendItemCollection();
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1024 LegendItemCollection old = plot.getFixedLegendItems();
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1025 lic.add(createLegendItem(theme, fa.getLabel()));
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1026 // (Re-)Add prior legend entries.
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1027 if (old != null) {
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1028 old.addAll(lic);
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1029 }
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1030 else {
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1031 old = lic;
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1032 }
fc86fcfe503e Only add one legend item for manual point themes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2183
diff changeset
1033 plot.setFixedLegendItems(old);
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1034 }
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1035 }
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1036
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1037 // The 'Sticky' Annotations (at axis, with line and text).
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1038 for (StickyAxisAnnotation sta: fa.getAxisTextAnnotations()) {
2996
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
1039 addStickyAnnotation(
55f91fae8a7b Respect new theme setting when drawing line to curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2780
diff changeset
1040 sta, plot, area, lineStyle, textStyle, theme);
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1041 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1042
2411
7e0be3e5dfaa Fix flys/issue490 (text for manual points).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2409
diff changeset
1043 // Other Text Annotations (e.g. labels of manual points).
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1044 for (XYTextAnnotation ta: fa.getTextAnnotations()) {
2193
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1045 // Style the text.
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1046 if (textStyle != null) {
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1047 textStyle.apply(ta);
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1048 }
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1049 ta.setY(area.above(0.05d, ta.getY()));
2183
a79d5cd26083 Render labels of manual points in a very primitive manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2163
diff changeset
1050 plot.getRenderer().addAnnotation(ta, org.jfree.ui.Layer.FOREGROUND);
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1051 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1052
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1053 // Hyks.
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1054 for (HYKFactory.Zone zone: fa.getBoxes()) {
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1055 // For each zone, create a box to fill with color, a box to draw
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1056 // the lines and a text to display the type.
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1057 fillPaint = colorForHYKZone(zone.getName());
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1058
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1059 XYBoxAnnotation boxA = new XYBoxAnnotation(zone.getFrom(), area.atGround(),
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1060 zone.getTo(), area.ofGround(0.03f), basicStroke, tranPaint, fillPaint);
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1061 XYBoxAnnotation boxB = new XYBoxAnnotation(zone.getFrom(), area.atGround(),
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1062 zone.getTo(), area.atTop(), basicStroke, fillPaint, tranPaint);
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1063
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1064 XYTextAnnotation tex = new XYTextAnnotation(zone.getName(),
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1065 zone.getFrom() + (zone.getTo() - zone.getFrom()) / 2.0d,
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1066 area.ofGround(0.015f));
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1067 if (textStyle != null) {
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1068 textStyle.apply(tex);
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1069 }
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1070
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1071 plot.getRenderer().addAnnotation(boxA, org.jfree.ui.Layer.BACKGROUND);
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1072 plot.getRenderer().addAnnotation(boxB, org.jfree.ui.Layer.BACKGROUND);
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1073 plot.getRenderer().addAnnotation(tex, org.jfree.ui.Layer.BACKGROUND);
2138
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1074 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1075 }
59bb5c895be3 Improved HYK/Zones- handling.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2132
diff changeset
1076 }
1679
69929c471646 Improved the creation/rendering of annotations (km favorites, mainvalues).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1645
diff changeset
1077
2152
2336927cb096 Add basic (text) styling for HYKS.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2143
diff changeset
1078
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1079 /**
2054
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1080 * Adjusts the axes of a plot. This method sets the <i>labelFont</i> of the
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1081 * X axis.
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1082 *
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1083 * @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
1084 */
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1085 protected void adjustAxes(XYPlot plot) {
2054
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1086 ValueAxis xaxis = plot.getDomainAxis();
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1087
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1088 ChartSettings chartSettings = getChartSettings();
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1089 if (chartSettings == null) {
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1090 return;
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
1091 }
2054
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1092
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1093 Font labelFont = new Font(
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1094 DEFAULT_FONT_NAME,
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1095 Font.BOLD,
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1096 getXAxisLabelFontSize());
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1097
a653295c9ac0 Make use of user defined axes font sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2053
diff changeset
1098 xaxis.setLabelFont(labelFont);
2590
d75b427da50a #522 Modified axes creation: label and tick label fonts will now always be the same.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2587
diff changeset
1099 xaxis.setTickLabelFont(labelFont);
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1100 }
414
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
1101
0385bcc4229a Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 375
diff changeset
1102
1940
0d12e70766c8 Refactored XYChartGenerator to have better working multi-axes features.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1935
diff changeset
1103 /**
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
1104 * 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
1105 * 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
1106 * 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
1107 *
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
1108 * @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
1109 */
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
1110 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
1111 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
1112 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
1113
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
1114 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
1115 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
1116 }
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
1117 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
1118 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
1119 }
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
1120 }
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
1121
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
1122 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
1123 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
1124
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
1125 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
1126 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
1127 }
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
1128 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
1129 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
1130 }
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
1131 }
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
1132 }
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
1133
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
1134
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
1135 /**
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
1136 * 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
1137 * 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
1138 *
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
1139 * @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
1140 */
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
1141 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
1142 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
1143 ((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
1144 }
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
1145
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
1146
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
1147 /**
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
1148 * 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
1149 * 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
1150 *
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
1151 * @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
1152 */
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
1153 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
1154 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
1155 ((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
1156 }
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
1157
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
1158
1932
17e18948fe5e Fix legend and themeing with new multiaxis feature.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1931
diff changeset
1159 /**
1861
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
1160 * Register annotations like MainValues for later plotting
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
1161 *
2767
1cb072d0978d Cosmetic
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2711
diff changeset
1162 * @param annotations list of annotations (data of facet).
1cb072d0978d Cosmetic
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2711
diff changeset
1163 * @param aandf Artifact and the facet.
1861
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
1164 * @param theme Theme document for given annotations.
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
1165 * @param visible The visibility of the annotations.
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1166 */
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1167 protected void doAnnotations(
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1168 FLYSAnnotation annotations,
2325
1fcaeced48f2 #485 Fixed broken renaming of chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2300
diff changeset
1169 ArtifactAndFacet aandf,
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1170 Document theme,
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1171 boolean visible
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1172 ){
2411
7e0be3e5dfaa Fix flys/issue490 (text for manual points).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2409
diff changeset
1173 // Running into trouble here.
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1174 logger.debug("doAnnotations");
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1175
1861
11c4b1429117 Cosmetics, resolve code duplicate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1849
diff changeset
1176 // Add all annotations to our annotation pool.
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1177 annotations.setTheme(theme);
2574
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1178 if (aandf != null) {
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1179 Facet facet = aandf.getFacet();
2325
1fcaeced48f2 #485 Fixed broken renaming of chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2300
diff changeset
1180 annotations.setLabel(aandf.getFacetDescription());
2574
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1181 }
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1182 else {
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1183 logger.debug(
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1184 "Art/Facet for Annotations is null. " +
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1185 "This should never happen!");
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1186 }
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1187
2772
5e8e42a36a90 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2767
diff changeset
1188 if (visible) {
5e8e42a36a90 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2767
diff changeset
1189 addVisibleAnnotations(annotations);
5e8e42a36a90 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2767
diff changeset
1190 }
1849
5d5dd44d613e Refactored, move doMainValueAnnotations to XYChartGenerator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1768
diff changeset
1191 }
1986
3632150dbe0b Implemented a ChartSettings with relevant Sections and Attributes for charts (NOTE: Work still in progress).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1983
diff changeset
1192
3632150dbe0b Implemented a ChartSettings with relevant Sections and Attributes for charts (NOTE: Work still in progress).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1983
diff changeset
1193
3632150dbe0b Implemented a ChartSettings with relevant Sections and Attributes for charts (NOTE: Work still in progress).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1983
diff changeset
1194 /**
2206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1195 * Do Points out.
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1196 */
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1197 protected void doPoints(
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1198 Object o,
2325
1fcaeced48f2 #485 Fixed broken renaming of chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2300
diff changeset
1199 ArtifactAndFacet aandf,
2206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1200 Document theme,
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1201 boolean visible,
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1202 int axisIndex
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1203 ) {
2325
1fcaeced48f2 #485 Fixed broken renaming of chart themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2300
diff changeset
1204 String seriesName = aandf.getFacetDescription();
2206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1205 XYSeries series = new StyledXYSeries(seriesName, theme);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1207 // Add text annotations for single points.
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1208 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1209
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1210 try {
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1211 JSONArray points = new JSONArray((String) o);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1212 for (int i = 0; i < points.length(); i++) {
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1213 JSONArray array = points.getJSONArray(i);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1214 double x = array.getDouble(0);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1215 double y = array.getDouble(1);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1216 String name = array.getString(2);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1217 boolean act = array.getBoolean(3);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1218 if (!act) {
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1219 continue;
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1220 }
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1221 //logger.debug(" x " + x + " y " + y );
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1222 series.add(x, y, false);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1223 xy.add(new CollisionFreeXYTextAnnotation(name, x, y));
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1224 }
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1225 }
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1226 catch(JSONException e){
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1227 logger.error("Could not decode json.");
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1228 }
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3064
diff changeset
1229
2206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1230 FLYSAnnotation annotations = new FLYSAnnotation(null, null, null, theme);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1231 annotations.setTextAnnotations(xy);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1232
2574
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1233 // Do not generate second legend entry. (null was passed for the aand before).
3598690dc9e2 Fix flys/issue501 (manual points have two legend entries).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2553
diff changeset
1234 doAnnotations(annotations, null, theme, visible);
2206
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1235 addAxisSeries(series, axisIndex, visible);
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1236 }
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1237
e2124ca11adb Add manual point handling for many different chart types.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2193
diff changeset
1238
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1239 /**
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1240 * Create a hash from a legenditem.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1241 * This hash can then be used to merge legend items labels.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1242 * @return hash for given legenditem to identify mergeables.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1243 */
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1244 public static String legendItemHash(LegendItem li) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1245 // TODO Do proper implementation. Ensure that only mergable sets are created.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1246 // getFillPaint()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1247 // getFillPaintTransformer()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1248 // getLabel()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1249 // getLine()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1250 // getLinePaint()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1251 // getLineStroke()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1252 // getOutlinePaint()
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3064
diff changeset
1253 // getOutlineStroke()
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1254 // Shape getShape()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1255 // String getToolTipText()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1256 // String getURLText()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1257 // boolean isLineVisible()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1258 // boolean isShapeFilled()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1259 // boolean isShapeOutlineVisible()
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1260 // boolean isShapeVisible()
2711
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1261 String hash = li.getLinePaint().toString();
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1262 String label = li.getLabel();
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1263 if (label.startsWith("W (") || label.startsWith("W(")) {
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1264 hash += "-W-";
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1265 }
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1266 else if (label.startsWith("Q(") || label.startsWith("Q (")) {
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1267 hash += "-Q-";
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1268 }
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1269
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1270 // WQ.java holds example of using regex Matcher/Pattern.
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1271
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1272 return hash;
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1273 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1274
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1275
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1276 /**
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1277 * Create a label for multiple items.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1278 *
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1279 * For example from "W(Q=100)" and "W(Q=220)"
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1280 * "W(Q= {100, 22})" would result.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1281 *
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1282 * @param items list of legenditems.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1283 * @return the merged label.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1284 */
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1285 public String mergeLegendNames(List<LegendItem> items) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1286 if (items.size() == 0) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1287 return null;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1288 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1289 if (items.size() == 1) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1290 return items.get(0).getLabel();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1291 }
2710
013882485011 Cosmetics (docs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2706
diff changeset
1292
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1293 // TODO consider using regionMathches for implementation.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1294 int lastMatchedChar = 0;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1295 boolean first = true;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1296 String startPattern = "";
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1297 String endPattern = "";
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1298 String name = "";
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1299 // First, figure out beginning and end patterns, then merge.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1300 for (LegendItem item : items) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1301 if (first) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1302 startPattern = item.getLabel();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1303 endPattern = item.getLabel();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1304 first = false;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1305 continue;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1306 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1307 while (startPattern.length() > 0 && !item.getLabel().startsWith(startPattern)) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1308 startPattern = startPattern.substring(0, startPattern.length() -1);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1309 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1310 while (endPattern.length() > 0 && !item.getLabel().endsWith(endPattern)) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1311 endPattern = endPattern.substring(1);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1312 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1313 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1314
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1315 // Then, merge.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1316 name = startPattern + " {";
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1317 first = true;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1318 for (LegendItem item : items) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1319 if (!first) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1320 name += ", ";
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1321 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1322 else {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1323 first = false;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1324 }
2711
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1325 // Possible case in differences
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1326 if (startPattern.length() + endPattern.length() < item.getLabel().length()) {
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1327 // Note that we do not really want this.
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1328 logger.error("Legend aggregation does not cover case: " +
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1329 startPattern + " -- " + item.getLabel() + " -- " + endPattern);
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1330 name += item.getLabel();
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1331 }
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1332 else {
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1333 name += item.getLabel().substring(startPattern.length(),
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1334 item.getLabel().length() - endPattern.length());
fa8ae7dbcb72 More stable legend item aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2710
diff changeset
1335 }
2584
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1336 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1337 name += "} ";
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1338 name += endPattern;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1339
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1340 return name;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1341 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1342
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1343
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1344 /**
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1345 * Create new legend entries, dependant on settings.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1346 * @param plot The plot for which to modify the legend.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1347 */
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1348 public void aggregateLegendEntries(XYPlot plot) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1349 LegendItemCollection old = plot.getLegendItems();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1350 // Find "similar" entries if aggregation is enabled.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1351
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1352 int maxListSize = 0;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1353 int AGGR_THRESHOLD = 2;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1354
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1355 HashMap<String, List<LegendItem>> entries = new LinkedHashMap<String, List<LegendItem>>();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1356 for (Iterator i = old.iterator(); i.hasNext();) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1357 LegendItem item = (LegendItem) i.next();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1358 String hash = legendItemHash(item);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1359 List<LegendItem> itemList = entries.get(hash);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1360 if (itemList == null) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1361 itemList = new ArrayList<LegendItem>();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1362 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1363 itemList.add(item);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1364
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1365 if (itemList.size() > maxListSize) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1366 maxListSize = itemList.size();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1367 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1368
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1369 entries.put(legendItemHash(item), itemList);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1370 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1371
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1372 if (maxListSize < AGGR_THRESHOLD) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1373 // No need to do anything.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1374 return;
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1375 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1376
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1377 // Run over collected entries, merge their names and create new
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1378 // entry if needed.
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1379 LegendItemCollection newLegend = new LegendItemCollection();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1380 for (Map.Entry<String, List<LegendItem>> cursor: entries.entrySet()) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1381 List<LegendItem> itemList = cursor.getValue();
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1382 if (itemList.size() >= AGGR_THRESHOLD) {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1383 // TODO now do merging
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1384 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1385 else {
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1386 // TODO create singular new entry
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1387 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1388
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1389 LegendItem item = (LegendItem) itemList.get(0);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1390 // Unfortunately we cannot clone and just setDescription, as this
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1391 // method was added in JFreeChart 1.0.14 (we are at .13).
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1392 LegendItem merged = new LegendItem(
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1393 mergeLegendNames(itemList), item.getDescription(), item.getToolTipText(),
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1394 item.getURLText(), item.isShapeVisible(), item.getShape(),
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1395 item.isShapeFilled(), item.getFillPaint(), item.isShapeOutlineVisible(),
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1396 item.getOutlinePaint(), item.getOutlineStroke(), item.isLineVisible(),
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1397 item.getLine(), item.getLineStroke(), item.getLinePaint());
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1398 newLegend.add(merged);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1399 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1400
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1401 plot.setFixedLegendItems (newLegend);
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1402 }
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1403
5d5457a1bd5f Stubby legend aggregation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2574
diff changeset
1404
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1405 /** Two Ranges that span a rectangular area. */
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1406 public static class Area {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1407 protected Range xRange;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1408 protected Range yRange;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1409
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1410 public Area(Range rangeX, Range rangeY) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1411 this.xRange = rangeX;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1412 this.yRange = rangeY;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1413 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1414
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1415 public Area(ValueAxis axisX, ValueAxis axisY) {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1416 this.xRange = axisX.getRange();
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1417 this.yRange = axisY.getRange();
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1418 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1419
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1420 public double ofLeft(double percent) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1421 return xRange.getLowerBound()
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1422 + xRange.getLength() * percent;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1423 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1424
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1425 public double ofRight(double percent) {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1426 return xRange.getUpperBound()
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1427 - xRange.getLength() * percent;
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1428 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1429
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1430 public double ofGround(double percent) {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1431 return yRange.getLowerBound()
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1432 + yRange.getLength() * percent;
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1433 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1434
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1435 public double atTop() {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1436 return yRange.getUpperBound();
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1437 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1438
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1439 public double atGround() {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1440 return yRange.getLowerBound();
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1441 }
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1442
2163
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1443 public double atRight() {
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1444 return xRange.getUpperBound();
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1445 }
105097966111 Theoretically allow annotations on second y ais. Practically allow Q MainValues on Q Axis in Duration Curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2161
diff changeset
1446
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1447 public double atLeft() {
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1448 return xRange.getLowerBound();
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1449 }
2193
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1450
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1451 public double above(double percent, double base) {
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1452 return base + yRange.getLength() * percent;
73490b828a90 Manual Point Theming improved.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2184
diff changeset
1453 }
2161
c68f4f227c09 Somewhat unified Annotation handling, use jfreechart-house-toolkit instead of custom StickyAxisAnnotation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2152
diff changeset
1454 }
369
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1455 }
2ce7b473620e Implemented the chart creation of a longitudinal section chart - W and Q facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1456 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org