changeset 6778:cbe9ac4380a5

issue1439: Show line segments for points that have gaps on both sides. Small refac.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 08 Aug 2013 10:38:36 +0200
parents 48f6780c372d
children 8e5adc56385c
files artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java
diffstat 3 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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);
                 }
--- 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);
     }
--- 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);

http://dive4elements.wald.intevation.org