Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java @ 9000:50cc99579a46
Work on uinfo
author | gernotbelger |
---|---|
date | Thu, 12 Apr 2018 19:16:10 +0200 |
parents | 7c1611b5a59e |
children | 7134a4c7d1b6 |
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 |
9000 | 30 private SInfoResultType(final String unit, final String csvHeader) { |
31 super(unit, csvHeader, csvHeader); | |
32 } | |
8948 | 33 |
9000 | 34 private SInfoResultType(final String unit, final String csvHeader, final String pdfHeader) { |
35 super(unit, csvHeader, pdfHeader); | |
36 } | |
8948 | 37 |
9000 | 38 public static final SInfoResultType waterlevel = new SInfoResultType(null, SInfoI18NStrings.CSV_WATERLEVEL_HEADER, |
39 "sinfo.export.flow_depth.pdf.header.waterlevel") { | |
8948 | 40 @Override |
41 public String exportValue(final CallContext context, final Object value) { | |
42 final double doubleValue = asDouble(value); | |
43 return exportDoubleValue(context, doubleValue); | |
44 } | |
45 | |
46 @Override | |
47 protected NumberFormat createFormatter(final CallContext context) { | |
48 // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of | |
49 // digits. | |
50 return Formatter.getFlowDepth(context); | |
51 } | |
9000 | 52 }; |
8948 | 53 |
9000 | 54 public static final SInfoResultType waterlevelLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LABEL_HEADER) { |
8948 | 55 @Override |
56 public String exportValue(final CallContext context, final Object value) { | |
57 return exportStringValue(value); | |
58 } | |
59 | |
60 @Override | |
61 protected NumberFormat createFormatter(final CallContext context) { | |
62 throw new UnsupportedOperationException(); | |
63 } | |
9000 | 64 }; |
8948 | 65 |
9000 | 66 public static final SInfoResultType discharge = new SInfoResultType(I18NStrings.UNIT_CUBIC_M, SInfoI18NStrings.CSV_DISCHARGE_HEADER) { |
8948 | 67 @Override |
68 public String exportValue(final CallContext context, final Object value) { | |
69 final double doubleValue = asDouble(value); | |
70 final double roundedDischarge = RiverUtils.roundQ(doubleValue); | |
71 return exportDoubleValue(context, roundedDischarge); | |
72 } | |
73 | |
74 @Override | |
75 protected NumberFormat createFormatter(final CallContext context) { | |
76 return Formatter.getWaterlevelQ(context); | |
77 } | |
9000 | 78 }; |
8948 | 79 |
9000 | 80 public static final SInfoResultType meanBedHeight = new SInfoResultType(null, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER, |
81 SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER_SHORT) { | |
8948 | 82 @Override |
83 public String exportValue(final CallContext context, final Object value) { | |
84 final double doubleValue = asDouble(value); | |
85 return exportDoubleValue(context, doubleValue); | |
86 } | |
87 | |
88 @Override | |
89 protected NumberFormat createFormatter(final CallContext context) { | |
90 return Formatter.getMeanBedHeight(context); | |
91 } | |
9000 | 92 }; |
8948 | 93 |
9000 | 94 public static final SInfoResultType soundingLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_SOUNDING_HEADER) { |
8948 | 95 @Override |
96 public String exportValue(final CallContext context, final Object value) { | |
97 return exportStringValue(value); | |
98 } | |
99 | |
100 @Override | |
101 protected NumberFormat createFormatter(final CallContext context) { | |
102 throw new UnsupportedOperationException(); | |
103 } | |
9000 | 104 }; |
105 public static final SInfoResultType flowdepthDevelopmentPerYear = new SInfoResultType(I18NStrings.UNIT_CM_A, | |
106 SInfoI18NStrings.CSV_FLOWDEPTH_DEVELOPMENT_PER_YEAR_HEADER) { | |
107 @Override | |
108 public String exportValue(final CallContext context, final Object value) { | |
109 final double doubleValue = asDouble(value); | |
110 return exportDoubleValue(context, doubleValue); | |
111 } | |
8948 | 112 |
9000 | 113 @Override |
114 protected NumberFormat createFormatter(final CallContext context) { | |
115 return Formatter.getFlowDepthDevelopmentPerYear(context); | |
116 } | |
117 }; | |
118 | |
119 public static final SInfoResultType flowdepthmin = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_MIN_HEADER) { | |
8948 | 120 @Override |
121 public String exportValue(final CallContext context, final Object value) { | |
122 final double doubleValue = asDouble(value); | |
123 return exportDoubleValue(context, doubleValue); | |
124 } | |
125 | |
126 @Override | |
127 protected NumberFormat createFormatter(final CallContext context) { | |
128 return Formatter.getFlowDepth(context); | |
129 } | |
9000 | 130 }; |
8948 | 131 |
9000 | 132 public static final SInfoResultType flowdepthmax = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_MAX_HEADER) { |
8948 | 133 @Override |
134 public String exportValue(final CallContext context, final Object value) { | |
135 final double doubleValue = asDouble(value); | |
136 return exportDoubleValue(context, doubleValue); | |
137 } | |
138 | |
139 @Override | |
140 protected NumberFormat createFormatter(final CallContext context) { | |
141 return Formatter.getFlowDepth(context); | |
142 } | |
9000 | 143 }; |
8948 | 144 |
9000 | 145 public static final SInfoResultType gaugeLabel = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_GAUGE_HEADER) { |
8948 | 146 @Override |
147 public String exportValue(final CallContext context, final Object value) { | |
148 return exportStringValue(value); | |
149 } | |
150 | |
151 @Override | |
152 protected NumberFormat createFormatter(final CallContext context) { | |
153 throw new UnsupportedOperationException(); | |
154 } | |
9000 | 155 }; |
8948 | 156 |
9000 | 157 public static final SInfoResultType location = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LOCATION_HEADER) { |
8948 | 158 @Override |
159 public String exportValue(final CallContext context, final Object value) { | |
160 return exportStringValue(value); | |
161 } | |
162 | |
163 @Override | |
164 protected NumberFormat createFormatter(final CallContext context) { | |
165 throw new UnsupportedOperationException(); | |
166 } | |
9000 | 167 }; |
8950
b0aeed4c97c1
Implemented chart output for sinfo flow depth min/max calculation
gernotbelger
parents:
8949
diff
changeset
|
168 |
9000 | 169 public static final SInfoResultType soilkind = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_TKHKIND_HEADER, |
170 "sinfo.export.tkh.pdf.header.tkhkind") { | |
8948 | 171 @Override |
172 public String exportValue(final CallContext context, final Object value) { | |
173 | |
174 if (value == null) | |
175 return StringUtils.EMPTY; | |
176 | |
177 final SoilKind kind = (SoilKind) value; | |
178 | |
179 final String key = SInfoI18NStrings.PREFIX_TKH_KIND + kind.name(); | |
180 return Resources.getMsg(context.getMeta(), key, key); | |
181 } | |
182 | |
183 @Override | |
184 protected NumberFormat createFormatter(final CallContext context) { | |
185 throw new UnsupportedOperationException(); | |
186 } | |
9000 | 187 }; |
8950
b0aeed4c97c1
Implemented chart output for sinfo flow depth min/max calculation
gernotbelger
parents:
8949
diff
changeset
|
188 |
9000 | 189 public static final SInfoResultType flowdepth = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_HEADER) { |
8951 | 190 @Override |
191 public String exportValue(final CallContext context, final Object value) { | |
192 final double doubleValue = asDouble(value); | |
193 return exportDoubleValue(context, doubleValue); | |
194 } | |
195 | |
196 @Override | |
197 protected NumberFormat createFormatter(final CallContext context) { | |
198 return Formatter.getFlowDepth(context); | |
199 } | |
8948 | 200 }; |
201 | |
9000 | 202 public static final SInfoResultType d50 = new SInfoResultType(null, null) { |
203 @Override | |
204 public String exportValue(final CallContext context, final Object value) { | |
205 final double doubleValue = asDouble(value); | |
206 return exportDoubleValue(context, doubleValue); | |
207 } | |
8948 | 208 |
9000 | 209 @Override |
210 protected NumberFormat createFormatter(final CallContext context) { | |
211 throw new UnsupportedOperationException(); | |
212 } | |
213 }; | |
8948 | 214 |
9000 | 215 public static final SInfoResultType velocity = new SInfoResultType(null, null) { |
216 @Override | |
217 public String exportValue(final CallContext context, final Object value) { | |
218 final double doubleValue = asDouble(value); | |
219 return exportDoubleValue(context, doubleValue); | |
220 } | |
8948 | 221 |
9000 | 222 @Override |
223 protected NumberFormat createFormatter(final CallContext context) { | |
224 throw new UnsupportedOperationException(); | |
225 } | |
226 }; | |
8948 | 227 |
9000 | 228 public static final SInfoResultType tau = new SInfoResultType(null, null) { |
229 @Override | |
230 public String exportValue(final CallContext context, final Object value) { | |
231 final double doubleValue = asDouble(value); | |
232 return exportDoubleValue(context, doubleValue); | |
233 } | |
8949
09e4a4909814
Distinguish between csv and pdf column headers
gernotbelger
parents:
8948
diff
changeset
|
234 |
9000 | 235 @Override |
236 protected NumberFormat createFormatter(final CallContext context) { | |
237 throw new UnsupportedOperationException(); | |
238 } | |
239 }; | |
240 | |
241 public static final SInfoResultType tkh = new SInfoResultType(I18NStrings.UNIT_CM, SInfoI18NStrings.CSV_TKH_HEADER, SInfoI18NStrings.CSV_TKH_HEADER_SHORT) { | |
242 @Override | |
243 public String exportValue(final CallContext context, final Object value) { | |
244 final double doubleValue = asDouble(value); | |
245 return exportDoubleValue(context, doubleValue); | |
246 } | |
247 | |
248 @Override | |
249 protected NumberFormat createFormatter(final CallContext context) { | |
250 return Formatter.getTkh(context); | |
251 } | |
252 }; | |
253 | |
254 public static final SInfoResultType tkhup = new SInfoResultType(I18NStrings.UNIT_M, null) { | |
255 @Override | |
256 public String exportValue(final CallContext context, final Object value) { | |
257 final double doubleValue = asDouble(value); | |
258 return exportDoubleValue(context, doubleValue); | |
259 } | |
260 | |
261 @Override | |
262 protected NumberFormat createFormatter(final CallContext context) { | |
263 throw new UnsupportedOperationException(); | |
264 } | |
265 }; | |
266 | |
267 public static final SInfoResultType tkhdown = new SInfoResultType(I18NStrings.UNIT_M, null) { | |
268 @Override | |
269 public String exportValue(final CallContext context, final Object value) { | |
270 final double doubleValue = asDouble(value); | |
271 return exportDoubleValue(context, doubleValue); | |
272 } | |
273 | |
274 @Override | |
275 protected NumberFormat createFormatter(final CallContext context) { | |
276 throw new UnsupportedOperationException(); | |
277 } | |
278 }; | |
279 | |
280 public static final SInfoResultType flowdepthtkh = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTHTKH_HEADER) { | |
281 @Override | |
282 public String exportValue(final CallContext context, final Object value) { | |
283 final double doubleValue = asDouble(value); | |
284 return exportDoubleValue(context, doubleValue); | |
285 } | |
286 | |
287 @Override | |
288 protected NumberFormat createFormatter(final CallContext context) { | |
289 return Formatter.getFlowDepth(context); | |
290 } | |
291 }; | |
292 | |
293 public static final SInfoResultType flowdepthDevelopment = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_DEVELOPMENT_HEADER, | |
294 SInfoI18NStrings.PDF_FLOWDEPTH_DEVELOPMENT_HEADER) { | |
295 @Override | |
296 public String exportValue(final CallContext context, final Object value) { | |
297 final double doubleValue = asDouble(value); | |
298 return exportDoubleValue(context, doubleValue); | |
299 } | |
300 | |
301 @Override | |
302 protected NumberFormat createFormatter(final CallContext context) { | |
303 return Formatter.getTkh(context); | |
304 } | |
305 }; | |
306 | |
307 public static final SInfoResultType depthDevelopmentPerYear = new SInfoResultType(I18NStrings.UNIT_CM_A, | |
308 SInfoI18NStrings.CSV_FLOWDEPTH_DEVELOPMENT_PER_YEAR_HEADER) { | |
309 @Override | |
310 public String exportValue(final CallContext context, final Object value) { | |
311 final double doubleValue = asDouble(value); | |
312 return exportDoubleValue(context, doubleValue); | |
313 } | |
314 | |
315 @Override | |
316 protected NumberFormat createFormatter(final CallContext context) { | |
317 return Formatter.getFlowDepthDevelopmentPerYear(context); | |
318 } | |
319 }; | |
320 public static final SInfoResultType waterlevelDifference = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_WATERLEVEL_DIFFERENCE_HEADER, | |
321 "sinfo.export.pdf.header.waterlevel.difference") { | |
322 @Override | |
323 public String exportValue(final CallContext context, final Object value) { | |
324 final double doubleValue = asDouble(value); | |
325 return exportDoubleValue(context, doubleValue); | |
326 } | |
327 | |
328 @Override | |
329 protected NumberFormat createFormatter(final CallContext context) { | |
330 return Formatter.getTkh(context); | |
331 } | |
332 }; | |
333 public static final SInfoResultType bedHeightDifference = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_DIFFERENCE_HEADER, | |
334 "sinfo.export.pdf.header.mean_bed_height.difference") { | |
335 @Override | |
336 public String exportValue(final CallContext context, final Object value) { | |
337 final double doubleValue = asDouble(value); | |
338 return exportDoubleValue(context, doubleValue); | |
339 } | |
340 | |
341 @Override | |
342 protected NumberFormat createFormatter(final CallContext context) { | |
343 return Formatter.getTkh(context); | |
344 } | |
345 }; | |
346 public static final SInfoResultType flowdepthCurrent = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_CURRENT_HEADER) { | |
347 @Override | |
348 public String exportValue(final CallContext context, final Object value) { | |
349 final double doubleValue = asDouble(value); | |
350 return exportDoubleValue(context, doubleValue); | |
351 } | |
352 | |
353 @Override | |
354 protected NumberFormat createFormatter(final CallContext context) { | |
355 return Formatter.getFlowDepth(context); | |
356 } | |
357 }; | |
358 public static final SInfoResultType flowdepthHistorical = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_FLOWDEPTH_HISTORICAL_HEADER) { | |
359 @Override | |
360 public String exportValue(final CallContext context, final Object value) { | |
361 final double doubleValue = asDouble(value); | |
362 return exportDoubleValue(context, doubleValue); | |
363 } | |
364 | |
365 @Override | |
366 protected NumberFormat createFormatter(final CallContext context) { | |
367 return Formatter.getFlowDepth(context); | |
368 } | |
369 }; | |
370 | |
8948 | 371 } |