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