comparison artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractExportContext.java @ 9195:a4121ec450d6

'ca.'-issue ExportContextCSV+PDF separated uinfo.inundationduration url export
author gernotbelger
date Fri, 29 Jun 2018 14:52:54 +0200
parents
children 3dae6b78e1da
comparison
equal deleted inserted replaced
9191:f692f5a0536a 9195:a4121ec450d6
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
77 protected final String msg(final String key, final Object... args) {
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 }

http://dive4elements.wald.intevation.org