[Dive4elements-commits] [PATCH] More solid S/Q function sampling
Wald Commits
scm-commit at wald.intevation.org
Fri Nov 16 17:41:20 CET 2012
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1353083987 -3600
# Node ID 080411ac948f42f6e0f91a8a2e812222fb686940
# Parent 25a63512233e1b772eb0358384a3d3d562ad22d6
More solid S/Q function sampling
diff -r 25a63512233e -r 080411ac948f flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQRelationGenerator.java
--- 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,
diff -r 25a63512233e -r 080411ac948f flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java
--- 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 :
More information about the Dive4elements-commits
mailing list