changeset 4564:080411ac948f

More solid S/Q function sampling
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 16 Nov 2012 17:39:47 +0100
parents 25a63512233e
children ce6bea03156c
files flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java
diffstat 2 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java	Fri Nov 16 14:57:14 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java	Fri Nov 16 17:39:47 2012 +0100
@@ -140,7 +140,7 @@
             return;
         }
 
-        XYSeries series = JFreeUtil.sampleFunction2D(
+        XYSeries series = JFreeUtil.sampleFunction2DPositive(
             func.getFunction(),
             attr,
             desc,
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java	Fri Nov 16 14:57:14 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java	Fri Nov 16 17:39:47 2012 +0100
@@ -116,5 +116,28 @@
 
         return series;
     }
+
+    public static StyledXYSeries sampleFunction2DPositive(
+        Function func,
+        Document theme,
+        String   seriesKey,
+        int      samples,
+        double   start,
+        double   end
+    ) {
+        StyledXYSeries series = new StyledXYSeries(seriesKey, theme);
+
+        double step = (end - start) / (samples - 1);
+
+        for (int i = 0; i < samples; i++) {
+            double x = start + (step * i);
+            double v = func.value(x);
+            if (x > 0d && v > 0d) {
+                series.add(x, v);
+            }
+        }
+
+        return series;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org