Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/JFreeUtil.java @ 3772:5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
flys-artifacts/trunk@5477 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 15 Sep 2012 18:11:51 +0000 |
parents | d8f2ab5b61c3 |
children | 080411ac948f |
comparison
equal
deleted
inserted
replaced
3771:04309ca24614 | 3772:5a8f8fd5310c |
---|---|
11 import org.w3c.dom.Document; | 11 import org.w3c.dom.Document; |
12 | 12 |
13 import de.intevation.flys.artifacts.math.Function; | 13 import de.intevation.flys.artifacts.math.Function; |
14 | 14 |
15 public class JFreeUtil { | 15 public class JFreeUtil { |
16 | 16 |
17 private static final Logger logger = Logger.getLogger(JFreeUtil.class); | 17 private static final Logger logger = Logger.getLogger(JFreeUtil.class); |
18 | 18 |
19 /** Do not instantiate. */ | 19 /** Do not instantiate. */ |
20 private JFreeUtil() { | 20 private JFreeUtil() { |
21 } | 21 } |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 return false; | 52 return false; |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 /** | 56 /** |
57 * This function samples a randomized line that contains of x and y values | 57 * This function samples a randomized line that contains of x and y values |
58 * between <i>startX</i>, <i>endX</i>, <i>startY</i> and <i>endY</i>. The | 58 * between <i>startX</i>, <i>endX</i>, <i>startY</i> and <i>endY</i>. The |
59 * number of points in the line is specified by <i>num</i>. | 59 * number of points in the line is specified by <i>num</i>. |
60 * | 60 * |
61 * @param num The number of points in the line. | 61 * @param num The number of points in the line. |
62 * @param startX The min value of the x values. | 62 * @param startX The min value of the x values. |
63 * @param endX The max value of the x values. | 63 * @param endX The max value of the x values. |
64 * @param startY The min value of the y values. | 64 * @param startY The min value of the y values. |
65 * @param endY The max value of the y values. | 65 * @param endY The max value of the y values. |
75 ) throws IllegalArgumentException | 75 ) throws IllegalArgumentException |
76 { | 76 { |
77 if (num <= 0) { | 77 if (num <= 0) { |
78 throw new IllegalArgumentException("Parameter 'num' has to be > 0"); | 78 throw new IllegalArgumentException("Parameter 'num' has to be > 0"); |
79 } | 79 } |
80 | 80 |
81 Random random = new Random(); | 81 Random random = new Random(); |
82 | 82 |
83 double[] x = new double[num]; | 83 double[] x = new double[num]; |
84 double[] y = new double[num]; | 84 double[] y = new double[num]; |
85 | 85 |
86 for (int i = 0; i < num; i++) { | 86 for (int i = 0; i < num; i++) { |
87 double xFac = random.nextDouble(); | 87 double xFac = random.nextDouble(); |
88 double yFac = random.nextDouble(); | 88 double yFac = random.nextDouble(); |
89 | 89 |
90 x[i] = startX + xFac * (endX - startX); | 90 x[i] = startX + xFac * (endX - startX); |
91 y[i] = startY + yFac * (endY - startY); | 91 y[i] = startY + yFac * (endY - startY); |
92 | 92 |
93 logger.debug("Created new point: " + x[i] + "|" + y[i]); | 93 logger.debug("Created new point: " + x[i] + "|" + y[i]); |
94 } | 94 } |
95 | 95 |
96 return new double[][] { x, y }; | 96 return new double[][] { x, y }; |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 public static StyledXYSeries sampleFunction2D( | 100 public static StyledXYSeries sampleFunction2D( |