Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java @ 9109:59cf6e6a452d
pdf export enhancements
author | gernotbelger |
---|---|
date | Fri, 01 Jun 2018 16:06:12 +0200 |
parents | 7134a4c7d1b6 |
children | 189cc8ededbd |
rev | line source |
---|---|
8948 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo.common; | |
11 | |
12 import java.text.NumberFormat; | |
13 | |
14 import org.apache.commons.lang.StringUtils; | |
15 import org.dive4elements.artifacts.CallContext; | |
9000 | 16 import org.dive4elements.river.artifacts.common.AbstractResultType; |
17 import org.dive4elements.river.artifacts.common.I18NStrings; | |
8948 | 18 import org.dive4elements.river.artifacts.resources.Resources; |
19 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKind; | |
20 import org.dive4elements.river.utils.Formatter; | |
21 import org.dive4elements.river.utils.RiverUtils; | |
22 | |
23 /** | |
24 * Result type for data that goes into {@link SInfoResultRow}s. | |
25 * | |
26 * @author Gernot Belger | |
27 */ | |
9000 | 28 public abstract class SInfoResultType extends AbstractResultType { |
8948 | 29 |
9006 | 30 private static final long serialVersionUID = 1L; |
31 | |
9000 | 32 private SInfoResultType(final String unit, final String csvHeader) { |
33 super(unit, csvHeader, csvHeader); | |
34 } | |
8948 | 35 |
9000 | 36 private SInfoResultType(final String unit, final String csvHeader, final String pdfHeader) { |
37 super(unit, csvHeader, pdfHeader); | |
38 } | |
8948 | 39 |
9000 | 40 public static final SInfoResultType waterlevel = new SInfoResultType(null, SInfoI18NStrings.CSV_WATERLEVEL_HEADER, |
41 "sinfo.export.flow_depth.pdf.header.waterlevel") { | |
9006 | 42 private static final long serialVersionUID = 1L; |
43 | |
8948 | 44 @Override |
45 public String exportValue(final CallContext context, final Object value) { | |
46 final double doubleValue = asDouble(value); | |
47 return exportDoubleValue(context, doubleValue); | |
48 } | |
49 | |
50 @Override | |
51 protected NumberFormat createFormatter(final CallContext context) { | |
52 // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of | |
53 // digits. | |
54 return Formatter.getFlowDepth(context); | |
55 } | |
9000 | 56 }; |
8948 | 57 |
9000 | 58 public static final SInfoResultType waterlevelLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LABEL_HEADER) { |
9006 | 59 private static final long serialVersionUID = 1L; |
60 | |
8948 | 61 @Override |
62 public String exportValue(final CallContext context, final Object value) { | |
63 return exportStringValue(value); | |
64 } | |
65 | |
66 @Override | |
67 protected NumberFormat createFormatter(final CallContext context) { | |
68 throw new UnsupportedOperationException(); | |
69 } | |
9000 | 70 }; |
8948 | 71 |
9000 | 72 public static final SInfoResultType discharge = new SInfoResultType(I18NStrings.UNIT_CUBIC_M, SInfoI18NStrings.CSV_DISCHARGE_HEADER) { |
9006 | 73 private static final long serialVersionUID = 1L; |
74 | |
8948 | 75 @Override |
76 public String exportValue(final CallContext context, final Object value) { | |
77 final double doubleValue = asDouble(value); | |
78 final double roundedDischarge = RiverUtils.roundQ(doubleValue); | |
79 return exportDoubleValue(context, roundedDischarge); | |
80 } | |
81 | |
82 @Override | |
83 protected NumberFormat createFormatter(final CallContext context) { | |
84 return Formatter.getWaterlevelQ(context); | |
85 } | |
9000 | 86 }; |
8948 | 87 |
9000 | 88 public static final SInfoResultType meanBedHeight = new SInfoResultType(null, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER, |
89 SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER_SHORT) { | |
9006 | 90 private static final long serialVersionUID = 1L; |
91 | |
8948 | 92 @Override |
93 public String exportValue(final CallContext context, final Object value) { | |
94 final double doubleValue = asDouble(value); | |
95 return exportDoubleValue(context, doubleValue); | |
96 } | |
97 | |
98 @Override | |
99 protected NumberFormat createFormatter(final CallContext context) { | |
100 return Formatter.getMeanBedHeight(context); | |
101 } | |
9000 | 102 }; |
8948 | 103 |
9000 | 104 public static final SInfoResultType soundingLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_SOUNDING_HEADER) { |
9006 | 105 private static final long serialVersionUID = 1L; |
106 | |
8948 | 107 @Override |
108 public String exportValue(final CallContext context, final Object value) { | |
109 return exportStringValue(value); | |
110 } | |
111 | |
112 @Override | |
113 protected NumberFormat createFormatter(final CallContext context) { | |
114 throw new UnsupportedOperationException(); | |
115 } | |
9000 | 116 }; |
117 public static final SInfoResultType flowdepthDevelopmentPerYear = new SInfoResultType(I18NStrings.UNIT_CM_A, | |
118 SInfoI18NStrings.CSV_FLOWDEPTH_DEVELOPMENT_PER_YEAR_HEADER) { | |
9006 | 119 private static final long serialVersionUID = 1L; |
120 | |
9000 | 121 @Override |
122 public String exportValue(final CallContext context, final Object value) { | |
123 final double doubleValue = asDouble(value); | |
124 return exportDoubleValue(context, doubleValue); | |
125 } | |
8948 | 126 |
9000 | 127 @Override |
128 protected NumberFormat createFormatter(final CallContext context) { | |
129 return Formatter.getFlowDepthDevelopmentPerYear(context); | |
130 } | |
131 }; | |
132 | |
133 public static final SInfoResultType flowdepthmin = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_MIN_HEADER) { | |
9006 | 134 private static final long serialVersionUID = 1L; |
135 | |
8948 | 136 @Override |
137 public String exportValue(final CallContext context, final Object value) { | |
138 final double doubleValue = asDouble(value); | |
139 return exportDoubleValue(context, doubleValue); | |
140 } | |
141 | |
142 @Override | |
143 protected NumberFormat createFormatter(final CallContext context) { | |
144 return Formatter.getFlowDepth(context); | |
145 } | |
9000 | 146 }; |
8948 | 147 |
9000 | 148 public static final SInfoResultType flowdepthmax = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_MAX_HEADER) { |
9006 | 149 private static final long serialVersionUID = 1L; |
150 | |
8948 | 151 @Override |
152 public String exportValue(final CallContext context, final Object value) { | |
153 final double doubleValue = asDouble(value); | |
154 return exportDoubleValue(context, doubleValue); | |
155 } | |
156 | |
157 @Override | |
158 protected NumberFormat createFormatter(final CallContext context) { | |
159 return Formatter.getFlowDepth(context); | |
160 } | |
9000 | 161 }; |
8948 | 162 |
9000 | 163 public static final SInfoResultType gaugeLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_GAUGE_HEADER) { |
9006 | 164 private static final long serialVersionUID = 1L; |
165 | |
8948 | 166 @Override |
167 public String exportValue(final CallContext context, final Object value) { | |
168 return exportStringValue(value); | |
169 } | |
170 | |
171 @Override | |
172 protected NumberFormat createFormatter(final CallContext context) { | |
173 throw new UnsupportedOperationException(); | |
174 } | |
9000 | 175 }; |
8948 | 176 |
9000 | 177 public static final SInfoResultType location = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LOCATION_HEADER) { |
9006 | 178 private static final long serialVersionUID = 1L; |
179 | |
8948 | 180 @Override |
181 public String exportValue(final CallContext context, final Object value) { | |
182 return exportStringValue(value); | |
183 } | |
184 | |
185 @Override | |
186 protected NumberFormat createFormatter(final CallContext context) { | |
187 throw new UnsupportedOperationException(); | |
188 } | |
9000 | 189 }; |
8950
b0aeed4c97c1
Implemented chart output for sinfo flow depth min/max calculation
gernotbelger
parents:
8949
diff
changeset
|
190 |
9000 | 191 public static final SInfoResultType soilkind = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_TKHKIND_HEADER, |
192 "sinfo.export.tkh.pdf.header.tkhkind") { | |
9006 | 193 private static final long serialVersionUID = 1L; |
194 | |
8948 | 195 @Override |
196 public String exportValue(final CallContext context, final Object value) { | |
197 | |
198 if (value == null) | |
199 return StringUtils.EMPTY; | |
200 | |
201 final SoilKind kind = (SoilKind) value; | |
202 | |
203 final String key = SInfoI18NStrings.PREFIX_TKH_KIND + kind.name(); | |
204 return Resources.getMsg(context.getMeta(), key, key); | |
205 } | |
206 | |
207 @Override | |
208 protected NumberFormat createFormatter(final CallContext context) { | |
209 throw new UnsupportedOperationException(); | |
210 } | |
9000 | 211 }; |
8950
b0aeed4c97c1
Implemented chart output for sinfo flow depth min/max calculation
gernotbelger
parents:
8949
diff
changeset
|
212 |
9000 | 213 public static final SInfoResultType flowdepth = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_HEADER) { |
9006 | 214 private static final long serialVersionUID = 1L; |
215 | |
8951 | 216 @Override |
217 public String exportValue(final CallContext context, final Object value) { | |
218 final double doubleValue = asDouble(value); | |
219 return exportDoubleValue(context, doubleValue); | |
220 } | |
221 | |
222 @Override | |
223 protected NumberFormat createFormatter(final CallContext context) { | |
224 return Formatter.getFlowDepth(context); | |
225 } | |
8948 | 226 }; |
227 | |
9000 | 228 public static final SInfoResultType d50 = new SInfoResultType(null, null) { |
9006 | 229 private static final long serialVersionUID = 1L; |
230 | |
9000 | 231 @Override |
232 public String exportValue(final CallContext context, final Object value) { | |
233 final double doubleValue = asDouble(value); | |
234 return exportDoubleValue(context, doubleValue); | |
235 } | |
8948 | 236 |
9000 | 237 @Override |
238 protected NumberFormat createFormatter(final CallContext context) { | |
239 throw new UnsupportedOperationException(); | |
240 } | |
241 }; | |
8948 | 242 |
9000 | 243 public static final SInfoResultType velocity = new SInfoResultType(null, null) { |
9006 | 244 private static final long serialVersionUID = 1L; |
245 | |
9000 | 246 @Override |
247 public String exportValue(final CallContext context, final Object value) { | |
248 final double doubleValue = asDouble(value); | |
249 return exportDoubleValue(context, doubleValue); | |
250 } | |
8948 | 251 |
9000 | 252 @Override |
253 protected NumberFormat createFormatter(final CallContext context) { | |
254 throw new UnsupportedOperationException(); | |
255 } | |
256 }; | |
8948 | 257 |
9000 | 258 public static final SInfoResultType tau = new SInfoResultType(null, null) { |
9006 | 259 private static final long serialVersionUID = 1L; |
260 | |
9000 | 261 @Override |
262 public String exportValue(final CallContext context, final Object value) { | |
263 final double doubleValue = asDouble(value); | |
264 return exportDoubleValue(context, doubleValue); | |
265 } | |
8949
09e4a4909814
Distinguish between csv and pdf column headers
gernotbelger
parents:
8948
diff
changeset
|
266 |
9000 | 267 @Override |
268 protected NumberFormat createFormatter(final CallContext context) { | |
269 throw new UnsupportedOperationException(); | |
270 } | |
271 }; | |
272 | |
273 public static final SInfoResultType tkh = new SInfoResultType(I18NStrings.UNIT_CM, SInfoI18NStrings.CSV_TKH_HEADER, SInfoI18NStrings.CSV_TKH_HEADER_SHORT) { | |
9006 | 274 private static final long serialVersionUID = 1L; |
275 | |
9000 | 276 @Override |
277 public String exportValue(final CallContext context, final Object value) { | |
278 final double doubleValue = asDouble(value); | |
279 return exportDoubleValue(context, doubleValue); | |
280 } | |
281 | |
282 @Override | |
283 protected NumberFormat createFormatter(final CallContext context) { | |
284 return Formatter.getTkh(context); | |
285 } | |
286 }; | |
287 | |
288 public static final SInfoResultType tkhup = new SInfoResultType(I18NStrings.UNIT_M, null) { | |
9006 | 289 private static final long serialVersionUID = 1L; |
290 | |
9000 | 291 @Override |
292 public String exportValue(final CallContext context, final Object value) { | |
293 final double doubleValue = asDouble(value); | |
294 return exportDoubleValue(context, doubleValue); | |
295 } | |
296 | |
297 @Override | |
298 protected NumberFormat createFormatter(final CallContext context) { | |
299 throw new UnsupportedOperationException(); | |
300 } | |
301 }; | |
302 | |
303 public static final SInfoResultType tkhdown = new SInfoResultType(I18NStrings.UNIT_M, null) { | |
9006 | 304 private static final long serialVersionUID = 1L; |
305 | |
9000 | 306 @Override |
307 public String exportValue(final CallContext context, final Object value) { | |
308 final double doubleValue = asDouble(value); | |
309 return exportDoubleValue(context, doubleValue); | |
310 } | |
311 | |
312 @Override | |
313 protected NumberFormat createFormatter(final CallContext context) { | |
314 throw new UnsupportedOperationException(); | |
315 } | |
316 }; | |
317 | |
318 public static final SInfoResultType flowdepthtkh = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTHTKH_HEADER) { | |
9006 | 319 private static final long serialVersionUID = 1L; |
320 | |
9000 | 321 @Override |
322 public String exportValue(final CallContext context, final Object value) { | |
323 final double doubleValue = asDouble(value); | |
324 return exportDoubleValue(context, doubleValue); | |
325 } | |
326 | |
327 @Override | |
328 protected NumberFormat createFormatter(final CallContext context) { | |
329 return Formatter.getFlowDepth(context); | |
330 } | |
331 }; | |
332 | |
333 public static final SInfoResultType flowdepthDevelopment = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_DEVELOPMENT_HEADER, | |
334 SInfoI18NStrings.PDF_FLOWDEPTH_DEVELOPMENT_HEADER) { | |
9006 | 335 private static final long serialVersionUID = 1L; |
336 | |
9000 | 337 @Override |
338 public String exportValue(final CallContext context, final Object value) { | |
339 final double doubleValue = asDouble(value); | |
340 return exportDoubleValue(context, doubleValue); | |
341 } | |
342 | |
343 @Override | |
344 protected NumberFormat createFormatter(final CallContext context) { | |
345 return Formatter.getTkh(context); | |
346 } | |
347 }; | |
348 | |
349 public static final SInfoResultType depthDevelopmentPerYear = new SInfoResultType(I18NStrings.UNIT_CM_A, | |
350 SInfoI18NStrings.CSV_FLOWDEPTH_DEVELOPMENT_PER_YEAR_HEADER) { | |
9006 | 351 private static final long serialVersionUID = 1L; |
352 | |
9000 | 353 @Override |
354 public String exportValue(final CallContext context, final Object value) { | |
355 final double doubleValue = asDouble(value); | |
356 return exportDoubleValue(context, doubleValue); | |
357 } | |
358 | |
359 @Override | |
360 protected NumberFormat createFormatter(final CallContext context) { | |
361 return Formatter.getFlowDepthDevelopmentPerYear(context); | |
362 } | |
363 }; | |
364 public static final SInfoResultType waterlevelDifference = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_WATERLEVEL_DIFFERENCE_HEADER, | |
9109 | 365 "sinfo.export.csv.header.waterlevel.difference") { |
9006 | 366 private static final long serialVersionUID = 1L; |
367 | |
9000 | 368 @Override |
369 public String exportValue(final CallContext context, final Object value) { | |
370 final double doubleValue = asDouble(value); | |
371 return exportDoubleValue(context, doubleValue); | |
372 } | |
373 | |
374 @Override | |
375 protected NumberFormat createFormatter(final CallContext context) { | |
376 return Formatter.getTkh(context); | |
377 } | |
378 }; | |
379 public static final SInfoResultType bedHeightDifference = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_DIFFERENCE_HEADER, | |
9109 | 380 "sinfo.export.csv.header.mean_bed_height.difference") { |
9006 | 381 private static final long serialVersionUID = 1L; |
382 | |
9000 | 383 @Override |
384 public String exportValue(final CallContext context, final Object value) { | |
385 final double doubleValue = asDouble(value); | |
386 return exportDoubleValue(context, doubleValue); | |
387 } | |
388 | |
389 @Override | |
390 protected NumberFormat createFormatter(final CallContext context) { | |
391 return Formatter.getTkh(context); | |
392 } | |
393 }; | |
394 public static final SInfoResultType flowdepthCurrent = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_CURRENT_HEADER) { | |
9006 | 395 private static final long serialVersionUID = 1L; |
396 | |
9000 | 397 @Override |
398 public String exportValue(final CallContext context, final Object value) { | |
399 final double doubleValue = asDouble(value); | |
400 return exportDoubleValue(context, doubleValue); | |
401 } | |
402 | |
403 @Override | |
404 protected NumberFormat createFormatter(final CallContext context) { | |
405 return Formatter.getFlowDepth(context); | |
406 } | |
407 }; | |
408 public static final SInfoResultType flowdepthHistorical = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_HISTORICAL_HEADER) { | |
9006 | 409 private static final long serialVersionUID = 1L; |
410 | |
9000 | 411 @Override |
412 public String exportValue(final CallContext context, final Object value) { | |
413 final double doubleValue = asDouble(value); | |
414 return exportDoubleValue(context, doubleValue); | |
415 } | |
416 | |
417 @Override | |
418 protected NumberFormat createFormatter(final CallContext context) { | |
419 return Formatter.getFlowDepth(context); | |
420 } | |
421 }; | |
422 | |
8948 | 423 } |