[PATCH] Fix for flys/issue1670: Introduce 100m gaps in single bed width

Wald Commits scm-commit at wald.intevation.org
Mon May 26 12:40:36 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1401100819 -7200
# Node ID 64930ceebac05ac312aaa95d8e22df079e542cd9
# Parent  af34cfbd7abcdad21e184f9312a28c383b1b7c3f
Fix for flys/issue1670: Introduce 100m gaps in single bed width.

diff -r af34cfbd7abc -r 64930ceebac0 artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java
--- 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;
diff -r af34cfbd7abc -r 64930ceebac0 artifacts/src/main/java/org/dive4elements/river/jfree/GapInserter.java
--- /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;
+    }
+}


More information about the Dive4Elements-commits mailing list