diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java @ 2674:2be59d5b342c

Added and respect theme prop whether or not to display (not yet calculated) middle height. flys-artifacts/trunk@4368 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 09 May 2012 20:05:46 +0000
parents 0143b44631cc
children 22c8a9b4de31
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Wed May 09 19:03:54 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Wed May 09 20:05:46 2012 +0000
@@ -58,7 +58,19 @@
         return sum;
     }
 
-    public static List<Line2D> fillWater(List<Point2D> points, double waterLevel) {
+
+    /** List of lines and a double-precision area. */
+    private static class ListWithArea {
+        public List<Line2D> lines;
+        public double area;
+        public ListWithArea(List<Line2D> lines, double area) {
+            this.lines = lines;
+            this.area = area;
+        }
+    }
+
+
+    public static ListWithArea fillWater(List<Point2D> points, double waterLevel) {
 
         boolean debug = log.isDebugEnabled();
 
@@ -72,7 +84,7 @@
         int N = points.size();
 
         if (N == 0) {
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         if (N == 1) {
@@ -83,7 +95,7 @@
                     p.getX(), waterLevel,
                     p.getX(), waterLevel));
             }
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         double minX =  Double.MAX_VALUE;
@@ -103,13 +115,13 @@
 
         if (minY > waterLevel) { // profile completely over water level
             log.debug("complete over water");
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         if (waterLevel > maxY) { // water floods profile
             log.debug("complete under water");
             result.add(new Line2D.Double(minX, waterLevel, maxX, waterLevel));
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         // Water is sometimes above, sometimes under profile.
@@ -292,7 +304,7 @@
                 maxX, waterLevel));
         }
 
-        return result;
+        return new ListWithArea(result, area);
     }
 
 
@@ -315,7 +327,8 @@
         List<Point2D> points,
         double        waterlevel
     ) {
-        List<Line2D> lines = fillWater(points, waterlevel);
+        ListWithArea listAndArea = fillWater(points, waterlevel);
+        List<Line2D> lines = listAndArea.lines;
 
         TDoubleArrayList lxs = new TDoubleArrayList();
         TDoubleArrayList lys = new TDoubleArrayList();
@@ -343,7 +356,7 @@
 
         return new LineData(
             new double [][] { lxs.toNativeArray(), lys.toNativeArray() },
-            linesLength, 0d
+            linesLength, listAndArea.area
             );
     }
 }

http://dive4elements.wald.intevation.org