Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 1953:590d9bc88ff5
Refactored LongitudinalSection- and WDiff-Generators, fixed minor issues.
flys-artifacts/trunk@3349 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 05 Dec 2011 09:24:12 +0000 |
parents | 65f9d707caff |
children | 156304542edf |
comparison
equal
deleted
inserted
replaced
1952:8dafae465c91 | 1953:590d9bc88ff5 |
---|---|
11 import org.jfree.chart.plot.XYPlot; | 11 import org.jfree.chart.plot.XYPlot; |
12 import org.jfree.data.xy.XYSeries; | 12 import org.jfree.data.xy.XYSeries; |
13 | 13 |
14 import org.w3c.dom.Document; | 14 import org.w3c.dom.Document; |
15 | 15 |
16 import de.intevation.artifactdatabase.state.ArtifactAndFacet; | |
16 import de.intevation.artifactdatabase.state.Facet; | 17 import de.intevation.artifactdatabase.state.Facet; |
17 | 18 |
18 import de.intevation.flys.artifacts.FLYSArtifact; | 19 import de.intevation.flys.artifacts.FLYSArtifact; |
19 | 20 |
20 import de.intevation.flys.artifacts.model.FacetTypes; | 21 import de.intevation.flys.artifacts.model.FacetTypes; |
21 import de.intevation.flys.artifacts.model.WKms; | 22 import de.intevation.flys.artifacts.model.WKms; |
22 import de.intevation.flys.artifacts.model.WQKms; | 23 import de.intevation.flys.artifacts.model.WQKms; |
23 | 24 |
24 import de.intevation.flys.jfree.FLYSAnnotation; | 25 import de.intevation.flys.jfree.FLYSAnnotation; |
25 | |
26 import de.intevation.artifactdatabase.state.ArtifactAndFacet; | |
27 | 26 |
28 import de.intevation.flys.utils.FLYSUtils; | 27 import de.intevation.flys.utils.FLYSUtils; |
29 import de.intevation.flys.utils.DataUtil; | 28 import de.intevation.flys.utils.DataUtil; |
30 | 29 |
31 | 30 |
36 */ | 35 */ |
37 public class LongitudinalSectionGenerator | 36 public class LongitudinalSectionGenerator |
38 extends XYChartGenerator | 37 extends XYChartGenerator |
39 implements FacetTypes | 38 implements FacetTypes |
40 { | 39 { |
41 public static enum YAXIS { | 40 public enum YAXIS { |
42 W(0), | 41 W(0), |
43 Q(1), | 42 Q(1), |
44 D(2); | 43 D(2); |
45 protected int idx; | 44 protected int idx; |
46 private YAXIS(int c) { | 45 private YAXIS(int c) { |
82 public static final String I18N_CHART_TITLE_DEFAULT = "W-L\u00e4ngsschnitt"; | 81 public static final String I18N_CHART_TITLE_DEFAULT = "W-L\u00e4ngsschnitt"; |
83 public static final String I18N_XAXIS_LABEL_DEFAULT = "km"; | 82 public static final String I18N_XAXIS_LABEL_DEFAULT = "km"; |
84 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; | 83 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; |
85 public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; | 84 public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; |
86 | 85 |
86 public final static String I18N_WDIFF_YAXIS_LABEL = | |
87 "chart.w_differences.yaxis.label"; | |
88 | |
89 public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m"; | |
90 | |
87 /** Whether or not the plot is inverted (left-right). */ | 91 /** Whether or not the plot is inverted (left-right). */ |
88 protected boolean inverted; | 92 protected boolean inverted; |
89 | 93 |
90 | 94 |
91 public LongitudinalSectionGenerator() { | 95 public LongitudinalSectionGenerator() { |
152 I18N_XAXIS_LABEL_DEFAULT, | 156 I18N_XAXIS_LABEL_DEFAULT, |
153 new Object[] { FLYSUtils.getRiver(flys).getName() }); | 157 new Object[] { FLYSUtils.getRiver(flys).getName() }); |
154 } | 158 } |
155 | 159 |
156 | 160 |
161 @Override | |
162 protected String getYAxisLabel() { | |
163 return getWAxisLabel(); | |
164 } | |
165 | |
157 /** | 166 /** |
158 * Get internationalized label for the y axis. | 167 * Get internationalized label for the y axis. |
159 */ | 168 */ |
160 protected String getYAxisLabel() { | 169 protected String getWAxisLabel() { |
161 FLYSArtifact flys = (FLYSArtifact) master; | 170 FLYSArtifact flys = (FLYSArtifact) master; |
162 | 171 |
163 String unit = FLYSUtils.getRiver(flys).getWstUnit().getName(); | 172 String unit = FLYSUtils.getRiver(flys).getWstUnit().getName(); |
164 | 173 |
165 return msg( | 174 return msg( |
176 @Override | 185 @Override |
177 protected NumberAxis createYAxis(int index) { | 186 protected NumberAxis createYAxis(int index) { |
178 Font labelFont = new Font("Tahoma", Font.BOLD, 14); | 187 Font labelFont = new Font("Tahoma", Font.BOLD, 14); |
179 String label = "default"; | 188 String label = "default"; |
180 if (index == YAXIS.W.idx) { | 189 if (index == YAXIS.W.idx) { |
181 label = getYAxisLabel(); | 190 label = getWAxisLabel(); |
182 } | 191 } |
183 else if (index == YAXIS.Q.idx) { | 192 else if (index == YAXIS.Q.idx) { |
184 label = msg(get2YAxisLabelKey(), get2YAxisDefaultLabel()); | 193 label = msg(getQAxisLabelKey(), getQAxisDefaultLabel()); |
185 } | 194 } |
186 else if (index == YAXIS.D.idx) { | 195 else if (index == YAXIS.D.idx) { |
187 // TODO: diff label | 196 label = msg(I18N_WDIFF_YAXIS_LABEL, I18N_WDIFF_YAXIS_LABEL_DEFAULT); |
188 label = "TODO: diff"; | |
189 } | 197 } |
190 NumberAxis axis = new NumberAxis(label); | 198 NumberAxis axis = new NumberAxis(label); |
191 // "Q" Axis shall include 0. | 199 // "Q" Axis shall include 0. |
192 if (index == YAXIS.Q.idx) { | 200 if (index == YAXIS.Q.idx) { |
193 axis.setAutoRangeIncludesZero(true); | 201 axis.setAutoRangeIncludesZero(true); |
201 | 209 |
202 /** | 210 /** |
203 * Get default value for the second Y-Axis' label (if no translation was | 211 * Get default value for the second Y-Axis' label (if no translation was |
204 * found). | 212 * found). |
205 */ | 213 */ |
206 protected String get2YAxisDefaultLabel() { | 214 protected String getQAxisDefaultLabel() { |
207 return I18N_2YAXIS_LABEL_DEFAULT; | 215 return I18N_2YAXIS_LABEL_DEFAULT; |
208 } | 216 } |
209 | 217 |
210 | 218 |
211 /** | 219 /** |
212 * Get key for internationalization of the second Y-Axis' label. | 220 * Get key for internationalization of the second Y-Axis' label. |
213 */ | 221 */ |
214 protected String get2YAxisLabelKey() { | 222 protected String getQAxisLabelKey() { |
215 return I18N_2YAXIS_LABEL; | 223 return I18N_2YAXIS_LABEL; |
216 } | 224 } |
217 | 225 |
218 | 226 |
219 /** | 227 /** |