diff flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java @ 3105:9592b7d76633

Generate fake data for SQ curves; Implemented the Facet and Generator stuff. flys-artifacts/trunk@4704 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 19 Jun 2012 13:55:14 +0000
parents 4bd3d8bbb60c
children 63ef889eea2b
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java	Tue Jun 19 13:20:03 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java	Tue Jun 19 13:55:14 2012 +0000
@@ -5,9 +5,14 @@
 
 import java.util.Iterator;
 
+import org.w3c.dom.Document;
+
 import org.jfree.chart.entity.ChartEntity;
 import org.jfree.chart.entity.EntityCollection;
 
+import org.jfree.data.function.Function2D;
+
+
 public class JFreeUtil {
 
     /** Do not instantiate. */
@@ -45,5 +50,26 @@
 
         return false;
     }
+
+
+    public static StyledXYSeries sampleFunction2D(
+        Function2D 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);
+            series.add(x, func.getValue(x));
+        }
+
+        return series;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org