[PATCH 2 of 2] (issue1670) Remove 99-percent copy-paste method, which had been used only once

Wald Commits scm-commit at wald.intevation.org
Mon Apr 20 15:02:07 CEST 2015


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1429527532 -7200
# Node ID 5dea205ea3e7dc2d649dfd2e616568660487d731
# Parent  5abbccb13e458549b44d251a72ce7b966c75ec2d
(issue1670) Remove 99-percent copy-paste method, which had been used only once.

diff -r 5abbccb13e45 -r 5dea205ea3e7 artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java	Mon Apr 20 12:50:00 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java	Mon Apr 20 12:58:52 2015 +0200
@@ -40,52 +40,6 @@
 
 
     /**
-     * Add points to series, create gaps if certain distance between
-     * points is met and scale the Y value.
-     *
-     * @param series Series to add points to.
-     * @param points Points to add to series, points[0] to 1st dim, points[1]
-     *               to 2nd dim.
-     * @param skipNANs if true, skip NAN values in points parameter. Otherwise,
-     *                 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.
-     * @param factor   Factor by which to scale the y value (points[1]).
-     */
-    public static void addPointsFactorY(XYSeries series,
-        double[][] points,
-        boolean skipNANs,
-        double distance,
-        double factor
-    ) {
-        if (points == null || points.length <= 1) {
-            return;
-        }
-        double [] xPoints = points[0];
-        double [] yPoints = points[1];
-        for (int i = 0; i < xPoints.length; i++) {
-            if (skipNANs &&
-                (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) {
-                continue;
-            }
-            // 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]*factor, false);
-                }
-
-                if (!Double.isNaN(yPoints[i-1]) && !Double.isNaN(yPoints[i])) {
-                    series.add((xPoints[i-1]+xPoints[i])/2.d, Double.NaN, false);
-                }
-            }
-            series.add(xPoints[i], yPoints[i]*factor, false);
-        }
-    }
-
-
-    /**
      * Add points to series, create gaps if certain distance between points is met.
      *
      * @param series Series to add points to.
diff -r 5abbccb13e45 -r 5dea205ea3e7 artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Mon Apr 20 12:50:00 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java	Mon Apr 20 12:58:52 2015 +0200
@@ -66,14 +66,17 @@
             return;
         }
         double[][] bData = (double[][]) data;
+        for (int N = bData[0].length, i = 0; i < N; i++) {
+            // scale to cm
+            bData[1][i] *= 100d;
+        }
 
         StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
         series.putMetaData(metaData, bundle.getArtifact(), context);
-        StyledSeriesBuilder.addPointsFactorY(series,
+        StyledSeriesBuilder.addPoints(series,
             bData,
             false,
-            GAP_TOLERANCE,
-            100d);
+            GAP_TOLERANCE);
 
         generator.addAxisSeries(series, axisName, visible);
 
diff -r 5abbccb13e45 -r 5dea205ea3e7 artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java	Mon Apr 20 12:50:00 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java	Mon Apr 20 12:58:52 2015 +0200
@@ -88,11 +88,10 @@
         }
 
         double[][] data = (double[][])raw;
-        StyledSeriesBuilder.addPointsFactorY(series,
+        StyledSeriesBuilder.addPoints(series,
             data,
             false,
-            GAP_TOLERANCE,
-            1d);
+            GAP_TOLERANCE);
         return series;
     }
 


More information about the Dive4Elements-commits mailing list