Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcDetailResult.java @ 9171:f1be005f0c46
tab titles from server
author | gernotbelger |
---|---|
date | Fri, 22 Jun 2018 11:02:59 +0200 |
parents | f9bb5d0a6ff3 |
children | 3ace6db2f87b |
rev | line source |
---|---|
9150 | 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.sinfo.collision; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 | |
15 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | |
16 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
17 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
18 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
19 import org.dive4elements.river.artifacts.common.ResultRow; | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
20 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
9150 | 21 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
22 | |
23 /** | |
24 * Contains the results of a {@link FloodDurationCalculation}. | |
25 * | |
26 * @author Gernot Belger | |
27 */ | |
28 final class CollisionCalcDetailResult extends AbstractCalculationExportableResult<CollisionCalculationResults> { | |
29 | |
30 private static final long serialVersionUID = 1L; | |
31 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.detail.jrxml"; | |
32 | |
33 public CollisionCalcDetailResult(final String label, final Collection<ResultRow> rows) { | |
34 super(label, rows); | |
35 } | |
36 | |
37 @Override | |
38 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results) { | |
9171 | 39 |
9150 | 40 exportContextCSV.writeBlankLine(); |
41 } | |
42 | |
43 @Override | |
44 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final RiverInfo river) { | |
45 | |
9171 | 46 final int colSize = 6; |
47 exportContextCSV.writeTitleForTabs("sinfo.export.csv.title.collision.detail", 6); // Voraussetzung für Tabs ist, dass der Titel vor den Headern | |
48 // geschrieben wird. | |
49 // Das ist etwas doof. | |
50 | |
51 final Collection<String> header = new ArrayList<>(colSize); | |
9150 | 52 |
53 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
54 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.date)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
55 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.collisionGaugeW)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
56 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
57 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.discharge)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
58 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.dischargeZone)); |
9150 | 59 |
9171 | 60 exportContextCSV.writeCSVLine(header.toArray(new String[colSize])); |
9150 | 61 } |
62 | |
63 @Override | |
64 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
65 return formatRow(exportContextCSV, results, row); | |
66 } | |
67 | |
68 @Override | |
69 protected String[] formatPDFRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
70 /* |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
71 * final Collection<String> lines = new ArrayList<>(6); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
72 * lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
73 * return lines.toArray(new String[lines.size()]); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
74 */ |
9150 | 75 return formatRow(exportContextCSV, results, row); |
76 } | |
77 | |
78 private String[] formatRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
79 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
80 final Collection<String> lines = new ArrayList<>(6); |
9150 | 81 |
82 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
83 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.date)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
84 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.collisionGaugeW)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
85 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
86 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.discharge)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
87 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.dischargeZone)); |
9150 | 88 |
89 return lines.toArray(new String[lines.size()]); | |
90 } | |
91 | |
92 @Override | |
93 protected String getJasperFile() { | |
94 return JASPER_FILE; | |
95 } | |
96 | |
97 @Override | |
98 protected void addJRTableHeader(final ExportContextCSV exportContextCSV, final MetaAndTableJRDataSource source, final CollisionCalculationResults results) { | |
99 | |
100 /* column headings */ | |
101 exportContextCSV.addJRMetadata(source, "station_header", GeneralResultType.station); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
102 exportContextCSV.addJRMetadata(source, "date_header", GeneralResultType.date); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
103 exportContextCSV.addJRMetadata(source, "gaugew_header", SInfoResultType.collisionGaugeW); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
104 exportContextCSV.addJRMetadata(source, "gaugelabel_header", SInfoResultType.gaugeLabel); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
105 exportContextCSV.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
106 exportContextCSV.addJRMetadata(source, "dischargezone_header", SInfoResultType.dischargeZone); |
9150 | 107 } |
108 } |