Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java @ 1933:9e9cfc036a3f
Better use multiple axis feature in chart generators.
flys-artifacts/trunk@3314 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 24 Nov 2011 11:03:33 +0000 |
parents | 7c52e9cb2a72 |
children | 21a4d2c677a1 |
comparison
equal
deleted
inserted
replaced
1932:17e18948fe5e | 1933:9e9cfc036a3f |
---|---|
1 package de.intevation.flys.exports; | 1 package de.intevation.flys.exports; |
2 | |
3 import java.awt.Font; | |
2 | 4 |
3 import org.w3c.dom.Document; | 5 import org.w3c.dom.Document; |
4 | 6 |
5 import org.apache.log4j.Logger; | 7 import org.apache.log4j.Logger; |
6 | 8 |
31 */ | 33 */ |
32 public class DurationCurveGenerator | 34 public class DurationCurveGenerator |
33 extends XYChartGenerator | 35 extends XYChartGenerator |
34 implements FacetTypes | 36 implements FacetTypes |
35 { | 37 { |
38 public static enum YAXIS { | |
39 W(0), | |
40 Q(1); | |
41 protected int idx; | |
42 private YAXIS(int c) { | |
43 idx = c; | |
44 } | |
45 } | |
46 | |
36 private static Logger logger = | 47 private static Logger logger = |
37 Logger.getLogger(DurationCurveGenerator.class); | 48 Logger.getLogger(DurationCurveGenerator.class); |
38 | 49 |
39 | |
40 public static final String I18N_DURATION_W = | 50 public static final String I18N_DURATION_W = |
41 "chart.duration.curve.curve.w"; | 51 "chart.duration.curve.curve.w"; |
42 | 52 |
43 public static final String I18N_DURATION_Q = | 53 public static final String I18N_DURATION_Q = |
44 "chart.duration.curve.curve.q"; | 54 "chart.duration.curve.curve.q"; |
67 | 77 |
68 public DurationCurveGenerator() { | 78 public DurationCurveGenerator() { |
69 super(); | 79 super(); |
70 } | 80 } |
71 | 81 |
82 | |
83 /** | |
84 * Create Axis for given index. | |
85 * @return axis with according internationalized label. | |
86 */ | |
87 @Override | |
88 protected NumberAxis createYAxis(int index) { | |
89 Font labelFont = new Font("Tahoma", Font.BOLD, 14); | |
90 String label = "default"; | |
91 if (index == YAXIS.W.idx) { | |
92 label = getYAxisLabel(); | |
93 } | |
94 else if (index == YAXIS.Q.idx) { | |
95 // TODO i18n for this label | |
96 label = "Q [m\u00b3/s]"; | |
97 //label = msg(get2YAxisLabelKey(), get2YAxisDefaultLabel()); | |
98 } | |
99 NumberAxis axis = new NumberAxis(label); | |
100 axis.setLabelFont(labelFont); | |
101 return axis; | |
102 } | |
72 | 103 |
73 protected String getChartTitle() { | 104 protected String getChartTitle() { |
74 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 105 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
75 } | 106 } |
76 | 107 |
108 } | 139 } |
109 | 140 |
110 axis.setUpperBound(364); | 141 axis.setUpperBound(364); |
111 | 142 |
112 return zoomin; | 143 return zoomin; |
113 } | |
114 | |
115 | |
116 protected void adjustAxes(XYPlot plot) { | |
117 super.adjustAxes(plot); | |
118 | |
119 NumberAxis qAxis = new NumberAxis("Q [m\u00b3/s]"); | |
120 | |
121 plot.setRangeAxis(1, qAxis); | |
122 } | 144 } |
123 | 145 |
124 | 146 |
125 @Override | 147 @Override |
126 public void doOut( | 148 public void doOut( |
182 double w = wqdays.getW(i); | 204 double w = wqdays.getW(i); |
183 | 205 |
184 series.add((double) day, w); | 206 series.add((double) day, w); |
185 } | 207 } |
186 | 208 |
187 addAxisSeries(series, 0, visible); | 209 addAxisSeries(series, YAXIS.W.idx, visible); |
188 } | 210 } |
189 | 211 |
190 | 212 |
191 /** | 213 /** |
192 * Creates the series for a duration curve's Q facet. | 214 * Creates the series for a duration curve's Q facet. |
207 double q = wqdays.getQ(i); | 229 double q = wqdays.getQ(i); |
208 | 230 |
209 series.add((double) day, q); | 231 series.add((double) day, q); |
210 } | 232 } |
211 | 233 |
212 addAxisSeries(series, 1, visible); | 234 addAxisSeries(series, YAXIS.Q.idx, visible); |
213 } | 235 } |
214 | 236 |
215 | 237 |
216 protected String getSeriesName(String river, String type) { | 238 protected String getSeriesName(String river, String type) { |
217 Object[] args = new Object[] { river }; | 239 Object[] args = new Object[] { river }; |