comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java @ 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 5a8f8fd5310c
children
comparison
equal deleted inserted replaced
4563:25a63512233e 4564:080411ac948f
114 series.add(x, func.value(x)); 114 series.add(x, func.value(x));
115 } 115 }
116 116
117 return series; 117 return series;
118 } 118 }
119
120 public static StyledXYSeries sampleFunction2DPositive(
121 Function func,
122 Document theme,
123 String seriesKey,
124 int samples,
125 double start,
126 double end
127 ) {
128 StyledXYSeries series = new StyledXYSeries(seriesKey, theme);
129
130 double step = (end - start) / (samples - 1);
131
132 for (int i = 0; i < samples; i++) {
133 double x = start + (step * i);
134 double v = func.value(x);
135 if (x > 0d && v > 0d) {
136 series.add(x, v);
137 }
138 }
139
140 return series;
141 }
119 } 142 }
120 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 143 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org