Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java @ 9205:3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
author | gernotbelger |
---|---|
date | Mon, 02 Jul 2018 19:01:09 +0200 |
parents | a4121ec450d6 |
children | da0bdbcd6f09 |
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; | |
26 | |
27 private NumberFormat kmFormat = null; | |
28 | |
29 /** The CallContext object. */ | |
30 private final CallContext context; | |
31 | |
32 private final AbstractCalculationResults<?> results; | |
33 | |
34 public AbstractExportContext(final CallContext context, final AbstractCalculationResults<?> results) { | |
35 this.context = context; | |
36 this.results = results; | |
37 } | |
38 | |
39 protected final CallContext getContext() { | |
40 return this.context; | |
41 } | |
42 | |
43 @Override | |
44 public final <RESULTS extends AbstractCalculationResults<?>> RESULTS getResults() { | |
45 @SuppressWarnings("unchecked") | |
46 final RESULTS resultsCast = (RESULTS) this.results; | |
47 return resultsCast; | |
48 } | |
49 | |
50 // copy from AbstractExporter TODO merge with ExportContextPDF | |
51 protected NumberFormat getKmFormatter() { | |
52 | |
53 if (this.kmFormat == null) | |
54 this.kmFormat = Formatter.getWaterlevelKM(getContext()); | |
55 | |
56 return this.kmFormat; | |
57 } | |
58 | |
59 public NumberFormat getQFormatter() { | |
60 if (this.qFormat == null) | |
61 this.qFormat = Formatter.getWaterlevelQ(this.context); | |
62 | |
63 return this.qFormat; | |
64 } | |
65 | |
66 public final NumberFormat getFlowDepthFormatter() { | |
67 if (this.flowDepthFormat == null) | |
68 this.flowDepthFormat = Formatter.getFlowDepth(this.context); | |
69 | |
70 return this.flowDepthFormat; | |
71 } | |
72 | |
73 protected String msg(final String key) { | |
74 return Resources.getMsg(this.context.getMeta(), key, key); | |
75 } | |
76 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9195
diff
changeset
|
77 public final String msg(final String key, final Object... args) { |
9195 | 78 return Resources.getMsg(this.context.getMeta(), key, key, args); |
79 } | |
80 | |
81 @Override | |
82 public final String formatRowValue(final ResultRow row, final IResultType type) { | |
83 return row.exportValue(this.context, type); | |
84 } | |
85 } |