[PATCH] issue1439: Show line segments for points that have gaps on both sides. Small refac

Wald Commits scm-commit at wald.intevation.org
Thu Aug 8 10:29:21 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1375951116 -7200
# Node ID cbe9ac4380a548b47a6af36e761bf125a9041073
# Parent  48f6780c372d4e73a56b3c2737b3a496a29f5a7f
issue1439: Show line segments for points that have gaps on both sides. Small refac.

diff -r 48f6780c372d -r cbe9ac4380a5 artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java	Wed Aug 07 19:36:05 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java	Thu Aug 08 10:38:36 2013 +0200
@@ -49,6 +49,7 @@
      *                 the NaNs lead to gaps in graph.
      * @param distance if two consecutive entries in points[0] are more
      *                 than distance apart, create a NaN value to skip in display.
+     *                 Still, create a line segment.
      */
     public static void addPoints(XYSeries series, double[][] points, boolean skipNANs, double distance) {
         if (points == null || points.length <= 1) {
@@ -64,6 +65,11 @@
             }
             // Create gap if distance >= distance.
             if (i != 0 && Math.abs(xPoints[i-1] - xPoints[i]) >= distance) {
+                // Create at least a small segment for last point.
+                if (!Double.isNaN(yPoints[i-1])) {
+                    series.add(xPoints[i-1]+0.99d*(distance)/2.d, yPoints[i-1], false);
+                }
+
                 if (!Double.isNaN(yPoints[i-1]) && !Double.isNaN(yPoints[i])) {
                     series.add((xPoints[i-1]+xPoints[i])/2.d, Double.NaN, false);
                 }
diff -r 48f6780c372d -r cbe9ac4380a5 artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Wed Aug 07 19:36:05 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java	Thu Aug 08 10:38:36 2013 +0200
@@ -26,6 +26,8 @@
     private final static Logger logger =
             Logger.getLogger(BedDiffHeightYearProcessor.class);
 
+    protected static double GAP_TOLERANCE = 0.101d;
+
     @Override
     public void doOut(
             XYChartGenerator generator,
@@ -62,7 +64,7 @@
         int axidx) {
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
-        StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), false, 0.101d);
+        StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), false, GAP_TOLERANCE);
 
         generator.addAxisSeries(series, axidx, visible);
     }
diff -r 48f6780c372d -r cbe9ac4380a5 artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Wed Aug 07 19:36:05 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Thu Aug 08 10:38:36 2013 +0200
@@ -26,6 +26,8 @@
     private final static Logger logger =
             Logger.getLogger(BedDiffYearProcessor.class);
 
+    protected static double GAP_TOLERANCE = 0.101d;
+
     @Override
     public void doOut(
             XYChartGenerator generator,
@@ -71,10 +73,10 @@
 
         XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr);
         if (idx == 0) {
-            StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), false, 0.101d);
+            StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), false, GAP_TOLERANCE);
         }
         else {
-            StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), false, 0.101d);
+            StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), false, GAP_TOLERANCE);
         }
 
         generator.addAxisSeries(series, axidx, visible);


More information about the Dive4elements-commits mailing list