Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMissVolCalculationResult2.java @ 9455:5f81d3f7b82b
pdf export disabled flag
author | gernotbelger |
---|---|
date | Thu, 23 Aug 2018 16:32:53 +0200 |
parents | 7e1fb8d0cb0d |
children | 3fa8551c3d1b |
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; | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
25 import org.dive4elements.river.model.BedHeightValueType; |
9331 | 26 |
27 /** | |
28 * Contains the results of a //TODO LINK{@link BezugswstCalculation}. | |
29 * | |
30 * @author Gernot Belger | |
31 */ | |
9332 | 32 final class BezugswstMissVolCalculationResult2 extends AbstractCalculationExportableResult implements BunduWstExporter.MissResultType { |
9331 | 33 |
34 private static final long serialVersionUID = 1L; | |
35 | |
36 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
|
37 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
|
38 private static final String fieldMassMsgKey = "bundu.export.bezugswst.csv.meta.miss.mass.field"; |
9331 | 39 |
40 public BezugswstMissVolCalculationResult2(final String label, final Collection<ResultRow> rows) { | |
41 super(label, rows); | |
42 | |
43 } | |
44 | |
45 @Override | |
9455 | 46 protected boolean pdfExportEnabled() { |
47 return false; | |
48 } | |
49 | |
50 @Override | |
9331 | 51 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { |
52 // no metadata | |
53 } | |
54 | |
55 @Override | |
56 protected String getJasperFile() { | |
57 return JASPER_FILE; | |
58 } | |
59 | |
60 protected String[] formatRow(final AbstractExportContext exportContext, final ResultRow row) { | |
61 | |
62 final Collection<String> lines = new ArrayList<>(20); | |
63 | |
64 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
65 @SuppressWarnings("unchecked") |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
66 final List<Double> vFields = (List<Double>) row.getValue(BunduResultType.missVolumeFields); |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
67 assert (vFields.size() == fieldSize()); // immer abgleichen mit der Calculation! |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
68 @SuppressWarnings("unchecked") |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
69 final List<Double> mFields = (List<Double>) row.getValue(BunduResultType.missMassFields); |
9448 | 70 assert (vFields.size() == mFields.size()); |
71 for (int i = 0; i < vFields.size(); i++) { | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
72 lines.add(BunduResultType.missVolumeFields.exportValue(exportContext.getContext(), vFields.get(i))); |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
73 lines.add(BunduResultType.missMassFields.exportValue(exportContext.getContext(), mFields.get(i))); |
9331 | 74 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
75 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
|
76 lines.add(exportContext.formatRowValue(row, BunduResultType.missMassMeanBed)); |
9331 | 77 |
78 return lines.toArray(new String[lines.size()]); | |
79 } | |
80 | |
81 @Override | |
82 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
83 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
84 final int colSize = 2 * fieldSize() + 3; |
9331 | 85 exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.result2", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
86 final Collection<String> header = new ArrayList<>(colSize); | |
87 | |
88 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
89 | |
9450
7e1fb8d0cb0d
Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
9448
diff
changeset
|
90 for (int i = 1, j = 1; i <= fieldSize() * 2; i += 2, j++) { |
7e1fb8d0cb0d
Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
9448
diff
changeset
|
91 header.add(exportContextCSV.msg(fieldVolumeMsgKey, j)); |
7e1fb8d0cb0d
Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
9448
diff
changeset
|
92 header.add(exportContextCSV.msg(fieldMassMsgKey, j)); |
9331 | 93 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
94 header.add(exportContextCSV.formatCsvHeader(BunduResultType.missVolumeMeanBed)); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
95 header.add(exportContextCSV.formatCsvHeader(BunduResultType.missMassMeanBed)); |
9331 | 96 |
97 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
98 | |
99 } | |
100 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
101 /** |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
102 * Number of elements of the various field lists |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
103 */ |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
104 private int fieldSize() { |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
105 return BedHeightValueType.FIELD_LAST_INDEX - BedHeightValueType.FIELD_FIRST_INDEX + 1; |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
106 } |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
107 |
9331 | 108 @Override |
109 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
110 | |
111 return this.formatRow(exportContextCSV, row); | |
112 } | |
113 | |
114 @Override | |
115 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
116 | |
117 return this.formatRow(exportContextPDF, row); | |
118 } | |
119 | |
120 @Override | |
121 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
122 /* column headings */ | |
123 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
124 // TODO Auftrennung jeder Volumen+Masse-Spalte in zwei getrennte Volumen- und Masse-Spalten |
9331 | 125 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
126 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
|
127 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
|
128 exportContextPDF.addJRMetadata(source, "field_header" + String.valueOf(i), exportContextPDF.msg(fieldMassMsgKey, i)); |
9331 | 129 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
130 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
|
131 exportContextPDF.addJRMetadata(source, "mean_bedheight_header", BunduResultType.missMassMeanBed); |
9331 | 132 |
133 } | |
134 } |