Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java @ 9431:eeea16ea0980
Added inverted attribute for y axis
author | mschaefer |
---|---|
date | Mon, 20 Aug 2018 09:42:32 +0200 |
parents | 740d65e4aa14 |
children | 9b8e8fc1f408 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5864
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5864
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3442
diff
changeset
|
9 package org.dive4elements.river.exports; |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
9312 | 11 import java.awt.Font; |
12 import java.awt.geom.Point2D; | |
13 | |
14 import org.apache.log4j.Logger; | |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3442
diff
changeset
|
15 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
16 import org.dive4elements.artifacts.CallContext; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3442
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3442
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.WQDay; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3442
diff
changeset
|
19 import org.dive4elements.river.jfree.Bounds; |
5864
f2e46a668fe6
River artifacts: Renamed FLYSAnnotation to RiverAnnotation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
20 import org.dive4elements.river.jfree.RiverAnnotation; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3442
diff
changeset
|
21 import org.dive4elements.river.jfree.StyledXYSeries; |
6905
1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
22 import org.dive4elements.river.themes.ThemeDocument; |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import org.jfree.chart.axis.NumberAxis; |
733
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
24 import org.jfree.chart.axis.ValueAxis; |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import org.jfree.chart.plot.XYPlot; |
733
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
26 import org.jfree.data.Range; |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 import org.jfree.data.xy.XYSeries; |
1850
0463e1f80bfd
Handle MainValue Facets in Duration Curve Diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1713
diff
changeset
|
28 |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * An OutGenerator that generates duration curves. |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 * |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 */ |
9312 | 34 public class DurationCurveGenerator extends XYChartGenerator implements FacetTypes { |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
35 public static enum YAXIS { |
9312 | 36 W(0), Q(1); |
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:
2074
diff
changeset
|
37 public int idx; |
9312 | 38 |
39 private YAXIS(final int c) { | |
40 this.idx = c; | |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
41 } |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
42 } |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
43 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
44 /** Local log. */ |
9312 | 45 private static Logger log = Logger.getLogger(DurationCurveGenerator.class); |
408
fc3ac59c3c8b
Enabled i18n support for charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
46 |
9312 | 47 public static final String I18N_CHART_TITLE = "chart.duration.curve.title"; |
408
fc3ac59c3c8b
Enabled i18n support for charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
48 |
9312 | 49 public static final String I18N_CHART_SUBTITLE = "chart.duration.curve.subtitle"; |
408
fc3ac59c3c8b
Enabled i18n support for charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
50 |
9312 | 51 public static final String I18N_XAXIS_LABEL = "chart.duration.curve.xaxis.label"; |
408
fc3ac59c3c8b
Enabled i18n support for charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
52 |
9312 | 53 public static final String I18N_YAXIS_LABEL_W = "chart.duration.curve.yaxis.label.w"; |
54 | |
55 public static final String I18N_YAXIS_LABEL_Q = "common.export.csv.header.q"; | |
56 | |
57 public static final String I18N_CHART_TITLE_DEFAULT = "Dauerlinie"; | |
58 | |
59 public static final String I18N_XAXIS_LABEL_DEFAULT = "Unterschreitungsdauer [Tage]"; | |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 public DurationCurveGenerator() { |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 super(); |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
65 /** |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
66 * Create Axis for given index. |
9312 | 67 * |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
68 * @return axis with according internationalized label. |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
69 */ |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
70 @Override |
9312 | 71 protected NumberAxis createYAxis(final int index) { |
72 final Font labelFont = new Font("Tahoma", Font.BOLD, 14); | |
73 final String label = getYAxisLabel(index); | |
2000
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
74 |
9312 | 75 final NumberAxis axis = createNumberAxis(index, label); |
1951
2c9bf9aede64
Fix first axis (do not include zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1948
diff
changeset
|
76 if (index == YAXIS.W.idx) { |
2c9bf9aede64
Fix first axis (do not include zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1948
diff
changeset
|
77 axis.setAutoRangeIncludesZero(false); |
2c9bf9aede64
Fix first axis (do not include zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1948
diff
changeset
|
78 } |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
79 axis.setLabelFont(labelFont); |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
80 return axis; |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
81 } |
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
82 |
2048
3157a78e6494
Improved chart title and subtitle creation in ChartGenerators - all ChartGenerators make now use of title and subtitle provided by ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2000
diff
changeset
|
83 @Override |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
84 protected String getDefaultChartTitle(final CallContext context) { |
408
fc3ac59c3c8b
Enabled i18n support for charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
85 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
414
0385bcc4229a
Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
88 @Override |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
89 protected String getDefaultChartSubtitle(final CallContext context) { |
9312 | 90 final double[] dist = getRange(); |
414
0385bcc4229a
Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
91 |
9312 | 92 final Object[] args = new Object[] { getRiverName(), dist[0] }; |
414
0385bcc4229a
Added subtitles to the available charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
93 |
1989
156304542edf
Finished the ChartSection part of the chart Settings returned by the XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1951
diff
changeset
|
94 return msg(I18N_CHART_SUBTITLE, "", args); |
156304542edf
Finished the ChartSection part of the chart Settings returned by the XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1951
diff
changeset
|
95 } |
156304542edf
Finished the ChartSection part of the chart Settings returned by the XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1951
diff
changeset
|
96 |
156304542edf
Finished the ChartSection part of the chart Settings returned by the XYChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1951
diff
changeset
|
97 @Override |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
98 protected String getDefaultXAxisLabel(final CallContext context) { |
408
fc3ac59c3c8b
Enabled i18n support for charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
99 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
2000
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
102 @Override |
9312 | 103 protected String getDefaultYAxisLabel(final int index) { |
2000
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
104 String label = "default"; |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
105 if (index == YAXIS.W.idx) { |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
106 label = msg(I18N_YAXIS_LABEL_W, I18N_YAXIS_LABEL_W, new Object[] { getRiverUnit() }); |
9312 | 107 } else if (index == YAXIS.Q.idx) { |
8248
2b0ff11cef3f
Fix duration curve i18n.
Tom Gottfried <tom@intevation.de>
parents:
8202
diff
changeset
|
108 label = msg(I18N_YAXIS_LABEL_Q); |
2000
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
109 } |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
110 |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
111 return label; |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
112 } |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
113 |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
114 @Override |
9312 | 115 protected boolean zoomX(final XYPlot plot, final ValueAxis axis, final Bounds bounds, final Range x) { |
116 final boolean zoomin = super.zoom(plot, axis, bounds, x); | |
733
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
117 |
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
118 if (!zoomin) { |
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
119 axis.setLowerBound(0d); |
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
120 } |
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
121 |
1713
6d9184c745dd
Bugfix: #226 Set the upper bound of duration curve charts to 364.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1684
diff
changeset
|
122 axis.setUpperBound(364); |
6d9184c745dd
Bugfix: #226 Set the upper bound of duration curve charts to 364.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1684
diff
changeset
|
123 |
733
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
124 return zoomin; |
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
125 } |
5f5e67aceb8c
#172 Charts of type duration curve will now have a lower X set to '0'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
704
diff
changeset
|
126 |
2421
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
127 /** |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
128 * This method overrides the method in the parent class to set the lower |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
129 * bounds of the Q axis to 0. This axis should never display negative |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
130 * values on its own. |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
131 */ |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
132 @Override |
9312 | 133 protected boolean zoomY(final XYPlot plot, final ValueAxis axis, final Bounds bounds, final Range x) { |
134 final boolean zoomin = super.zoom(plot, axis, bounds, x); | |
2421
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
135 |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
136 if (!zoomin && axis instanceof IdentifiableNumberAxis) { |
9312 | 137 final String id = ((IdentifiableNumberAxis) axis).getId(); |
2421
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
138 |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
139 if (YAXIS.Q.toString().equals(id)) { |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
140 axis.setLowerBound(0d); |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
141 } |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
142 } |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
143 |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
144 return zoomin; |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
145 } |
59047dfed8be
Picked rev4061 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2325
diff
changeset
|
146 |
695
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
686
diff
changeset
|
147 @Override |
9312 | 148 public void doOut(final ArtifactAndFacet artifactFacet, final ThemeDocument attr, final boolean visible) { |
149 final String name = artifactFacet.getFacetName(); | |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
151 log.debug("DurationCurveGenerator.doOut: " + name); |
695
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
686
diff
changeset
|
152 |
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
686
diff
changeset
|
153 if (name == null || name.length() == 0) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
154 log.error("No facet given. Cannot create dataset."); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 return; |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 } |
9312 | 157 |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
8856
diff
changeset
|
158 final CallContext context = getContext(); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 |
696
708b270dfd30
OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
695
diff
changeset
|
160 if (name.equals(DURATION_W)) { |
9312 | 161 doWOut((WQDay) artifactFacet.getData(context), artifactFacet, attr, visible); |
162 } else if (name.equals(DURATION_Q)) { | |
163 doQOut((WQDay) artifactFacet.getData(context), artifactFacet, attr, visible); | |
164 } else if (name.equals(MAINVALUES_Q) || name.equals(MAINVALUES_W)) { | |
165 doAnnotations((RiverAnnotation) artifactFacet.getData(context), artifactFacet, attr, visible); | |
166 } else if (name.equals(RELATIVE_POINT)) { | |
167 doPointOut((Point2D) artifactFacet.getData(context), artifactFacet, attr, visible); | |
168 } else if (FacetTypes.IS.MANUALPOINTS(name)) { | |
169 doPoints(artifactFacet.getData(context), artifactFacet, attr, visible, YAXIS.W.idx); | |
170 } else { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
171 log.warn("Unknown facet name: " + name); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 return; |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 /** |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 * Creates the series for a duration curve's W facet. |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 * |
9312 | 179 * @param wqdays |
180 * The WQDay store that contains the Ws. | |
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
|
181 * @param theme |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 */ |
9312 | 183 protected void doWOut(final WQDay wqdays, final ArtifactAndFacet aaf, final ThemeDocument theme, final boolean visible) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
184 log.debug("DurationCurveGenerator.doWOut"); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 |
9312 | 186 final XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 |
9312 | 188 final int size = wqdays.size(); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 for (int i = 0; i < size; i++) { |
9312 | 190 final int day = wqdays.getDay(i); |
191 final double w = wqdays.getW(i); | |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 |
3409
97ad960f5579
Add subtitle to Fix W/Q chart and refactor addSubtitle() method(s)
Christian Lins <christian.lins@intevation.de>
parents:
2750
diff
changeset
|
193 series.add(day, w); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
196 addAxisSeries(series, YAXIS.W.idx, visible); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 |
9312 | 199 protected void doPointOut(final Point2D point, final ArtifactAndFacet aandf, final ThemeDocument theme, final boolean visible) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
200 log.debug("DurationCurveGenerator.doPointOut"); |
2750
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
201 |
9312 | 202 final XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); |
2750
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
203 |
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
204 series.add(point.getX(), point.getY()); |
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
205 |
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
206 addAxisSeries(series, YAXIS.W.idx, visible); |
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
207 } |
97cb098dbf7a
Handle relative points in duration curve diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2699
diff
changeset
|
208 |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 /** |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 * Creates the series for a duration curve's Q facet. |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 * |
9312 | 212 * @param wqdays |
213 * The WQDay store that contains the Qs. | |
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
|
214 * @param theme |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 */ |
9312 | 216 protected void doQOut(final WQDay wqdays, final ArtifactAndFacet aaf, final ThemeDocument theme, final boolean visible) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6905
diff
changeset
|
217 log.debug("DurationCurveGenerator.doQOut"); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 |
9312 | 219 final XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 |
9312 | 221 final int size = wqdays.size(); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
222 for (int i = 0; i < size; i++) { |
9312 | 223 final int day = wqdays.getDay(i); |
224 final double q = wqdays.getQ(i); | |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 |
3409
97ad960f5579
Add subtitle to Fix W/Q chart and refactor addSubtitle() method(s)
Christian Lins <christian.lins@intevation.de>
parents:
2750
diff
changeset
|
226 series.add(day, q); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 |
1933
9e9cfc036a3f
Better use multiple axis feature in chart generators.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1931
diff
changeset
|
229 addAxisSeries(series, YAXIS.Q.idx, visible); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 |
2000
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
232 @Override |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
233 protected YAxisWalker getYAxisWalker() { |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
234 return new YAxisWalker() { |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
235 @Override |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
236 public int length() { |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
237 return YAXIS.values().length; |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
238 } |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
239 |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
240 @Override |
9312 | 241 public String getId(final int idx) { |
242 final YAXIS[] yaxes = YAXIS.values(); | |
2000
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
243 return yaxes[idx].toString(); |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
244 } |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
245 }; |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
246 } |
e71719483546
Improved the ChartSettings - now, each chart writes proper AxisSections into the ChartSettings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1989
diff
changeset
|
247 |
8856 | 248 // MainValue-Annotations should be visualized by |
249 // a line that goes to the curve itself. | |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
251 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |