Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcOverviewResult.java @ 9157:f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
author | mschaefer |
---|---|
date | Tue, 19 Jun 2018 14:19:32 +0200 |
parents | 23945061daec |
children | f1be005f0c46 |
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 /** | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
24 * Contains the results of a {@link CollisionCalculation}. |
9150 | 25 * |
26 * @author Gernot Belger | |
27 */ | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
28 final public class CollisionCalcOverviewResult extends AbstractCalculationExportableResult<CollisionCalculationResults> { |
9150 | 29 |
30 private static final long serialVersionUID = 1L; | |
31 | |
32 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml"; | |
33 | |
34 public CollisionCalcOverviewResult(final String label, final Collection<ResultRow> rows) { | |
35 super(label, rows); | |
36 } | |
37 | |
38 @Override | |
39 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results) { | |
40 // TODO Auto-generated method stub | |
41 // final WstInfo wst = result.getWst(); | |
42 // exportContext.writeCSVWaterlevelMetadata(writer, wst); | |
43 } | |
44 | |
45 @Override | |
46 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final RiverInfo river) { | |
47 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
48 final Collection<String> header = new ArrayList<>(3); |
9150 | 49 |
50 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
51 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.years)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
52 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.collisionCount)); |
9150 | 53 |
54 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
55 } | |
56 | |
57 @Override | |
58 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
59 return formatRow(exportContextCSV, results, row); | |
60 } | |
61 | |
62 @Override | |
63 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
|
64 final Collection<String> lines = new ArrayList<>(3); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
65 |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
66 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
67 |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
68 return lines.toArray(new String[lines.size()]); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
69 // return formatRow(exportContextCSV, results, row); |
9150 | 70 } |
71 | |
72 private String[] formatRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
73 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
74 final Collection<String> lines = new ArrayList<>(3); |
9150 | 75 |
76 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
77 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.years)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
78 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.collisionCount)); |
9150 | 79 |
80 return lines.toArray(new String[lines.size()]); | |
81 } | |
82 | |
83 @Override | |
84 protected String getJasperFile() { | |
85 return JASPER_FILE; | |
86 } | |
87 | |
88 @Override | |
89 protected void addJRTableHeader(final ExportContextCSV exportContextCSV, final MetaAndTableJRDataSource source, final CollisionCalculationResults results) { | |
90 | |
91 /* column headings */ | |
92 exportContextCSV.addJRMetadata(source, "station_header", GeneralResultType.station); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
93 // exportContextCSV.addJRMetadata(source, "years_header", SInfoResultType.years); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
94 // exportContextCSV.addJRMetadata(source, "collisioncount_header", SInfoResultType.collisionCount); |
9150 | 95 } |
96 } |