Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java @ 1092:0eb585cd3882
Added limited themeing-support for MainValues.
flys-artifacts/trunk@2595 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 26 Aug 2011 12:44:12 +0000 |
parents | e298c4d28927 |
children | 1ea7eb72aaa6 |
comparison
equal
deleted
inserted
replaced
1091:7230e087ef8b | 1092:0eb585cd3882 |
---|---|
4 import java.util.ArrayList; | 4 import java.util.ArrayList; |
5 import java.util.List; | 5 import java.util.List; |
6 | 6 |
7 import org.w3c.dom.Document; | 7 import org.w3c.dom.Document; |
8 | 8 |
9 import java.awt.Color; | |
9 import org.jfree.chart.JFreeChart; | 10 import org.jfree.chart.JFreeChart; |
11 import org.jfree.chart.annotations.XYAnnotation; | |
10 import org.jfree.chart.title.TextTitle; | 12 import org.jfree.chart.title.TextTitle; |
13 import org.jfree.chart.plot.XYPlot; | |
11 import org.jfree.data.xy.XYSeries; | 14 import org.jfree.data.xy.XYSeries; |
12 import org.jfree.chart.axis.ValueAxis; | 15 import org.jfree.data.xy.XYSeriesCollection; |
13 import org.jfree.chart.plot.XYPlot; | |
14 import org.jfree.chart.annotations.XYAnnotation; | |
15 | 16 |
16 import de.intevation.artifacts.Artifact; | 17 import de.intevation.artifacts.Artifact; |
17 | 18 |
18 import de.intevation.artifactdatabase.state.Facet; | 19 import de.intevation.artifactdatabase.state.Facet; |
19 | 20 |
21 import de.intevation.flys.artifacts.model.NamedDouble; | 22 import de.intevation.flys.artifacts.model.NamedDouble; |
22 import de.intevation.flys.artifacts.model.FacetTypes; | 23 import de.intevation.flys.artifacts.model.FacetTypes; |
23 import de.intevation.flys.artifacts.model.WQKms; | 24 import de.intevation.flys.artifacts.model.WQKms; |
24 | 25 |
25 import de.intevation.flys.jfree.StickyAxisAnnotation; | 26 import de.intevation.flys.jfree.StickyAxisAnnotation; |
27 | |
28 import de.intevation.flys.utils.ThemeUtil; | |
26 | 29 |
27 | 30 |
28 /** | 31 /** |
29 * An OutGenerator that generates discharge curves. | 32 * An OutGenerator that generates discharge curves. |
30 * | 33 * |
48 public static final String I18N_YAXIS_LABEL = | 51 public static final String I18N_YAXIS_LABEL = |
49 "chart.computed.discharge.curve.yaxis.label"; | 52 "chart.computed.discharge.curve.yaxis.label"; |
50 | 53 |
51 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurve"; | 54 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurve"; |
52 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; | 55 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; |
56 public static final String I18N_MAINVALUES_Q_LABEL = "Q (Haupt- und Extremwerte)"; | |
57 public static final String I18N_MAINVALUES_W_LABEL = "W (Haupt- und Extremwerte)"; | |
53 | 58 |
54 /** List of Annotations (specifically, Main Values). */ | 59 /** List of Annotations (specifically, Main Values). */ |
55 protected List<XYAnnotation> annotations; | 60 protected List<XYAnnotation> annotations; |
56 | 61 |
57 // TODO Add pseudodataseries for having mainvalue-text in legend. | 62 /** Pseudo-Dataseries to have a legend for annotations. */ |
63 protected XYSeriesCollection pseudoAnnotationData = null; | |
64 | |
58 // TODO Let theme pass through to annotations-facets. | 65 // TODO Let theme pass through to annotations-facets. |
59 | 66 |
60 | 67 |
61 /** Trivial Constructor. */ | 68 /** Trivial Constructor. */ |
62 public ComputedDischargeCurveGenerator () { | 69 public ComputedDischargeCurveGenerator () { |
124 /** | 131 /** |
125 * Store W MainValues as annotations for later plotting. | 132 * Store W MainValues as annotations for later plotting. |
126 */ | 133 */ |
127 protected void doMainValueWAnnotations(Object o, Document theme) { | 134 protected void doMainValueWAnnotations(Object o, Document theme) { |
128 logger.debug("ComputedDischargeCurveGenerator set W MainValues."); | 135 logger.debug("ComputedDischargeCurveGenerator set W MainValues."); |
136 if (pseudoAnnotationData == null) { | |
137 pseudoAnnotationData = new XYSeriesCollection(); | |
138 } | |
139 | |
140 Color color = ThemeUtil.parseLineColorField(theme); | |
141 if (color == null) { | |
142 color = Color.black; | |
143 } | |
144 | |
129 List<NamedDouble> mainValuesW = (List<NamedDouble>) o; | 145 List<NamedDouble> mainValuesW = (List<NamedDouble>) o; |
130 for (NamedDouble mv: mainValuesW) { | 146 for (NamedDouble mv: mainValuesW) { |
131 float pos = (float) mv.getValue(); | 147 float pos = (float) mv.getValue(); |
132 String text = mv.getName(); | 148 String text = mv.getName(); |
133 StickyAxisAnnotation ta = new StickyAxisAnnotation(text, pos, | 149 StickyAxisAnnotation ta = new StickyAxisAnnotation(text, pos, |
134 StickyAxisAnnotation.SimpleAxis.Y_AXIS); | 150 StickyAxisAnnotation.SimpleAxis.Y_AXIS); |
135 logger.debug("Adding W: " + text + " : " + pos); | 151 ta.setPaint(color); |
136 this.annotations.add(ta); | 152 this.annotations.add(ta); |
137 } | 153 } |
154 String label = msg(I18N_MAINVALUES_W_LABEL, I18N_MAINVALUES_W_LABEL, null); | |
155 pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme)); | |
138 } | 156 } |
139 | 157 |
140 | 158 |
141 /** | 159 /** |
142 * Store Q MainValues as annotations for later plotting. | 160 * Store Q MainValues as annotations for later plotting. |
143 */ | 161 */ |
144 protected void doMainValueQAnnotations(Object o, Document theme) { | 162 protected void doMainValueQAnnotations(Object o, Document theme) { |
145 logger.debug("ComputedDischargeCurveGenerator set Q MainValues."); | 163 logger.debug("ComputedDischargeCurveGenerator set Q MainValues."); |
164 | |
165 Color color = ThemeUtil.parseLineColorField(theme); | |
166 if (color == null) { | |
167 color = Color.black; | |
168 } | |
169 | |
170 if (pseudoAnnotationData == null) { | |
171 pseudoAnnotationData = new XYSeriesCollection(); | |
172 } | |
173 | |
146 List<NamedDouble> mainValuesQ = (List<NamedDouble>) o; | 174 List<NamedDouble> mainValuesQ = (List<NamedDouble>) o; |
147 for (NamedDouble mv: mainValuesQ) { | 175 for (NamedDouble mv: mainValuesQ) { |
148 float pos = (float) mv.getValue(); | 176 float pos = (float) mv.getValue(); |
149 String text = mv.getName(); | 177 String text = mv.getName(); |
150 StickyAxisAnnotation ta = new StickyAxisAnnotation(text, pos); | 178 StickyAxisAnnotation ta = new StickyAxisAnnotation(text, pos); |
179 ta.setPaint(color); | |
151 this.annotations.add(ta); | 180 this.annotations.add(ta); |
152 } | 181 } |
182 String label = msg(I18N_MAINVALUES_Q_LABEL, I18N_MAINVALUES_Q_LABEL, null); | |
183 pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme)); | |
153 } | 184 } |
154 | 185 |
155 | 186 |
156 /** Generate Chart with annotations. */ | 187 /** Generate Chart with annotations. */ |
157 @Override | 188 @Override |
194 } | 225 } |
195 | 226 |
196 addFirstAxisSeries(series); | 227 addFirstAxisSeries(series); |
197 } | 228 } |
198 | 229 |
199 | 230 /** |
231 * Add datasets to plot. | |
232 * @param plot plot to add datasets to. | |
233 * @todo merge with LongitudinalSectionGenerator/superclass. | |
234 */ | |
235 @Override | |
236 protected void addDatasets(XYPlot plot) { | |
237 super.addDatasets(plot); | |
238 if (pseudoAnnotationData != null) { | |
239 plot.setDataset(2, pseudoAnnotationData); | |
240 } | |
241 } | |
242 | |
200 protected String getSeriesName(WQKms wqkms) { | 243 protected String getSeriesName(WQKms wqkms) { |
201 Object[] args = new Object[] { | 244 Object[] args = new Object[] { |
202 getRiverName(), | 245 getRiverName(), |
203 wqkms.getName() | 246 wqkms.getName() |
204 }; | 247 }; |