Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMissVolCalculationResult2.java @ 9444:ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author | mschaefer |
---|---|
date | Tue, 21 Aug 2018 13:41:18 +0200 |
parents | d194c5b24bf8 |
children | e60584f2a531 |
rev | line source |
---|---|
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9331 | 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.bundu.bezugswst; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 import java.util.List; | |
15 | |
16 import org.dive4elements.river.artifacts.bundu.BunduResultType; | |
17 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | |
18 import org.dive4elements.river.artifacts.common.AbstractExportContext; | |
19 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
20 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
21 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
22 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
23 import org.dive4elements.river.artifacts.common.ResultRow; | |
24 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
25 | |
26 /** | |
27 * Contains the results of a //TODO LINK{@link BezugswstCalculation}. | |
28 * | |
29 * @author Gernot Belger | |
30 */ | |
9332 | 31 final class BezugswstMissVolCalculationResult2 extends AbstractCalculationExportableResult implements BunduWstExporter.MissResultType { |
9331 | 32 |
33 private static final long serialVersionUID = 1L; | |
34 | |
35 private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.result2.jrxml"; | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
36 private static final String fieldVolumeMsgKey = "bundu.export.bezugswst.csv.meta.miss.volume.field"; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
37 private static final String fieldMassMsgKey = "bundu.export.bezugswst.csv.meta.miss.mass.field"; |
9331 | 38 private static final int fieldSize = 10; |
39 | |
40 public BezugswstMissVolCalculationResult2(final String label, final Collection<ResultRow> rows) { | |
41 super(label, rows); | |
42 | |
43 } | |
44 | |
45 @Override | |
46 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
47 // no metadata | |
48 } | |
49 | |
50 @Override | |
51 protected String getJasperFile() { | |
52 return JASPER_FILE; | |
53 } | |
54 | |
55 protected String[] formatRow(final AbstractExportContext exportContext, final ResultRow row) { | |
56 | |
57 final Collection<String> lines = new ArrayList<>(20); | |
58 | |
59 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
60 final List<String> vFields = (List<String>) row.getValue(BunduResultType.missVolumeFields); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
61 assert (vFields.size() == fieldSize); // immer abgleichen mit der Calculation! |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
62 final List<String> mFields = (List<String>) row.getValue(BunduResultType.missMassFields); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
63 for (int i = 0; i <= vFields.size() - 1; i++) { |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
64 lines.add(vFields.get(i)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
65 lines.add(mFields.get(i)); |
9331 | 66 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
67 lines.add(exportContext.formatRowValue(row, BunduResultType.missVolumeMeanBed)); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
68 lines.add(exportContext.formatRowValue(row, BunduResultType.missMassMeanBed)); |
9331 | 69 |
70 return lines.toArray(new String[lines.size()]); | |
71 } | |
72 | |
73 @Override | |
74 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
75 | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
76 final int colSize = 2 * fieldSize + 2; |
9331 | 77 exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.result2", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
78 final Collection<String> header = new ArrayList<>(colSize); | |
79 | |
80 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
81 | |
82 for (int i = 1; i <= fieldSize; i++) { | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
83 header.add(exportContextCSV.msg(fieldVolumeMsgKey, i)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
84 header.add(exportContextCSV.msg(fieldMassMsgKey, i)); |
9331 | 85 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
86 header.add(exportContextCSV.formatCsvHeader(BunduResultType.missVolumeMeanBed)); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
87 header.add(exportContextCSV.formatCsvHeader(BunduResultType.missMassMeanBed)); |
9331 | 88 |
89 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
90 | |
91 } | |
92 | |
93 @Override | |
94 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
95 | |
96 return this.formatRow(exportContextCSV, row); | |
97 } | |
98 | |
99 @Override | |
100 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
101 | |
102 return this.formatRow(exportContextPDF, row); | |
103 } | |
104 | |
105 @Override | |
106 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
107 /* column headings */ | |
108 | |
109 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | |
110 for (int i = 1; i <= fieldSize; i++) { | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
111 exportContextPDF.addJRMetadata(source, "field_header" + String.valueOf(i), exportContextPDF.msg(fieldVolumeMsgKey, i)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
112 exportContextPDF.addJRMetadata(source, "field_header" + String.valueOf(i), exportContextPDF.msg(fieldMassMsgKey, i)); |
9331 | 113 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
114 exportContextPDF.addJRMetadata(source, "mean_bedheight_header", BunduResultType.missVolumeMeanBed); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
115 exportContextPDF.addJRMetadata(source, "mean_bedheight_header", BunduResultType.missMassMeanBed); |
9331 | 116 |
117 } | |
118 } |