diff 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
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcOverviewResult.java	Mon Jul 02 13:00:59 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcOverviewResult.java	Mon Jul 02 17:40:39 2018 +0200
@@ -16,11 +16,14 @@
 import org.dive4elements.river.artifacts.common.ExportContextCSV;
 import org.dive4elements.river.artifacts.common.ExportContextPDF;
 import org.dive4elements.river.artifacts.common.GeneralResultType;
+import org.dive4elements.river.artifacts.common.IResultType;
 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
 import org.dive4elements.river.artifacts.common.ResultRow;
 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
 
+import gnu.trove.TDoubleArrayList;
+
 /**
  * Contains the results of a {@link CollisionCalculation}.
  *
@@ -32,8 +35,36 @@
 
     private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml";
 
-    public CollisionCalcOverviewResult(final String label, final Collection<ResultRow> rows) {
+    private final int[] singleYears;
+
+    public CollisionCalcOverviewResult(final String label, final int[] singleYears, final Collection<ResultRow> rows) {
         super(label, rows);
+        this.singleYears = singleYears;
+    }
+
+    public int[] getSingleYears() {
+        return this.singleYears;
+    }
+
+    @Override
+    public double[][] getStationPoints(final IResultType type, final int index) {
+
+        final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size());
+        final TDoubleArrayList yPoints = new TDoubleArrayList(this.rows.size());
+
+        for (final ResultRow row : this.rows) {
+
+            if ((this.singleYears == null) || (Integer.valueOf(row.getValue(SInfoResultType.years).toString()) == this.singleYears[index])) {
+
+                final double station = row.getDoubleValue(GeneralResultType.station);
+                final double value = row.getDoubleValue(type);
+
+                xPoints.add(station);
+                yPoints.add(value);
+            }
+        }
+
+        return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() };
     }
 
     @Override
@@ -45,7 +76,7 @@
     public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
         final int colSize = 3;
         exportContextCSV.writeTitleForTabs("sinfo.export.csv.title.collison.overview", 3); // Voraussetzung für Tabs ist, dass der Titel vor den Headern
-                                                                                           // geschrieben wird.
+        // geschrieben wird.
         // Das ist etwas doof.
 
         final Collection<String> header = new ArrayList<>(colSize);

http://dive4elements.wald.intevation.org