Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java @ 4842:97a0fa4dff8e
Use isDebugEnabled() in S/Q Measurement factory.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 23 Jan 2013 17:36:18 +0100 |
parents | 080411ac948f |
children |
rev | line source |
---|---|
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.jfree; |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
3 import java.awt.Shape; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
4 import java.awt.geom.Rectangle2D; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
5 import java.util.Iterator; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
6 import java.util.Random; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
7 |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
8 import org.apache.log4j.Logger; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
9 import org.jfree.chart.entity.ChartEntity; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
10 import org.jfree.chart.entity.EntityCollection; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
11 import org.w3c.dom.Document; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
12 |
3109
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
13 import de.intevation.flys.artifacts.math.Function; |
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
14 |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 public class JFreeUtil { |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
16 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
17 private static final Logger logger = Logger.getLogger(JFreeUtil.class); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3023
diff
changeset
|
18 |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 /** Do not instantiate. */ |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 private JFreeUtil() { |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 } |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 /** |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 * True if \param hotspot collides with a Entity in \param entities. |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 * @param hotspot Shape to compare against other shapes (bounds only). |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 * @param entities entities against which to compare shape. |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
28 * @param exclusiveEntityClass If not null, consider only entities of |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
29 * given class. |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
30 * @return true if a collision (non-zero intersection) exists between |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 * shapes. |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 */ |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
33 public static boolean collides(Shape hotspot, EntityCollection entities, |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
34 Class exclusiveEntityClass) { |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 if (entities == null) return false; |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 Rectangle2D hotspotBox = hotspot.getBounds2D(); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3023
diff
changeset
|
38 |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 for (Iterator i = entities.iterator(); i.hasNext(); ) { |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 Object next = i.next(); |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 ChartEntity entity = (ChartEntity) next; |
3023
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
42 if (exclusiveEntityClass == null |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
43 || exclusiveEntityClass.isInstance(entity)) |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
44 { |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
45 if (entity.getArea().intersects(hotspotBox)) { |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
46 // Found collision, early stop. |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
47 return true; |
e19ff9086035
Avoid collisions between line labels.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3018
diff
changeset
|
48 } |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 } |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 } |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 return false; |
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 } |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
54 |
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
55 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
56 /** |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
57 * This function samples a randomized line that contains of x and y values |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
58 * between <i>startX</i>, <i>endX</i>, <i>startY</i> and <i>endY</i>. The |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
59 * number of points in the line is specified by <i>num</i>. |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
60 * |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
61 * @param num The number of points in the line. |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
62 * @param startX The min value of the x values. |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
63 * @param endX The max value of the x values. |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
64 * @param startY The min value of the y values. |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
65 * @param endY The max value of the y values. |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
66 * @return an array with [allX-values, allY-values]. |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
67 * @throws IllegalArgumentException |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
68 */ |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
69 public static double[][] randomizeLine( |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
70 int num, |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
71 double startX, |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
72 double endX, |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
73 double startY, |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
74 double endY |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
75 ) throws IllegalArgumentException |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
76 { |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
77 if (num <= 0) { |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
78 throw new IllegalArgumentException("Parameter 'num' has to be > 0"); |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
79 } |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
80 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
81 Random random = new Random(); |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
82 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
83 double[] x = new double[num]; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
84 double[] y = new double[num]; |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
85 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
86 for (int i = 0; i < num; i++) { |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
87 double xFac = random.nextDouble(); |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
88 double yFac = random.nextDouble(); |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
89 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
90 x[i] = startX + xFac * (endX - startX); |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
91 y[i] = startY + yFac * (endY - startY); |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
92 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
93 logger.debug("Created new point: " + x[i] + "|" + y[i]); |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
94 } |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3765
diff
changeset
|
95 |
3765
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
96 return new double[][] { x, y }; |
d8f2ab5b61c3
Added JFreeUtil.randomizeLine() to generate randomized lines.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3109
diff
changeset
|
97 } |
3105
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
98 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
99 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
100 public static StyledXYSeries sampleFunction2D( |
3109
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
101 Function func, |
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
102 Document theme, |
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
103 String seriesKey, |
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
104 int samples, |
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
105 double start, |
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
106 double end |
3105
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
107 ) { |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
108 StyledXYSeries series = new StyledXYSeries(seriesKey, theme); |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
109 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
110 double step = (end - start) / (samples - 1); |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
111 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
112 for (int i = 0; i < samples; i++) { |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
113 double x = start + (step * i); |
3109
63ef889eea2b
SQ: Directly sample our Function objects instead of Function2D from JFreeChart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3105
diff
changeset
|
114 series.add(x, func.value(x)); |
3105
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
115 } |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
116 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
117 return series; |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
118 } |
4564
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
119 |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
120 public static StyledXYSeries sampleFunction2DPositive( |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
121 Function func, |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
122 Document theme, |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
123 String seriesKey, |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
124 int samples, |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
125 double start, |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
126 double end |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
127 ) { |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
128 StyledXYSeries series = new StyledXYSeries(seriesKey, theme); |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
129 |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
130 double step = (end - start) / (samples - 1); |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
131 |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
132 for (int i = 0; i < samples; i++) { |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
133 double x = start + (step * i); |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
134 double v = func.value(x); |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
135 if (x > 0d && v > 0d) { |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
136 series.add(x, v); |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
137 } |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
138 } |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
139 |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
140 return series; |
080411ac948f
More solid S/Q function sampling
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3772
diff
changeset
|
141 } |
3018
fb07f936b5ad
New helper.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3076
diff
changeset
|
143 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |