changeset 3176:cbaa49896eca

Fix issue663 (step curves for longitudinal_section Qs). flys-artifacts/trunk@4791 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 25 Jun 2012 19:13:16 +0000
parents 4616436a84f4
children 585c0b49e696
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java
diffstat 3 files changed, 45 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jun 25 18:12:19 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jun 25 19:13:16 2012 +0000
@@ -1,3 +1,13 @@
+2012-06-25	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Fix issue663 ("step" curves for Q).
+
+	* src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java
+	  (addStepPointsKmQ): New, add "step" points for series.
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  Use new StyledSeriesBuilder function.
+
 2012-06-25	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Mon Jun 25 18:12:19 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Mon Jun 25 19:13:16 2012 +0000
@@ -42,11 +42,11 @@
 {
     public enum YAXIS {
         W(0),
-        Q(1),
-        D(2);
+        D(1),
+        Q(2);
         protected int idx;
         private YAXIS(int c) {
-           idx = c;
+            idx = c;
         }
     }
 
@@ -473,7 +473,6 @@
     }
 
 
-
     /**
      * Process the output for Q facets in a longitudinal section curve.
      *
@@ -494,7 +493,7 @@
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
-        StyledSeriesBuilder.addPointsKmQ(series, wqkms);
+        StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
 
         addAxisSeries(series, YAXIS.Q.idx, visible);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java	Mon Jun 25 18:12:19 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java	Mon Jun 25 19:13:16 2012 +0000
@@ -95,6 +95,37 @@
 
 
     /**
+     * Add points to series (km to 1st dim, q to 2nd dim), adding points
+     * to achieve a step-like curve.
+     *
+     * @param series Series to add points to.
+     * @param points Points to add to series.
+     */
+    public static void addStepPointsKmQ(XYSeries series, WQKms wqkms) {
+        if (wqkms == null) {
+            return;
+        }
+
+        int size = wqkms.size();
+
+        for (int i = 0; i < size; i++) {
+            if (i==0) {
+                series.add(wqkms.getKm(i), wqkms.getQ(i), false);
+            }
+            else {
+                //Add two points.
+                double halveX = (wqkms.getKm(i-1) + wqkms.getKm(i)) / 2d;
+                series.add(halveX, wqkms.getQ(i-1));
+                series.add(halveX, wqkms.getQ(i));
+            }
+            if (i == size-1) {
+                series.add(wqkms.getKm(i), wqkms.getQ(i), false);
+            }
+        }
+    }
+
+
+    /**
      * Add points to series (q to 1st dim, w to 2nd dim).
      *
      * @param series Series to add points to.

http://dive4elements.wald.intevation.org