comparison artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java @ 8996:fb9430250899

Work on uinfo
author gernotbelger
date Thu, 12 Apr 2018 19:13:39 +0200
parents 322b0e6298ea
children 7134a4c7d1b6
comparison
equal deleted inserted replaced
8995:8c3e5682cb60 8996:fb9430250899
16 16
17 import org.dive4elements.artifacts.CallContext; 17 import org.dive4elements.artifacts.CallContext;
18 import org.dive4elements.artifacts.CallMeta; 18 import org.dive4elements.artifacts.CallMeta;
19 import org.dive4elements.river.artifacts.resources.Resources; 19 import org.dive4elements.river.artifacts.resources.Resources;
20 20
21
22 /** Helper to access static i18n Formatters. */ 21 /** Helper to access static i18n Formatters. */
23 public final class Formatter { 22 public final class Formatter {
24 23
25 // KMS IN ERROR REPORTS. 24 // KMS IN ERROR REPORTS.
26 public static final int CALCULATION_REPORT_KM_MIN_DIGITS = 1; 25 public static final int CALCULATION_REPORT_KM_MIN_DIGITS = 1;
27 public static final int CALCULATION_REPORT_KM_MAX_DIGITS = 3; 26 public static final int CALCULATION_REPORT_KM_MAX_DIGITS = 3;
28 27
29 // WATERLEVEL FORMATTER CONSTANTS 28 // WATERLEVEL FORMATTER CONSTANTS
30 public static final int WATERLEVEL_KM_MIN_DIGITS = 3; 29 public static final int WATERLEVEL_KM_MIN_DIGITS = 3;
31 public static final int WATERLEVEL_KM_MAX_DIGITS = 3; 30 public static final int WATERLEVEL_KM_MAX_DIGITS = 3;
32 public static final int WATERLEVEL_W_MIN_DIGITS = 0; 31 public static final int WATERLEVEL_W_MIN_DIGITS = 0;
33 public static final int WATERLEVEL_W_MAX_DIGITS = 2; 32 public static final int WATERLEVEL_W_MAX_DIGITS = 2;
34 public static final int WATERLEVEL_Q_MIN_DIGITS = 0; 33 public static final int WATERLEVEL_Q_MIN_DIGITS = 0;
35 public static final int WATERLEVEL_Q_MAX_DIGITS = 2; 34 public static final int WATERLEVEL_Q_MAX_DIGITS = 2;
36
37 35
38 // COMPUTED DISCHARGE CURVE FORMATTER CONSTANTS 36 // COMPUTED DISCHARGE CURVE FORMATTER CONSTANTS
39 public static final int COMPUTED_DISCHARGE_W_MIN_DIGITS = 2; 37 public static final int COMPUTED_DISCHARGE_W_MIN_DIGITS = 2;
40 public static final int COMPUTED_DISCHARGE_W_MAX_DIGITS = 2; 38 public static final int COMPUTED_DISCHARGE_W_MAX_DIGITS = 2;
41 public static final int COMPUTED_DISCHARGE_Q_MIN_DIGITS = 0; 39 public static final int COMPUTED_DISCHARGE_Q_MIN_DIGITS = 0;
42 public static final int COMPUTED_DISCHARGE_Q_MAX_DIGITS = 2; 40 public static final int COMPUTED_DISCHARGE_Q_MAX_DIGITS = 2;
43
44 41
45 // HISTORICAL DISCHARGE CURVE FORMATTER CONSTANTS 42 // HISTORICAL DISCHARGE CURVE FORMATTER CONSTANTS
46 public static final int HISTORICAL_DISCHARGE_W_MIN_DIGITS = 0; 43 public static final int HISTORICAL_DISCHARGE_W_MIN_DIGITS = 0;
47 public static final int HISTORICAL_DISCHARGE_W_MAX_DIGITS = 2; 44 public static final int HISTORICAL_DISCHARGE_W_MAX_DIGITS = 2;
48 public static final int HISTORICAL_DISCHARGE_Q_MIN_DIGITS = 0; 45 public static final int HISTORICAL_DISCHARGE_Q_MIN_DIGITS = 0;
49 public static final int HISTORICAL_DISCHARGE_Q_MAX_DIGITS = 2; 46 public static final int HISTORICAL_DISCHARGE_Q_MAX_DIGITS = 2;
50
51 47
52 // DURATION CURVE FORMATTER CONSTANTS 48 // DURATION CURVE FORMATTER CONSTANTS
53 public static final int DURATION_W_MIN_DIGITS = 0; 49 public static final int DURATION_W_MIN_DIGITS = 0;
54 public static final int DURATION_W_MAX_DIGITS = 2; 50 public static final int DURATION_W_MAX_DIGITS = 2;
55 public static final int DURATION_Q_MIN_DIGITS = 0; 51 public static final int DURATION_Q_MIN_DIGITS = 0;
56 public static final int DURATION_Q_MAX_DIGITS = 1; 52 public static final int DURATION_Q_MAX_DIGITS = 1;
57 public static final int DURATION_D_MIN_DIGITS = 0; 53 public static final int DURATION_D_MIN_DIGITS = 0;
58 public static final int DURATION_D_MAX_DIGITS = 0; 54 public static final int DURATION_D_MAX_DIGITS = 0;
59 55
60
61 // FLOW VELOCITY FORMATTER CONSTANTS 56 // FLOW VELOCITY FORMATTER CONSTANTS
62 public static final int FLOW_VELOCITY_KM_MIN_DIGITS = 3; 57 public static final int FLOW_VELOCITY_KM_MIN_DIGITS = 3;
63 public static final int FLOW_VELOCITY_KM_MAX_DIGITS = 3; 58 public static final int FLOW_VELOCITY_KM_MAX_DIGITS = 3;
64 public static final int FLOW_VELOCITY_VALUES_MIN_DIGITS = 2; 59 public static final int FLOW_VELOCITY_VALUES_MIN_DIGITS = 2;
65 public static final int FLOW_VELOCITY_VALUES_MAX_DIGITS = 2; 60 public static final int FLOW_VELOCITY_VALUES_MAX_DIGITS = 2;
66 public static final int FLOW_VELOCITY_Q_MIN_DIGITS = 0; 61 public static final int FLOW_VELOCITY_Q_MIN_DIGITS = 0;
67 public static final int FLOW_VELOCITY_Q_MAX_DIGITS = 2; 62 public static final int FLOW_VELOCITY_Q_MAX_DIGITS = 2;
68
69 63
70 // MIDDLE BED HEIGHT FORMATTER CONSTANTS 64 // MIDDLE BED HEIGHT FORMATTER CONSTANTS
71 public static final int MIDDLE_BED_HEIGHT_KM_MIN_DIGITS = 3; 65 public static final int MIDDLE_BED_HEIGHT_KM_MIN_DIGITS = 3;
72 public static final int MIDDLE_BED_HEIGHT_KM_MAX_DIGITS = 3; 66 public static final int MIDDLE_BED_HEIGHT_KM_MAX_DIGITS = 3;
73 public static final int MIDDLE_BED_HEIGHT_HEIGHT_MIN_DIGITS = 3; 67 public static final int MIDDLE_BED_HEIGHT_HEIGHT_MIN_DIGITS = 3;
74 public static final int MIDDLE_BED_HEIGHT_HEIGHT_MAX_DIGITS = 3; 68 public static final int MIDDLE_BED_HEIGHT_HEIGHT_MAX_DIGITS = 3;
75 public static final int MIDDLE_BED_HEIGHT_UNCERT_MIN_DIGITS = 3; 69 public static final int MIDDLE_BED_HEIGHT_UNCERT_MIN_DIGITS = 3;
76 public static final int MIDDLE_BED_HEIGHT_UNCERT_MAX_DIGITS = 3; 70 public static final int MIDDLE_BED_HEIGHT_UNCERT_MAX_DIGITS = 3;
77 public static final int MIDDLE_BED_HEIGHT_DATAGAP_MIN_DIGITS = 2; 71 public static final int MIDDLE_BED_HEIGHT_DATAGAP_MIN_DIGITS = 2;
78 public static final int MIDDLE_BED_HEIGHT_DATAGAP_MAX_DIGITS = 2; 72 public static final int MIDDLE_BED_HEIGHT_DATAGAP_MAX_DIGITS = 2;
79 public static final int MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MIN_DIGITS = 0; 73 public static final int MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MIN_DIGITS = 0;
80 public static final int MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MAX_DIGITS = 0; 74 public static final int MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MAX_DIGITS = 0;
81 public static final int MIDDLE_BED_HEIGHT_WIDTH_MIN_DIGITS = 3; 75 public static final int MIDDLE_BED_HEIGHT_WIDTH_MIN_DIGITS = 3;
82 public static final int MIDDLE_BED_HEIGHT_WIDTH_MAX_DIGITS = 3; 76 public static final int MIDDLE_BED_HEIGHT_WIDTH_MAX_DIGITS = 3;
83 77
84 public static final int FIX_DELTA_W_KM_MIN_DIGITS = 3; 78 public static final int FIX_DELTA_W_KM_MIN_DIGITS = 3;
85 public static final int FIX_DELTA_W_KM_MAX_DIGITS = 3; 79 public static final int FIX_DELTA_W_KM_MAX_DIGITS = 3;
86 public static final int FIX_DELTA_W_DELTA_W_MIN_DIGITS = 3; 80 public static final int FIX_DELTA_W_DELTA_W_MIN_DIGITS = 3;
87 public static final int FIX_DELTA_W_DELTA_W_MAX_DIGITS = 3; 81 public static final int FIX_DELTA_W_DELTA_W_MAX_DIGITS = 3;
88 public static final int FIX_DELTA_W_DELTA_Q_MIN_DIGITS = 0; 82 public static final int FIX_DELTA_W_DELTA_Q_MIN_DIGITS = 0;
89 public static final int FIX_DELTA_W_DELTA_Q_MAX_DIGITS = 2; 83 public static final int FIX_DELTA_W_DELTA_Q_MAX_DIGITS = 2;
90 84
91 public static final int VARIANCE_MIN_DIGITS = 3; 85 public static final int VARIANCE_MIN_DIGITS = 3;
92 public static final int VARIANCE_MAX_DIGITS = 3; 86 public static final int VARIANCE_MAX_DIGITS = 3;
93 87
94 // SQ Relation 88 // SQ Relation
95 public static final int SQ_RELATION_KM_MIN_DIGITS = 2; 89 public static final int SQ_RELATION_KM_MIN_DIGITS = 2;
96 public static final int SQ_RELATION_KM_MAX_DIGITS = 2; 90 public static final int SQ_RELATION_KM_MAX_DIGITS = 2;
97 public static final int SQ_RELATION_A_MAX_DIGITS = 2; 91 public static final int SQ_RELATION_A_MAX_DIGITS = 2;
98 public static final int SQ_RELATION_A_MIN_DIGITS = 2; 92 public static final int SQ_RELATION_A_MIN_DIGITS = 2;
99 public static final int SQ_RELATION_B_MAX_DIGITS = 3; 93 public static final int SQ_RELATION_B_MAX_DIGITS = 3;
100 public static final int SQ_RELATION_B_MIN_DIGITS = 3; 94 public static final int SQ_RELATION_B_MIN_DIGITS = 3;
101 95
102 // OTHER 96 // OTHER
103 public static final int CSV_DIAGRAM_DATA_MAX_DIGITS = 3; 97 public static final int CSV_DIAGRAM_DATA_MAX_DIGITS = 3;
104 public static final int CSV_DIAGRAM_DATA_MIN_DIGITS = 3; 98 public static final int CSV_DIAGRAM_DATA_MIN_DIGITS = 3;
105 99
106 /** 100 /**
107 * Creates a localized NumberFormatter with given range of decimal digits. 101 * Creates a localized NumberFormatter with given range of decimal digits.
108 * @param m CallMeta to find the locale. 102 *
109 * @param min minimum number of decimal ("fraction") digits. 103 * @param m
110 * @param max maximum number of decimal ("fraction") digits. 104 * CallMeta to find the locale.
105 * @param min
106 * minimum number of decimal ("fraction") digits.
107 * @param max
108 * maximum number of decimal ("fraction") digits.
111 * @return A NumberFormat. Use #format(NUMBER) to get String representation 109 * @return A NumberFormat. Use #format(NUMBER) to get String representation
112 * of NUMBER. 110 * of NUMBER.
113 */ 111 */
114 public static NumberFormat getFormatter(final CallMeta m, final int min, final int max){ 112 public static NumberFormat getFormatter(final CallMeta m, final int min, final int max) {
115 final Locale locale = Resources.getLocale(m); 113 final Locale locale = Resources.getLocale(m);
116 final NumberFormat nf = NumberFormat.getInstance(locale); 114 final NumberFormat nf = NumberFormat.getInstance(locale);
117 115
118 nf.setMaximumFractionDigits(max); 116 nf.setMaximumFractionDigits(max);
119 nf.setMinimumFractionDigits(min); 117 nf.setMinimumFractionDigits(min);
120 118
121 return nf; 119 return nf;
122 } 120 }
123 121
124 public static NumberFormat getFormatter(final CallContext c, final int min, final int max){ 122 public static NumberFormat getFormatter(final CallContext c, final int min, final int max) {
125 return getFormatter(c.getMeta(), min, max); 123 return getFormatter(c.getMeta(), min, max);
126 } 124 }
127 125
128
129 /** 126 /**
130 * Returns a number formatter with no max or min digits set. 127 * Returns a number formatter with no max or min digits set.
131 * 128 *
132 * @param c The CallContext. 129 * @param c
130 * The CallContext.
133 * 131 *
134 * @return a number formatter. 132 * @return a number formatter.
135 */ 133 */
136 public static NumberFormat getRawFormatter(final CallContext c) { 134 public static NumberFormat getRawFormatter(final CallContext c) {
137 final Locale locale = Resources.getLocale(c.getMeta()); 135 final Locale locale = Resources.getLocale(c.getMeta());
142 * Returns a formatter in engineering notation. 140 * Returns a formatter in engineering notation.
143 */ 141 */
144 public static NumberFormat getEngFormatter(final CallContext c) { 142 public static NumberFormat getEngFormatter(final CallContext c) {
145 final NumberFormat nf = getRawFormatter(c); 143 final NumberFormat nf = getRawFormatter(c);
146 if (nf instanceof DecimalFormat) { 144 if (nf instanceof DecimalFormat) {
147 final DecimalFormat df = (DecimalFormat)nf; 145 final DecimalFormat df = (DecimalFormat) nf;
148 df.applyPattern("##0.#####E0"); 146 df.applyPattern("##0.#####E0");
149 } 147 }
150 return nf; 148 return nf;
151 } 149 }
152 150
153 /** 151 /**
154 * Returns a number formatter that uses an exponent after max digits. 152 * Returns a number formatter that uses an exponent after max digits.
155 */ 153 */
156 public static NumberFormat getScientificFormater( 154 public static NumberFormat getScientificFormater(final CallContext c, final int min, final int max) {
157 final CallContext c,
158 final int min,
159 final int max
160 ) {
161 final NumberFormat nf = getRawFormatter(c); 155 final NumberFormat nf = getRawFormatter(c);
162 if (nf instanceof DecimalFormat) { 156 if (nf instanceof DecimalFormat) {
163 final DecimalFormat df = (DecimalFormat)nf; 157 final DecimalFormat df = (DecimalFormat) nf;
164 df.applyPattern("0.0E0"); 158 df.applyPattern("0.0E0");
165 df.setMaximumFractionDigits(max); 159 df.setMaximumFractionDigits(max);
166 df.setMinimumFractionDigits(min); 160 df.setMinimumFractionDigits(min);
167 } 161 }
168 return nf; 162 return nf;
169 } 163 }
170 164
171
172 /** 165 /**
173 * Returns a date formatter with SHORT style. 166 * Returns a date formatter with SHORT style.
174 */ 167 */
175 public static DateFormat getShortDateFormat(final CallContext cc) { 168 public static DateFormat getShortDateFormat(final CallContext cc) {
176 final Locale locale = Resources.getLocale(cc.getMeta()); 169 final Locale locale = Resources.getLocale(cc.getMeta());
177 return DateFormat.getDateInstance(DateFormat.SHORT, locale); 170 return DateFormat.getDateInstance(DateFormat.SHORT, locale);
178 } 171 }
179 172
180
181 /** 173 /**
182 * Returns a date formatter with MEDIUM style. 174 * Returns a date formatter with MEDIUM style.
183 */ 175 */
184 public static DateFormat getMediumDateFormat(final CallContext cc) { 176 public static DateFormat getMediumDateFormat(final CallContext cc) {
185 final Locale locale = Resources.getLocale(cc.getMeta()); 177 final Locale locale = Resources.getLocale(cc.getMeta());
186 return DateFormat.getDateInstance(DateFormat.MEDIUM, locale); 178 return DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
187 } 179 }
188 180
189
190 /** 181 /**
191 * Returns the number formatter for kilometer values in waterlevel exports. 182 * Returns the number formatter for kilometer values in waterlevel exports.
192 * 183 *
193 * @return the number formatter for kilometer values. 184 * @return the number formatter for kilometer values.
194 */ 185 */
195 public static NumberFormat getWaterlevelKM(final CallContext context) { 186 public static NumberFormat getWaterlevelKM(final CallContext context) {
196 return getFormatter( 187 return getFormatter(context, WATERLEVEL_KM_MIN_DIGITS, WATERLEVEL_KM_MAX_DIGITS);
197 context,
198 WATERLEVEL_KM_MIN_DIGITS,
199 WATERLEVEL_KM_MAX_DIGITS);
200 } 188 }
201 189
202 /** 190 /**
203 * Returns the number formatter for data exported from diagram (not from 191 * Returns the number formatter for data exported from diagram (not from
204 * calculation. 192 * calculation.
205 * 193 *
206 * @return the number formatter for csv data from diagra. 194 * @return the number formatter for csv data from diagra.
207 */ 195 */
208 public static NumberFormat getCSVFormatter(final CallContext context) { 196 public static NumberFormat getCSVFormatter(final CallContext context) {
209 return getFormatter( 197 return getFormatter(context, CSV_DIAGRAM_DATA_MIN_DIGITS, CSV_DIAGRAM_DATA_MAX_DIGITS);
210 context,
211 CSV_DIAGRAM_DATA_MIN_DIGITS,
212 CSV_DIAGRAM_DATA_MAX_DIGITS);
213 } 198 }
214 199
215 public static NumberFormat getWaterlevelW(final CallMeta meta) { 200 public static NumberFormat getWaterlevelW(final CallMeta meta) {
216 return getFormatter( 201 return getFormatter(meta, WATERLEVEL_W_MIN_DIGITS, WATERLEVEL_W_MAX_DIGITS);
217 meta, 202 }
218 WATERLEVEL_W_MIN_DIGITS,
219 WATERLEVEL_W_MAX_DIGITS);
220 }
221
222 203
223 /** 204 /**
224 * Returns the number formatter for W values in waterlevel exports. 205 * Returns the number formatter for W values in waterlevel exports.
225 * 206 *
226 * @return the number formatter for W values. 207 * @return the number formatter for W values.
227 */ 208 */
228 public static NumberFormat getWaterlevelW(final CallContext context) { 209 public static NumberFormat getWaterlevelW(final CallContext context) {
229 return getFormatter( 210 return getFormatter(context, WATERLEVEL_W_MIN_DIGITS, WATERLEVEL_W_MAX_DIGITS);
230 context, 211 }
231 WATERLEVEL_W_MIN_DIGITS,
232 WATERLEVEL_W_MAX_DIGITS);
233 }
234
235 212
236 /** 213 /**
237 * Returns the number formatter for Q values in waterlevel exports. 214 * Returns the number formatter for Q values in waterlevel exports.
238 * 215 *
239 * @return the number formatter for Q values. 216 * @return the number formatter for Q values.
240 */ 217 */
241 public static NumberFormat getWaterlevelQ(final CallContext context) { 218 public static NumberFormat getWaterlevelQ(final CallContext context) {
242 return getFormatter( 219 return getFormatter(context, WATERLEVEL_Q_MIN_DIGITS, WATERLEVEL_Q_MAX_DIGITS);
243 context, 220 }
244 WATERLEVEL_Q_MIN_DIGITS,
245 WATERLEVEL_Q_MAX_DIGITS);
246 }
247
248 221
249 public static NumberFormat getWaterlevelQ(final CallMeta meta) { 222 public static NumberFormat getWaterlevelQ(final CallMeta meta) {
250 return getFormatter( 223 return getFormatter(meta, WATERLEVEL_Q_MIN_DIGITS, WATERLEVEL_Q_MAX_DIGITS);
251 meta,
252 WATERLEVEL_Q_MIN_DIGITS,
253 WATERLEVEL_Q_MAX_DIGITS);
254 } 224 }
255 225
256 /** 226 /**
257 * Returns the number formatter for W values in exports of computed 227 * Returns the number formatter for W values in exports of computed
258 * discharge curves. 228 * discharge curves.
259 * 229 *
260 * @return the number formatter for W values. 230 * @return the number formatter for W values.
261 */ 231 */
262 public static NumberFormat getComputedDischargeW(final CallContext context) { 232 public static NumberFormat getComputedDischargeW(final CallContext context) {
263 return getFormatter( 233 return getFormatter(context, COMPUTED_DISCHARGE_W_MIN_DIGITS, COMPUTED_DISCHARGE_W_MAX_DIGITS);
264 context, 234 }
265 COMPUTED_DISCHARGE_W_MIN_DIGITS,
266 COMPUTED_DISCHARGE_W_MAX_DIGITS);
267 }
268
269 235
270 /** 236 /**
271 * Returns the number formatter for Q values in exports of computed 237 * Returns the number formatter for Q values in exports of computed
272 * discharge curves. 238 * discharge curves.
273 * 239 *
274 * @return the number formatter for Q values. 240 * @return the number formatter for Q values.
275 */ 241 */
276 public static NumberFormat getComputedDischargeQ(final CallContext context) { 242 public static NumberFormat getComputedDischargeQ(final CallContext context) {
277 return getFormatter( 243 return getFormatter(context, COMPUTED_DISCHARGE_Q_MIN_DIGITS, COMPUTED_DISCHARGE_Q_MAX_DIGITS);
278 context, 244 }
279 COMPUTED_DISCHARGE_Q_MIN_DIGITS,
280 COMPUTED_DISCHARGE_Q_MAX_DIGITS);
281 }
282
283 245
284 /** 246 /**
285 * Returns the number formatter for W values in exports of historical 247 * Returns the number formatter for W values in exports of historical
286 * discharge curves. 248 * discharge curves.
287 * 249 *
288 * @return the number formatter for W values. 250 * @return the number formatter for W values.
289 */ 251 */
290 public static NumberFormat getHistoricalDischargeW(final CallContext context) { 252 public static NumberFormat getHistoricalDischargeW(final CallContext context) {
291 return getFormatter( 253 return getFormatter(context, HISTORICAL_DISCHARGE_W_MIN_DIGITS, HISTORICAL_DISCHARGE_W_MAX_DIGITS);
292 context, 254 }
293 HISTORICAL_DISCHARGE_W_MIN_DIGITS,
294 HISTORICAL_DISCHARGE_W_MAX_DIGITS);
295 }
296
297 255
298 /** 256 /**
299 * Returns the number formatter for Q values in exports of historical 257 * Returns the number formatter for Q values in exports of historical
300 * discharge curves. 258 * discharge curves.
301 * 259 *
302 * @return the number formatter for Q values. 260 * @return the number formatter for Q values.
303 */ 261 */
304 public static NumberFormat getHistoricalDischargeQ(final CallContext context) { 262 public static NumberFormat getHistoricalDischargeQ(final CallContext context) {
305 return getFormatter( 263 return getFormatter(context, HISTORICAL_DISCHARGE_Q_MIN_DIGITS, HISTORICAL_DISCHARGE_Q_MAX_DIGITS);
306 context, 264 }
307 HISTORICAL_DISCHARGE_Q_MIN_DIGITS,
308 HISTORICAL_DISCHARGE_Q_MAX_DIGITS);
309 }
310
311 265
312 /** 266 /**
313 * Returns the number formatter for W values in duration curve exports. 267 * Returns the number formatter for W values in duration curve exports.
314 * 268 *
315 * @return the number formatter for W values. 269 * @return the number formatter for W values.
316 */ 270 */
317 public static NumberFormat getDurationW(final CallContext context) { 271 public static NumberFormat getDurationW(final CallContext context) {
318 return getFormatter( 272 return getFormatter(context, DURATION_W_MIN_DIGITS, DURATION_W_MAX_DIGITS);
319 context, 273 }
320 DURATION_W_MIN_DIGITS,
321 DURATION_W_MAX_DIGITS);
322 }
323
324 274
325 /** 275 /**
326 * Returns the number formatter for Q values in duration curve exports. 276 * Returns the number formatter for Q values in duration curve exports.
327 * 277 *
328 * @return the number formatter for W values. 278 * @return the number formatter for W values.
329 */ 279 */
330 public static NumberFormat getDurationQ(final CallContext context) { 280 public static NumberFormat getDurationQ(final CallContext context) {
331 return getFormatter( 281 return getFormatter(context, DURATION_Q_MIN_DIGITS, DURATION_Q_MAX_DIGITS);
332 context, 282 }
333 DURATION_Q_MIN_DIGITS,
334 DURATION_Q_MAX_DIGITS);
335 }
336
337 283
338 /** 284 /**
339 * Returns the number formatter for D values in duration curve exports. 285 * Returns the number formatter for D values in duration curve exports.
340 * 286 *
341 * @return the number formatter for W values. 287 * @return the number formatter for W values.
342 */ 288 */
343 public static NumberFormat getDurationD(final CallContext context) { 289 public static NumberFormat getDurationD(final CallContext context) {
344 return getFormatter( 290 return getFormatter(context, DURATION_D_MIN_DIGITS, DURATION_D_MAX_DIGITS);
345 context,
346 DURATION_D_MIN_DIGITS,
347 DURATION_D_MAX_DIGITS);
348 } 291 }
349 292
350 public static NumberFormat getCalculationKm(final CallMeta meta) { 293 public static NumberFormat getCalculationKm(final CallMeta meta) {
351 return getFormatter( 294 return getFormatter(meta, CALCULATION_REPORT_KM_MIN_DIGITS, CALCULATION_REPORT_KM_MAX_DIGITS);
352 meta, 295 }
353 CALCULATION_REPORT_KM_MIN_DIGITS,
354 CALCULATION_REPORT_KM_MAX_DIGITS);
355 }
356
357 296
358 public static NumberFormat getFlowVelocityKM(final CallContext context) { 297 public static NumberFormat getFlowVelocityKM(final CallContext context) {
359 return getFormatter( 298 return getFormatter(context, FLOW_VELOCITY_KM_MIN_DIGITS, FLOW_VELOCITY_KM_MAX_DIGITS);
360 context, 299 }
361 FLOW_VELOCITY_KM_MIN_DIGITS,
362 FLOW_VELOCITY_KM_MAX_DIGITS);
363 }
364
365 300
366 public static NumberFormat getFlowVelocityValues(final CallContext context) { 301 public static NumberFormat getFlowVelocityValues(final CallContext context) {
367 return getFormatter( 302 return getFormatter(context, FLOW_VELOCITY_VALUES_MIN_DIGITS, FLOW_VELOCITY_VALUES_MAX_DIGITS);
368 context, 303 }
369 FLOW_VELOCITY_VALUES_MIN_DIGITS,
370 FLOW_VELOCITY_VALUES_MAX_DIGITS);
371 }
372
373 304
374 public static NumberFormat getFlowVelocityQ(final CallContext context) { 305 public static NumberFormat getFlowVelocityQ(final CallContext context) {
375 return getFormatter( 306 return getFormatter(context, FLOW_VELOCITY_Q_MIN_DIGITS, FLOW_VELOCITY_Q_MAX_DIGITS);
376 context, 307 }
377 FLOW_VELOCITY_Q_MIN_DIGITS,
378 FLOW_VELOCITY_Q_MAX_DIGITS);
379 }
380
381 308
382 public static NumberFormat getMiddleBedHeightKM(final CallContext context) { 309 public static NumberFormat getMiddleBedHeightKM(final CallContext context) {
383 return getFormatter( 310 return getFormatter(context, MIDDLE_BED_HEIGHT_KM_MIN_DIGITS, MIDDLE_BED_HEIGHT_KM_MAX_DIGITS);
384 context, 311 }
385 MIDDLE_BED_HEIGHT_KM_MIN_DIGITS,
386 MIDDLE_BED_HEIGHT_KM_MAX_DIGITS);
387 }
388
389 312
390 public static NumberFormat getMiddleBedHeightHeight(final CallContext context) { 313 public static NumberFormat getMiddleBedHeightHeight(final CallContext context) {
391 return getFormatter( 314 return getFormatter(context, MIDDLE_BED_HEIGHT_HEIGHT_MIN_DIGITS, MIDDLE_BED_HEIGHT_HEIGHT_MAX_DIGITS);
392 context, 315 }
393 MIDDLE_BED_HEIGHT_HEIGHT_MIN_DIGITS,
394 MIDDLE_BED_HEIGHT_HEIGHT_MAX_DIGITS);
395 }
396
397 316
398 public static NumberFormat getMiddleBedHeightUncert(final CallContext context) { 317 public static NumberFormat getMiddleBedHeightUncert(final CallContext context) {
399 return getFormatter( 318 return getFormatter(context, MIDDLE_BED_HEIGHT_UNCERT_MIN_DIGITS, MIDDLE_BED_HEIGHT_UNCERT_MAX_DIGITS);
400 context, 319 }
401 MIDDLE_BED_HEIGHT_UNCERT_MIN_DIGITS,
402 MIDDLE_BED_HEIGHT_UNCERT_MAX_DIGITS);
403 }
404
405 320
406 public static NumberFormat getMiddleBedHeightDataGap(final CallContext context) { 321 public static NumberFormat getMiddleBedHeightDataGap(final CallContext context) {
407 return getFormatter( 322 return getFormatter(context, MIDDLE_BED_HEIGHT_DATAGAP_MIN_DIGITS, MIDDLE_BED_HEIGHT_DATAGAP_MAX_DIGITS);
408 context, 323 }
409 MIDDLE_BED_HEIGHT_DATAGAP_MIN_DIGITS, 324
410 MIDDLE_BED_HEIGHT_DATAGAP_MAX_DIGITS); 325 public static NumberFormat getMiddleBedHeightSounding(final CallContext context) {
411 } 326 return getFormatter(context, MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MIN_DIGITS, MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MAX_DIGITS);
412 327 }
413
414 public static NumberFormat getMiddleBedHeightSounding(
415 final CallContext context
416 ) {
417 return getFormatter(
418 context,
419 MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MIN_DIGITS,
420 MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MAX_DIGITS);
421 }
422
423 328
424 public static NumberFormat getFixDeltaWKM(final CallContext context) { 329 public static NumberFormat getFixDeltaWKM(final CallContext context) {
425 return getFormatter( 330 return getFormatter(context, FIX_DELTA_W_KM_MIN_DIGITS, FIX_DELTA_W_KM_MAX_DIGITS);
426 context,
427 FIX_DELTA_W_KM_MIN_DIGITS,
428 FIX_DELTA_W_KM_MAX_DIGITS);
429 } 331 }
430 332
431 public static NumberFormat getFixDeltaWDeltaW(final CallContext context) { 333 public static NumberFormat getFixDeltaWDeltaW(final CallContext context) {
432 return getFormatter( 334 return getFormatter(context, FIX_DELTA_W_DELTA_W_MIN_DIGITS, FIX_DELTA_W_DELTA_W_MAX_DIGITS);
433 context,
434 FIX_DELTA_W_DELTA_W_MIN_DIGITS,
435 FIX_DELTA_W_DELTA_W_MAX_DIGITS);
436 } 335 }
437 336
438 public static NumberFormat getFixDeltaWQ(final CallContext context) { 337 public static NumberFormat getFixDeltaWQ(final CallContext context) {
439 return getFormatter( 338 return getFormatter(context, FIX_DELTA_W_DELTA_Q_MIN_DIGITS, FIX_DELTA_W_DELTA_Q_MAX_DIGITS);
440 context,
441 FIX_DELTA_W_DELTA_Q_MIN_DIGITS,
442 FIX_DELTA_W_DELTA_Q_MAX_DIGITS);
443 } 339 }
444 340
445 public static NumberFormat getFixDeltaWW(final CallContext context) { 341 public static NumberFormat getFixDeltaWW(final CallContext context) {
446 return getFormatter( 342 return getFormatter(context, FIX_DELTA_W_DELTA_W_MIN_DIGITS, FIX_DELTA_W_DELTA_W_MAX_DIGITS);
447 context,
448 FIX_DELTA_W_DELTA_W_MIN_DIGITS,
449 FIX_DELTA_W_DELTA_W_MAX_DIGITS);
450 } 343 }
451 344
452 public static NumberFormat getVariance(final CallContext context) { 345 public static NumberFormat getVariance(final CallContext context) {
453 return getFormatter( 346 return getFormatter(context, VARIANCE_MIN_DIGITS, VARIANCE_MAX_DIGITS);
454 context,
455 VARIANCE_MIN_DIGITS,
456 VARIANCE_MAX_DIGITS);
457 } 347 }
458 348
459 public static NumberFormat getSQRelationA(final CallContext context) { 349 public static NumberFormat getSQRelationA(final CallContext context) {
460 return getScientificFormater( 350 return getScientificFormater(context, SQ_RELATION_A_MIN_DIGITS, SQ_RELATION_A_MAX_DIGITS);
461 context,
462 SQ_RELATION_A_MIN_DIGITS,
463 SQ_RELATION_A_MAX_DIGITS);
464 } 351 }
465 352
466 public static NumberFormat getSQRelationB(final CallContext context) { 353 public static NumberFormat getSQRelationB(final CallContext context) {
467 return getFormatter( 354 return getFormatter(context, SQ_RELATION_B_MIN_DIGITS, SQ_RELATION_B_MAX_DIGITS);
468 context,
469 SQ_RELATION_B_MIN_DIGITS,
470 SQ_RELATION_B_MAX_DIGITS);
471 } 355 }
472 356
473 public static NumberFormat getSQRelationKM(final CallContext context) { 357 public static NumberFormat getSQRelationKM(final CallContext context) {
474 return getFormatter( 358 return getFormatter(context, SQ_RELATION_KM_MIN_DIGITS, SQ_RELATION_KM_MAX_DIGITS);
475 context,
476 SQ_RELATION_KM_MIN_DIGITS,
477 SQ_RELATION_KM_MAX_DIGITS);
478 } 359 }
479 360
480 public static NumberFormat getMeterFormat(final CallContext context) { 361 public static NumberFormat getMeterFormat(final CallContext context) {
481 return getFormatter( 362 return getFormatter(context, 0, 2);
482 context,
483 0,
484 2);
485 363
486 } 364 }
487 365
488 public static DateFormat getDateFormatter(final CallMeta m, final String pattern) { 366 public static DateFormat getDateFormatter(final CallMeta m, final String pattern) {
489 final Locale locale = Resources.getLocale(m); 367 final Locale locale = Resources.getLocale(m);
508 386
509 /** 387 /**
510 * Another waterlevel formatter with fixed digits (always 2) 388 * Another waterlevel formatter with fixed digits (always 2)
511 */ 389 */
512 public static NumberFormat getWaterlevelW2(final CallMeta meta) { 390 public static NumberFormat getWaterlevelW2(final CallMeta meta) {
513 return getFormatter( meta, 2, 2); 391 return getFormatter(meta, 2, 2);
514 } 392 }
515 393
516 public static NumberFormat getFlowDepthDevelopmentPerYear(final CallContext context) { 394 public static NumberFormat getFlowDepthDevelopmentPerYear(final CallContext context) {
517 return getFormatter(context.getMeta(), 2, 2); 395 return getFormatter(context.getMeta(), 2, 2);
518 } 396 }
397
398 public static NumberFormat getSalixLine(final CallContext context) {
399 return Formatter.getFormatter(context, 2, 2);
400 }
519 } 401 }

http://dive4elements.wald.intevation.org