Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java @ 9503:83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
author | mschaefer |
---|---|
date | Fri, 28 Sep 2018 10:11:06 +0200 |
parents | e60584f2a531 |
children |
rev | line source |
---|---|
9195 | 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.common; | |
11 | |
12 import java.text.NumberFormat; | |
13 | |
14 import org.dive4elements.artifacts.CallContext; | |
15 import org.dive4elements.river.artifacts.resources.Resources; | |
16 import org.dive4elements.river.utils.Formatter; | |
17 | |
18 /** | |
19 * @author Domenico Nardi Tironi | |
20 */ | |
21 public abstract class AbstractExportContext implements IExportContext { | |
22 | |
23 private NumberFormat qFormat = null; | |
24 | |
25 private NumberFormat flowDepthFormat = null; | |
9357
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
26 private NumberFormat floodDurationFormat = null; |
9243 | 27 private NumberFormat salixScenFormat = null; |
9195 | 28 private NumberFormat kmFormat = null; |
9503
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
29 private NumberFormat intFormat = null; |
9195 | 30 |
31 /** The CallContext object. */ | |
32 private final CallContext context; | |
33 | |
34 private final AbstractCalculationResults<?> results; | |
35 | |
36 public AbstractExportContext(final CallContext context, final AbstractCalculationResults<?> results) { | |
37 this.context = context; | |
38 this.results = results; | |
39 } | |
40 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9357
diff
changeset
|
41 public final CallContext getContext() { |
9195 | 42 return this.context; |
43 } | |
44 | |
45 @Override | |
46 public final <RESULTS extends AbstractCalculationResults<?>> RESULTS getResults() { | |
47 @SuppressWarnings("unchecked") | |
48 final RESULTS resultsCast = (RESULTS) this.results; | |
49 return resultsCast; | |
50 } | |
51 | |
52 // copy from AbstractExporter TODO merge with ExportContextPDF | |
53 protected NumberFormat getKmFormatter() { | |
54 | |
55 if (this.kmFormat == null) | |
56 this.kmFormat = Formatter.getWaterlevelKM(getContext()); | |
57 | |
58 return this.kmFormat; | |
59 } | |
60 | |
61 public NumberFormat getQFormatter() { | |
62 if (this.qFormat == null) | |
63 this.qFormat = Formatter.getWaterlevelQ(this.context); | |
64 | |
65 return this.qFormat; | |
66 } | |
67 | |
68 public final NumberFormat getFlowDepthFormatter() { | |
69 if (this.flowDepthFormat == null) | |
70 this.flowDepthFormat = Formatter.getFlowDepth(this.context); | |
71 | |
72 return this.flowDepthFormat; | |
73 } | |
74 | |
9357
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
75 public final NumberFormat getFloodDurationFormatter() { |
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
76 |
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
77 if (this.floodDurationFormat == null) |
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
78 this.floodDurationFormat = Formatter.getIntegerFormatter(this.context); |
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
79 return this.floodDurationFormat; |
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
80 } |
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9243
diff
changeset
|
81 |
9243 | 82 public final NumberFormat getSalixScenFormatter() { |
83 if (this.salixScenFormat == null) | |
84 this.salixScenFormat = Formatter.getSalixLine(this.context); | |
85 | |
86 return this.salixScenFormat; | |
87 } | |
88 | |
9503
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
89 public final NumberFormat getIntegerFormatter() { |
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
90 if (this.intFormat == null) |
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
91 this.intFormat = Formatter.getIntegerFormatter(this.context); |
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
92 |
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
93 return this.intFormat; |
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
94 } |
83e6acdf8fc6
Fixed: no rounding during calculations (Meilenstein-2 2.9)
mschaefer
parents:
9446
diff
changeset
|
95 |
9195 | 96 protected String msg(final String key) { |
97 return Resources.getMsg(this.context.getMeta(), key, key); | |
98 } | |
99 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9195
diff
changeset
|
100 public final String msg(final String key, final Object... args) { |
9195 | 101 return Resources.getMsg(this.context.getMeta(), key, key, args); |
102 } | |
103 | |
104 @Override | |
105 public final String formatRowValue(final ResultRow row, final IResultType type) { | |
106 return row.exportValue(this.context, type); | |
107 } | |
108 } |