changeset 7901:64930ceebac0

Fix for flys/issue1670: Introduce 100m gaps in single bed width.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 26 May 2014 12:40:19 +0200
parents af34cfbd7abc
children a7b218447e12
files artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java artifacts/src/main/java/org/dive4elements/river/jfree/GapInserter.java
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Wed May 21 17:26:12 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Mon May 26 12:40:19 2014 +0200
@@ -18,6 +18,7 @@
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.GapInserter;
 import org.dive4elements.river.jfree.StyledXYSeries;
 import org.dive4elements.river.themes.ThemeDocument;
 
@@ -37,6 +38,8 @@
     public static final String I18N_AXIS_LABEL =
         "chart.beddifference.yaxis.label.morph";
 
+    public static final double GAP_WIDTH = 100.0;
+
     @Override
     public void doOut(
             DiagramGenerator generator,
@@ -73,8 +76,10 @@
             double[] width = bData.getSoundingWidths();
             double[] stations = bData.getStations().toNativeArray();
 
+            GapInserter gi = new GapInserter(series, GAP_WIDTH);
+
             for (int i = 0; i < width.length; i++) {
-                series.add(stations[i], width[i], false);
+                gi.add(stations[i], width[i]);
             }
         } else if (data instanceof List<?>) {
             List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/GapInserter.java	Mon May 26 12:40:19 2014 +0200
@@ -0,0 +1,27 @@
+package org.dive4elements.river.jfree;
+
+import org.jfree.data.xy.XYSeries;
+
+public class GapInserter {
+
+    private XYSeries series;
+    private double   gap;
+    private double   lastX;
+
+    public GapInserter() {
+    }
+
+    public GapInserter(XYSeries series, double gap) {
+        lastX = Double.NaN;
+        this.series = series;
+        this.gap = Math.abs(gap);
+    }
+
+    public void add(double x, double y) {
+        if (!Double.isNaN(lastX) && !Double.isNaN(x) && Math.abs(x - lastX) > gap) {
+            series.add((x + lastX)/2.0, Double.NaN, false);
+        }
+        series.add(x, y, false);
+        lastX = x;
+    }
+}

http://dive4elements.wald.intevation.org