comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java @ 2266:c9a40e3fdf16

Added a second Y axis for ReferenceCurveGenerator. flys-artifacts/trunk@3922 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 06 Feb 2012 13:20:00 +0000
parents bdd032bfd978
children 08bb95e1fc41
comparison
equal deleted inserted replaced
2265:1dad713412a7 2266:c9a40e3fdf16
28 public class ReferenceCurveGenerator 28 public class ReferenceCurveGenerator
29 extends XYChartGenerator 29 extends XYChartGenerator
30 implements FacetTypes 30 implements FacetTypes
31 { 31 {
32 public static enum YAXIS { 32 public static enum YAXIS {
33 W(0); 33 W_M(0),
34 W_CM(1);
35
34 public int idx; 36 public int idx;
35 private YAXIS(int c) { 37 private YAXIS(int c) {
36 idx = c; 38 idx = c;
37 } 39 }
38 } 40 }
39 41
42 /** House logger. */
40 private static Logger logger = 43 private static Logger logger =
41 Logger.getLogger(ReferenceCurveGenerator.class); 44 Logger.getLogger(ReferenceCurveGenerator.class);
42 45
43 public static final String I18N_CHART_TITLE = 46 public static final String I18N_CHART_TITLE =
44 "chart.reference.curve.title"; 47 "chart.reference.curve.title";
45 48
46 public static final String I18N_CHART_SUBTITLE = 49 public static final String I18N_CHART_SUBTITLE =
47 "chart.reference.curve.subtitle"; 50 "chart.reference.curve.subtitle";
51
52 public static final String W_CM_DEFAULT =
53 "chart.reference.curve.wcm";
54
55 public static final String W_NNM_DEFAULT =
56 "chart.reference.curve.wnn";
57
58 public static final String START_GAUGE =
59 "chart.reference.curve.start_at_gauge";
60
61 public static final String START_FREE =
62 "chart.reference.curve.start_free";
48 63
49 /* 64 /*
50 65
51 public static final String I18N_XAXIS_LABEL = 66 public static final String I18N_XAXIS_LABEL =
52 "chart.reference.curve.xaxis.label"; 67 "chart.reference.curve.xaxis.label";
53 68
54 public static final String I18N_YAXIS_LABEL = 69 public static final String I18N_YAXIS_LABEL =
55 "chart.reference.curve.yaxis.label"; 70 "chart.reference.curve.yaxis.label";
56 */ 71 */
57 public static final String I18N_CHART_TITLE_DEFAULT =
58 "Bezugslinie";
59 /* 72 /*
60 public static final String I18N_XAXIS_LABEL_DEFAULT = 73 public static final String I18N_XAXIS_LABEL_DEFAULT =
61 "W [NN+m]"; 74 "W [NN + m]";
62 75
63 public static final String I18N_YAXIS_LABEL_DEFAULT = 76 public static final String I18N_YAXIS_LABEL_DEFAULT =
64 "W [NN + m]"; 77 "W [NN + m]";
65 */ 78 */
79
80
81 public static final String I18N_CHART_TITLE_DEFAULT =
82 "Bezugslinie";
83
66 84
67 public ReferenceCurveGenerator() { 85 public ReferenceCurveGenerator() {
68 super(); 86 super();
69 } 87 }
70 88
77 protected NumberAxis createYAxis(int index) { 95 protected NumberAxis createYAxis(int index) {
78 Font labelFont = new Font("Tahoma", Font.BOLD, 14); 96 Font labelFont = new Font("Tahoma", Font.BOLD, 14);
79 String label = getYAxisLabel(index); 97 String label = getYAxisLabel(index);
80 98
81 NumberAxis axis = createNumberAxis(index, label); 99 NumberAxis axis = createNumberAxis(index, label);
82 if (index == YAXIS.W.idx) { 100 // TODO aspect-ratio settings.
101 if (index == YAXIS.W_M.idx) {
83 axis.setAutoRangeIncludesZero(false); 102 axis.setAutoRangeIncludesZero(false);
84 } 103 }
85 axis.setLabelFont(labelFont); 104 axis.setLabelFont(labelFont);
86 return axis; 105 return axis;
87 } 106 }
115 134
116 /** Get Label for X-axis (W). */ 135 /** Get Label for X-axis (W). */
117 @Override 136 @Override
118 protected String getDefaultXAxisLabel() { 137 protected String getDefaultXAxisLabel() {
119 // TODO i18nreturn msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); 138 // TODO i18nreturn msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
139 // at_gauge + w_cm
120 return "W am Bezugsort- oder Pegel."; 140 return "W am Bezugsort- oder Pegel.";
121 } 141 }
122 142
123 143
124 /** 144 /**
126 * @param index Axis-Index (0-based). 146 * @param index Axis-Index (0-based).
127 */ 147 */
128 @Override 148 @Override
129 protected String getDefaultYAxisLabel(int index) { 149 protected String getDefaultYAxisLabel(int index) {
130 String label = "default"; 150 String label = "default";
131 if (index == YAXIS.W.idx) { 151 if (index == YAXIS.W_M.idx) {
132 //label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); 152 //label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
133 //TODO i18n 153 //TODO i18n
134 return "W am Zielort oder -pegel"; 154 return "W am Zielort";
155 }
156 else if (index == YAXIS.W_CM.idx) {
157 return "W am Zielpegel";
135 } 158 }
136 159
137 return label; 160 return label;
138 } 161 }
139 162
167 return; 190 return;
168 } 191 }
169 } 192 }
170 193
171 194
195 /** Register DataSeries with (maybe transformed) points. */
172 public void doReferenceOut( 196 public void doReferenceOut(
173 Object data, 197 Object data,
174 Document theme, 198 Document theme,
175 boolean visible 199 boolean visible
176 ) { 200 ) {
189 while (iter.hasNext()) { 213 while (iter.hasNext()) {
190 iter.next(values); 214 iter.next(values);
191 series.add(values[0], values[1], false); 215 series.add(values[0], values[1], false);
192 } 216 }
193 217
194 addAxisSeries(series, YAXIS.W.idx, visible); 218 if (ww.endAtGauge()) {
219 addAxisSeries(series, YAXIS.W_M.idx, visible);
220 }
221 else {
222 addAxisSeries(series, YAXIS.W_CM.idx, visible);
223 }
195 } 224 }
196 225
197 226
198 /** Get Walker to iterate over all axes. */ 227 /** Get Walker to iterate over all axes. */
199 @Override 228 @Override

http://dive4elements.wald.intevation.org