Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextCSV.java @ 9188:3931e8741f53
Minor cleanup and bugfix concerning number formatters
author | gernotbelger |
---|---|
date | Thu, 28 Jun 2018 13:14:44 +0200 |
parents | f1be005f0c46 |
children | a4121ec450d6 |
comparison
equal
deleted
inserted
replaced
9187:b3c11c5fdbd5 | 9188:3931e8741f53 |
---|---|
48 | 48 |
49 private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel"; | 49 private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel"; |
50 | 50 |
51 private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel.original"; | 51 private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel.original"; |
52 | 52 |
53 private static NumberFormat qFormat = null; | 53 private NumberFormat qFormat = null; |
54 | 54 |
55 private static NumberFormat flowDepthFormat = null; | 55 private NumberFormat flowDepthFormat = null; |
56 | 56 |
57 private NumberFormat kmFormat; | 57 private NumberFormat kmFormat = null; |
58 | 58 |
59 /** The CallContext object. */ | 59 /** The CallContext object. */ |
60 private final CallContext context; | 60 private final CallContext context; |
61 | 61 |
62 private final CSVWriter writer; | 62 private final CSVWriter writer; |
81 this.writer.writeNext(new String[] { Resources.getMsg(meta, message, message, messageArgs) }); | 81 this.writer.writeNext(new String[] { Resources.getMsg(meta, message, message, messageArgs) }); |
82 } | 82 } |
83 | 83 |
84 public void writeBlankLine() { | 84 public void writeBlankLine() { |
85 writeCSVLine(new String[] { "" }); | 85 writeCSVLine(new String[] { "" }); |
86 | |
87 } | 86 } |
88 | 87 |
89 // *** CUSTOM STUFF that is used multiple times ***/// | 88 // *** CUSTOM STUFF that is used multiple times ***/// |
90 | 89 |
91 public final void writeCSVSoundingMetadata(final BedHeightInfo sounding) { | 90 public final void writeCSVSoundingMetadata(final BedHeightInfo sounding) { |
108 | 107 |
109 public void addJRMetadata(final MetaAndTableJRDataSource source, final String key, final IResultType type) { | 108 public void addJRMetadata(final MetaAndTableJRDataSource source, final String key, final IResultType type) { |
110 source.addMetaData(key, type.getPdfHeader(this.context.getMeta())); | 109 source.addMetaData(key, type.getPdfHeader(this.context.getMeta())); |
111 } | 110 } |
112 | 111 |
113 public final void writeCSVGlobalMetadataDefaults(final AbstractCalculationResults results) { | 112 public final void writeCSVGlobalMetadataDefaults(final AbstractCalculationResults<?> results) { |
114 // TODO: results as member | 113 // TODO: results as member |
115 final String calcModeLabel = results.getCalcModeLabel(); | 114 final String calcModeLabel = results.getCalcModeLabel(); |
116 final RiverInfo river = results.getRiver(); | 115 final RiverInfo river = results.getRiver(); |
117 final DoubleRange calcRange = results.getCalcRange(); | 116 final DoubleRange calcRange = results.getCalcRange(); |
118 | 117 |
163 } | 162 } |
164 | 163 |
165 // copy from AbstractExporter TODO merge with ExportContextPDF | 164 // copy from AbstractExporter TODO merge with ExportContextPDF |
166 protected NumberFormat getKmFormatter() { | 165 protected NumberFormat getKmFormatter() { |
167 | 166 |
168 if (this.kmFormat == null) { | 167 if (this.kmFormat == null) |
169 this.kmFormat = Formatter.getWaterlevelKM(this.context); | 168 this.kmFormat = Formatter.getWaterlevelKM(this.context); |
170 } | 169 |
171 return this.kmFormat; | 170 return this.kmFormat; |
172 } | 171 } |
173 | 172 |
174 public void addJRMetadata(final MetaAndTableJRDataSource source, final String key, final String msg) { | 173 public void addJRMetadata(final MetaAndTableJRDataSource source, final String key, final String msg) { |
175 source.addMetaData(key, msg); | 174 source.addMetaData(key, msg); |
176 | |
177 } | 175 } |
178 | 176 |
179 public NumberFormat getQFormatter() { | 177 public NumberFormat getQFormatter() { |
180 if (this.qFormat == null) { | 178 if (this.qFormat == null) |
181 this.qFormat = Formatter.getWaterlevelQ(this.context); | 179 this.qFormat = Formatter.getWaterlevelQ(this.context); |
182 } | 180 |
183 return this.qFormat; | 181 return this.qFormat; |
184 } | 182 } |
185 | 183 |
186 public final NumberFormat getFlowDepthFormatter() { | 184 public final NumberFormat getFlowDepthFormatter() { |
187 if (this.flowDepthFormat == null) | 185 if (this.flowDepthFormat == null) |
188 this.flowDepthFormat = Formatter.getFlowDepth(this.context); | 186 this.flowDepthFormat = Formatter.getFlowDepth(this.context); |
187 | |
189 return this.flowDepthFormat; | 188 return this.flowDepthFormat; |
190 } | 189 } |
191 | 190 |
192 /** | 191 /** |
193 * Formats header with unit: msg [unit] | 192 * Formats header with unit: msg [unit] |
229 return String.format("%s [%s] (%s)", msg, unit, label); | 228 return String.format("%s [%s] (%s)", msg, unit, label); |
230 } | 229 } |
231 | 230 |
232 public String msgPdf(final SInfoResultType type) { | 231 public String msgPdf(final SInfoResultType type) { |
233 return type.getPdfHeader(this.context.getMeta()); | 232 return type.getPdfHeader(this.context.getMeta()); |
234 | |
235 } | 233 } |
236 | 234 |
237 public void writeTitleForTabs(final String tabTitleMsg, final int colSize) { | 235 public void writeTitleForTabs(final String tabTitleMsg, final int colSize) { |
238 | 236 |
239 final Collection<String> title = new ArrayList<>(colSize); | 237 final Collection<String> title = new ArrayList<>(colSize); |