Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcOverviewResult.java @ 9204:4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
author | mschaefer |
---|---|
date | Mon, 02 Jul 2018 17:40:39 +0200 |
parents | a4121ec450d6 |
children | 3dae6b78e1da |
comparison
equal
deleted
inserted
replaced
9203:9831f6c60473 | 9204:4f411c6ee3ae |
---|---|
14 | 14 |
15 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | 15 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
16 import org.dive4elements.river.artifacts.common.ExportContextCSV; | 16 import org.dive4elements.river.artifacts.common.ExportContextCSV; |
17 import org.dive4elements.river.artifacts.common.ExportContextPDF; | 17 import org.dive4elements.river.artifacts.common.ExportContextPDF; |
18 import org.dive4elements.river.artifacts.common.GeneralResultType; | 18 import org.dive4elements.river.artifacts.common.GeneralResultType; |
19 import org.dive4elements.river.artifacts.common.IResultType; | |
19 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | 20 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; |
20 import org.dive4elements.river.artifacts.common.ResultRow; | 21 import org.dive4elements.river.artifacts.common.ResultRow; |
21 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | 22 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
22 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | 23 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
24 | |
25 import gnu.trove.TDoubleArrayList; | |
23 | 26 |
24 /** | 27 /** |
25 * Contains the results of a {@link CollisionCalculation}. | 28 * Contains the results of a {@link CollisionCalculation}. |
26 * | 29 * |
27 * @author Gernot Belger | 30 * @author Gernot Belger |
30 | 33 |
31 private static final long serialVersionUID = 1L; | 34 private static final long serialVersionUID = 1L; |
32 | 35 |
33 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml"; | 36 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml"; |
34 | 37 |
35 public CollisionCalcOverviewResult(final String label, final Collection<ResultRow> rows) { | 38 private final int[] singleYears; |
39 | |
40 public CollisionCalcOverviewResult(final String label, final int[] singleYears, final Collection<ResultRow> rows) { | |
36 super(label, rows); | 41 super(label, rows); |
42 this.singleYears = singleYears; | |
43 } | |
44 | |
45 public int[] getSingleYears() { | |
46 return this.singleYears; | |
47 } | |
48 | |
49 @Override | |
50 public double[][] getStationPoints(final IResultType type, final int index) { | |
51 | |
52 final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size()); | |
53 final TDoubleArrayList yPoints = new TDoubleArrayList(this.rows.size()); | |
54 | |
55 for (final ResultRow row : this.rows) { | |
56 | |
57 if ((this.singleYears == null) || (Integer.valueOf(row.getValue(SInfoResultType.years).toString()) == this.singleYears[index])) { | |
58 | |
59 final double station = row.getDoubleValue(GeneralResultType.station); | |
60 final double value = row.getDoubleValue(type); | |
61 | |
62 xPoints.add(station); | |
63 yPoints.add(value); | |
64 } | |
65 } | |
66 | |
67 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; | |
37 } | 68 } |
38 | 69 |
39 @Override | 70 @Override |
40 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | 71 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { |
41 // do nothing so far | 72 // do nothing so far |
43 | 74 |
44 @Override | 75 @Override |
45 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | 76 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { |
46 final int colSize = 3; | 77 final int colSize = 3; |
47 exportContextCSV.writeTitleForTabs("sinfo.export.csv.title.collison.overview", 3); // Voraussetzung für Tabs ist, dass der Titel vor den Headern | 78 exportContextCSV.writeTitleForTabs("sinfo.export.csv.title.collison.overview", 3); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
48 // geschrieben wird. | 79 // geschrieben wird. |
49 // Das ist etwas doof. | 80 // Das ist etwas doof. |
50 | 81 |
51 final Collection<String> header = new ArrayList<>(colSize); | 82 final Collection<String> header = new ArrayList<>(colSize); |
52 | 83 |
53 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | 84 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); |