propane 3.1.0.pre-java → 3.2.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -0
  3. data/CHANGELOG.md +1 -5
  4. data/README.md +23 -12
  5. data/Rakefile +23 -12
  6. data/lib/propane/helpers/version_error.rb +6 -0
  7. data/lib/propane/runner.rb +12 -0
  8. data/lib/propane/version.rb +1 -1
  9. data/library/slider/slider.rb +1 -1
  10. data/mvnw +234 -0
  11. data/mvnw.cmd +145 -0
  12. data/pom.xml +28 -27
  13. data/propane.gemspec +2 -2
  14. data/src/main/java/japplemenubar/JAppleMenuBar.java +41 -47
  15. data/src/main/java/monkstone/ColorUtil.java +1 -1
  16. data/src/main/java/monkstone/MathToolModule.java +12 -11
  17. data/src/main/java/monkstone/PropaneLibrary.java +9 -10
  18. data/src/main/java/monkstone/core/LibraryProxy.java +124 -113
  19. data/src/main/java/monkstone/fastmath/Deglut.java +86 -89
  20. data/src/main/java/monkstone/filechooser/Chooser.java +7 -13
  21. data/src/main/java/monkstone/noise/SimplexNoise.java +0 -1
  22. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +4 -4
  23. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  24. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +9 -9
  25. data/src/main/java/monkstone/slider/SimpleSlider.java +0 -9
  26. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +11 -13
  27. data/src/main/java/monkstone/slider/Slider.java +1 -1
  28. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  29. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  30. data/src/main/java/monkstone/slider/WheelHandler.java +8 -9
  31. data/src/main/java/monkstone/vecmath/AppRender.java +2 -2
  32. data/src/main/java/monkstone/vecmath/ShapeRender.java +2 -2
  33. data/src/main/java/monkstone/vecmath/package-info.java +2 -2
  34. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
  35. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  36. data/src/main/java/monkstone/videoevent/VideoInterface.java +11 -5
  37. data/src/main/java/monkstone/videoevent/package-info.java +2 -2
  38. data/src/main/java/processing/awt/PGraphicsJava2D.java +1742 -2243
  39. data/src/main/java/processing/awt/PShapeJava2D.java +268 -270
  40. data/src/main/java/processing/awt/PSurfaceAWT.java +821 -920
  41. data/src/main/java/processing/core/DesktopHandler.java +94 -0
  42. data/src/main/java/processing/core/PApplet.java +14170 -14082
  43. data/src/main/java/processing/core/PConstants.java +447 -473
  44. data/src/main/java/processing/core/PFont.java +867 -873
  45. data/src/main/java/processing/core/PGraphics.java +7193 -7428
  46. data/src/main/java/processing/core/PImage.java +3051 -3117
  47. data/src/main/java/processing/core/PMatrix.java +159 -172
  48. data/src/main/java/processing/core/PMatrix2D.java +403 -444
  49. data/src/main/java/processing/core/PMatrix3D.java +735 -749
  50. data/src/main/java/processing/core/PShape.java +2651 -2793
  51. data/src/main/java/processing/core/PShapeOBJ.java +415 -422
  52. data/src/main/java/processing/core/PShapeSVG.java +1466 -1475
  53. data/src/main/java/processing/core/PStyle.java +37 -40
  54. data/src/main/java/processing/core/PSurface.java +98 -103
  55. data/src/main/java/processing/core/PSurfaceNone.java +208 -236
  56. data/src/main/java/processing/core/PVector.java +961 -990
  57. data/src/main/java/processing/data/DoubleDict.java +709 -753
  58. data/src/main/java/processing/data/DoubleList.java +695 -748
  59. data/src/main/java/processing/data/FloatDict.java +702 -746
  60. data/src/main/java/processing/data/FloatList.java +697 -751
  61. data/src/main/java/processing/data/IntDict.java +673 -718
  62. data/src/main/java/processing/data/IntList.java +633 -699
  63. data/src/main/java/processing/data/JSONArray.java +873 -931
  64. data/src/main/java/processing/data/JSONObject.java +1165 -1262
  65. data/src/main/java/processing/data/JSONTokener.java +341 -351
  66. data/src/main/java/processing/data/LongDict.java +662 -707
  67. data/src/main/java/processing/data/LongList.java +634 -700
  68. data/src/main/java/processing/data/Sort.java +41 -37
  69. data/src/main/java/processing/data/StringDict.java +486 -522
  70. data/src/main/java/processing/data/StringList.java +580 -624
  71. data/src/main/java/processing/data/Table.java +3508 -3686
  72. data/src/main/java/processing/data/TableRow.java +183 -182
  73. data/src/main/java/processing/data/XML.java +883 -957
  74. data/src/main/java/processing/event/Event.java +66 -87
  75. data/src/main/java/processing/event/KeyEvent.java +41 -48
  76. data/src/main/java/processing/event/MouseEvent.java +93 -103
  77. data/src/main/java/processing/event/TouchEvent.java +6 -10
  78. data/src/main/java/processing/javafx/PGraphicsFX2D.java +5 -69
  79. data/src/main/java/processing/javafx/PSurfaceFX.java +2 -7
  80. data/src/main/java/processing/opengl/FontTexture.java +270 -290
  81. data/src/main/java/processing/opengl/FrameBuffer.java +363 -375
  82. data/src/main/java/processing/opengl/LinePath.java +500 -543
  83. data/src/main/java/processing/opengl/LineStroker.java +582 -593
  84. data/src/main/java/processing/opengl/PGL.java +2881 -2904
  85. data/src/main/java/processing/opengl/PGraphics2D.java +315 -408
  86. data/src/main/java/processing/opengl/PGraphics3D.java +72 -107
  87. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12043 -12230
  88. data/src/main/java/processing/opengl/PJOGL.java +1681 -1745
  89. data/src/main/java/processing/opengl/PShader.java +1257 -1260
  90. data/src/main/java/processing/opengl/PShapeOpenGL.java +4599 -4662
  91. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1030 -1047
  92. data/src/main/java/processing/opengl/Texture.java +1397 -1462
  93. data/src/main/java/processing/opengl/VertexBuffer.java +55 -57
  94. data/src/main/resources/icon/icon-1024.png +0 -0
  95. data/src/main/resources/icon/icon-128.png +0 -0
  96. data/src/main/resources/icon/icon-16.png +0 -0
  97. data/src/main/resources/icon/icon-256.png +0 -0
  98. data/src/main/resources/icon/icon-32.png +0 -0
  99. data/src/main/resources/icon/icon-48.png +0 -0
  100. data/src/main/resources/icon/icon-512.png +0 -0
  101. data/src/main/resources/icon/icon-64.png +0 -0
  102. data/vendors/Rakefile +1 -1
  103. metadata +12 -8
  104. data/src/main/java/processing/core/ThinkDifferent.java +0 -70
@@ -1,5 +1,3 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
1
  /*
4
2
  * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
5
3
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -24,600 +22,559 @@
24
22
  * CA 95054 USA or visit www.sun.com if you need additional information or
25
23
  * have any questions.
26
24
  */
27
-
28
25
  package processing.opengl;
29
26
 
30
27
  import processing.core.PMatrix2D;
31
28
 
32
29
  /**
33
- * The {@code LinePath} class allows to represent polygonal paths,
34
- * potentially composed by several disjoint polygonal segments.
35
- * It can be iterated by the {@link PathIterator} class including all
36
- * of its segment types and winding rules
30
+ * The {@code LinePath} class allows to represent polygonal paths, potentially
31
+ * composed by several disjoint polygonal segments. It can be iterated by the
32
+ * {@link PathIterator} class including all of its segment types and winding
33
+ * rules
37
34
  *
38
35
  */
39
36
  public class LinePath {
40
- /**
41
- * The winding rule constant for specifying an even-odd rule
42
- * for determining the interior of a path.
43
- * The even-odd rule specifies that a point lies inside the
44
- * path if a ray drawn in any direction from that point to
45
- * infinity is crossed by path segments an odd number of times.
46
- */
47
- public static final int WIND_EVEN_ODD = 0;
48
-
49
- /**
50
- * The winding rule constant for specifying a non-zero rule
51
- * for determining the interior of a path.
52
- * The non-zero rule specifies that a point lies inside the
53
- * path if a ray drawn in any direction from that point to
54
- * infinity is crossed by path segments a different number
55
- * of times in the counter-clockwise direction than the
56
- * clockwise direction.
57
- */
58
- public static final int WIND_NON_ZERO = 1;
59
-
60
- /**
61
- * Starts segment at a given position.
62
- */
63
- public static final byte SEG_MOVETO = 0;
64
-
65
- /**
66
- * Extends segment by adding a line to a given position.
67
- */
68
- public static final byte SEG_LINETO = 1;
69
-
70
- /**
71
- * Closes segment at current position.
72
- */
73
- public static final byte SEG_CLOSE = 2;
74
-
75
- /**
76
- * Joins path segments by extending their outside edges until they meet.
77
- */
78
- public final static int JOIN_MITER = 0;
79
-
80
- /**
81
- * Joins path segments by rounding off the corner at a radius of half the line
82
- * width.
83
- */
84
- public final static int JOIN_ROUND = 1;
85
-
86
- /**
87
- * Joins path segments by connecting the outer corners of their wide outlines
88
- * with a straight segment.
89
- */
90
- public final static int JOIN_BEVEL = 2;
91
-
92
- /**
93
- * Ends unclosed subpaths and dash segments with no added decoration.
94
- */
95
- public final static int CAP_BUTT = 0;
96
-
97
- /**
98
- * Ends unclosed subpaths and dash segments with a round decoration that has a
99
- * radius equal to half of the width of the pen.
100
- */
101
- public final static int CAP_ROUND = 1;
102
-
103
- /**
104
- * Ends unclosed subpaths and dash segments with a square projection that
105
- * extends beyond the end of the segment to a distance equal to half of the
106
- * line width.
107
- */
108
- public final static int CAP_SQUARE = 2;
109
-
110
- private static PMatrix2D identity = new PMatrix2D();
111
-
112
- private static float defaultMiterlimit = 10.0f;
113
-
114
- static final int INIT_SIZE = 20;
115
-
116
- static final int EXPAND_MAX = 500;
117
-
118
- protected byte[] pointTypes;
119
-
120
- protected float[] floatCoords;
121
-
122
- protected int[] pointColors;
123
-
124
- protected int numTypes;
125
-
126
- protected int numCoords;
127
-
128
- protected int windingRule;
129
-
130
-
131
- /**
132
- * Constructs a new empty single precision {@code LinePath} object with a
133
- * default winding rule of {@link #WIND_NON_ZERO}.
134
- */
135
- public LinePath() {
136
- this(WIND_NON_ZERO, INIT_SIZE);
137
- }
138
-
139
-
140
- /**
141
- * Constructs a new empty single precision {@code LinePath} object with the
142
- * specified winding rule to control operations that require the interior of
143
- * the path to be defined.
144
- *
145
- * @param rule
146
- * the winding rule
147
- * @see #WIND_EVEN_ODD
148
- * @see #WIND_NON_ZERO
149
- */
150
- public LinePath(int rule) {
151
- this(rule, INIT_SIZE);
152
- }
153
-
154
-
155
- /**
156
- * Constructs a new {@code LinePath} object from the given specified initial
157
- * values. This method is only intended for internal use and should not be
158
- * made public if the other constructors for this class are ever exposed.
159
- *
160
- * @param rule
161
- * the winding rule
162
- * @param initialCapacity
163
- * the size to make the initial array to store the path segment types
164
- */
165
- public LinePath(int rule, int initialCapacity) {
166
- setWindingRule(rule);
167
- this.pointTypes = new byte[initialCapacity];
168
- floatCoords = new float[initialCapacity * 2];
169
- pointColors = new int[initialCapacity];
170
- }
171
-
172
-
173
- void needRoom(boolean needMove, int newPoints) {
174
- if (needMove && numTypes == 0) {
175
- throw new RuntimeException("missing initial moveto "
176
- + "in path definition");
177
- }
178
- int size = pointTypes.length;
179
- if (numTypes >= size) {
180
- int grow = size;
181
- if (grow > EXPAND_MAX) {
182
- grow = EXPAND_MAX;
183
- }
184
- pointTypes = copyOf(pointTypes, size + grow);
185
- }
186
- size = floatCoords.length;
187
- if (numCoords + newPoints * 2 > size) {
188
- int grow = size;
189
- if (grow > EXPAND_MAX * 2) {
190
- grow = EXPAND_MAX * 2;
191
- }
192
- if (grow < newPoints * 2) {
193
- grow = newPoints * 2;
194
- }
195
- floatCoords = copyOf(floatCoords, size + grow);
196
- }
197
- size = pointColors.length;
198
- if (numCoords/2 + newPoints > size) {
199
- int grow = size;
200
- if (grow > EXPAND_MAX) {
201
- grow = EXPAND_MAX;
202
- }
203
- if (grow < newPoints) {
204
- grow = newPoints;
205
- }
206
- pointColors = copyOf(pointColors, size + grow);
207
- }
208
- }
209
-
210
-
211
- /**
212
- * Adds a point to the path by moving to the specified coordinates specified
213
- * in float precision.
214
- * <p>
215
- * This method provides a single precision variant of the double precision
216
- * {@code moveTo()} method on the base {@code LinePath} class.
217
- *
218
- * @param x
219
- * the specified X coordinate
220
- * @param y
221
- * the specified Y coordinate
222
- * @see LinePath#moveTo
223
- */
224
- public final void moveTo(float x, float y, int c) {
225
- if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
226
- floatCoords[numCoords - 2] = x;
227
- floatCoords[numCoords - 1] = y;
228
- pointColors[numCoords/2-1] = c;
229
- } else {
230
- needRoom(false, 1);
231
- pointTypes[numTypes++] = SEG_MOVETO;
232
- floatCoords[numCoords++] = x;
233
- floatCoords[numCoords++] = y;
234
- pointColors[numCoords/2-1] = c;
235
- }
236
- }
237
-
238
-
239
- /**
240
- * Adds a point to the path by drawing a straight line from the current
241
- * coordinates to the new specified coordinates specified in float precision.
242
- * <p>
243
- * This method provides a single precision variant of the double precision
244
- * {@code lineTo()} method on the base {@code LinePath} class.
245
- *
246
- * @param x
247
- * the specified X coordinate
248
- * @param y
249
- * the specified Y coordinate
250
- * @see LinePath#lineTo
251
- */
252
- public final void lineTo(float x, float y, int c) {
253
- needRoom(true, 1);
254
- pointTypes[numTypes++] = SEG_LINETO;
255
- floatCoords[numCoords++] = x;
256
- floatCoords[numCoords++] = y;
257
- pointColors[numCoords/2-1] = c;
258
- }
259
-
260
-
261
- /**
262
- * The iterator for this class is not multi-threaded safe, which means that
263
- * the {@code LinePath} class does not guarantee that modifications to the
264
- * geometry of this {@code LinePath} object do not affect any iterations of that
265
- * geometry that are already in process.
266
- */
267
- public PathIterator getPathIterator() {
268
- return new PathIterator(this);
269
- }
270
-
271
-
272
- /**
273
- * Closes the current subpath by drawing a straight line back to the
274
- * coordinates of the last {@code moveTo}. If the path is already closed then
275
- * this method has no effect.
276
- */
277
- public final void closePath() {
278
- if (numTypes == 0 || pointTypes[numTypes - 1] != SEG_CLOSE) {
279
- needRoom(false, 0);
280
- pointTypes[numTypes++] = SEG_CLOSE;
281
- }
282
- }
283
-
284
-
285
- /**
286
- * Returns the fill style winding rule.
287
- *
288
- * @return an integer representing the current winding rule.
289
- * @see #WIND_EVEN_ODD
290
- * @see #WIND_NON_ZERO
291
- * @see #setWindingRule
292
- */
293
- public final int getWindingRule() {
294
- return windingRule;
295
- }
296
-
297
-
298
- /**
299
- * Sets the winding rule for this path to the specified value.
300
- *
301
- * @param rule
302
- * an integer representing the specified winding rule
303
- * @exception IllegalArgumentException
304
- * if {@code rule} is not either {@link #WIND_EVEN_ODD} or
305
- * {@link #WIND_NON_ZERO}
306
- * @see #getWindingRule
307
- */
308
- public final void setWindingRule(int rule) {
309
- if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
310
- throw new IllegalArgumentException("winding rule must be "
311
- + "WIND_EVEN_ODD or " + "WIND_NON_ZERO");
312
- }
313
- windingRule = rule;
314
- }
315
-
316
-
317
- /**
318
- * Resets the path to empty. The append position is set back to the beginning
319
- * of the path and all coordinates and point types are forgotten.
320
- */
321
- public final void reset() {
322
- numTypes = numCoords = 0;
323
- }
324
37
 
38
+ /**
39
+ * The winding rule constant for specifying an even-odd rule for determining
40
+ * the interior of a path. The even-odd rule specifies that a point lies
41
+ * inside the path if a ray drawn in any direction from that point to
42
+ * infinity is crossed by path segments an odd number of times.
43
+ */
44
+ public static final int WIND_EVEN_ODD = 0;
45
+
46
+ /**
47
+ * The winding rule constant for specifying a non-zero rule for determining
48
+ * the interior of a path. The non-zero rule specifies that a point lies
49
+ * inside the path if a ray drawn in any direction from that point to
50
+ * infinity is crossed by path segments a different number of times in the
51
+ * counter-clockwise direction than the clockwise direction.
52
+ */
53
+ public static final int WIND_NON_ZERO = 1;
54
+
55
+ /**
56
+ * Starts segment at a given position.
57
+ */
58
+ public static final byte SEG_MOVETO = 0;
59
+
60
+ /**
61
+ * Extends segment by adding a line to a given position.
62
+ */
63
+ public static final byte SEG_LINETO = 1;
64
+
65
+ /**
66
+ * Closes segment at current position.
67
+ */
68
+ public static final byte SEG_CLOSE = 2;
69
+
70
+ /**
71
+ * Joins path segments by extending their outside edges until they meet.
72
+ */
73
+ public final static int JOIN_MITER = 0;
74
+
75
+ /**
76
+ * Joins path segments by rounding off the corner at a radius of half the
77
+ * line width.
78
+ */
79
+ public final static int JOIN_ROUND = 1;
80
+
81
+ /**
82
+ * Joins path segments by connecting the outer corners of their wide
83
+ * outlines with a straight segment.
84
+ */
85
+ public final static int JOIN_BEVEL = 2;
86
+
87
+ /**
88
+ * Ends unclosed subpaths and dash segments with no added decoration.
89
+ */
90
+ public final static int CAP_BUTT = 0;
91
+
92
+ /**
93
+ * Ends unclosed subpaths and dash segments with a round decoration that has
94
+ * a radius equal to half of the width of the pen.
95
+ */
96
+ public final static int CAP_ROUND = 1;
97
+
98
+ /**
99
+ * Ends unclosed subpaths and dash segments with a square projection that
100
+ * extends beyond the end of the segment to a distance equal to half of the
101
+ * line width.
102
+ */
103
+ public final static int CAP_SQUARE = 2;
104
+
105
+ private static PMatrix2D identity = new PMatrix2D();
106
+
107
+ private static float defaultMiterlimit = 10.0f;
108
+
109
+ static final int INIT_SIZE = 20;
110
+
111
+ static final int EXPAND_MAX = 500;
112
+
113
+ protected byte[] pointTypes;
114
+
115
+ protected float[] floatCoords;
116
+
117
+ protected int[] pointColors;
118
+
119
+ protected int numTypes;
120
+
121
+ protected int numCoords;
122
+
123
+ protected int windingRule;
124
+
125
+ /**
126
+ * Constructs a new empty single precision {@code LinePath} object with a
127
+ * default winding rule of {@link #WIND_NON_ZERO}.
128
+ */
129
+ public LinePath() {
130
+ this(WIND_NON_ZERO, INIT_SIZE);
131
+ }
325
132
 
326
- static public class PathIterator {
327
- float floatCoords[];
328
-
329
- int typeIdx;
330
-
331
- int pointIdx;
133
+ /**
134
+ * Constructs a new empty single precision {@code LinePath} object with the
135
+ * specified winding rule to control operations that require the interior of
136
+ * the path to be defined.
137
+ *
138
+ * @param rule the winding rule
139
+ * @see #WIND_EVEN_ODD
140
+ * @see #WIND_NON_ZERO
141
+ */
142
+ public LinePath(int rule) {
143
+ this(rule, INIT_SIZE);
144
+ }
332
145
 
333
- int colorIdx;
146
+ /**
147
+ * Constructs a new {@code LinePath} object from the given specified initial
148
+ * values. This method is only intended for internal use and should not be
149
+ * made public if the other constructors for this class are ever exposed.
150
+ *
151
+ * @param rule the winding rule
152
+ * @param initialCapacity the size to make the initial array to store the
153
+ * path segment types
154
+ */
155
+ public LinePath(int rule, int initialCapacity) {
156
+ setWindingRule(rule);
157
+ this.pointTypes = new byte[initialCapacity];
158
+ floatCoords = new float[initialCapacity * 2];
159
+ pointColors = new int[initialCapacity];
160
+ }
334
161
 
335
- LinePath path;
162
+ void needRoom(boolean needMove, int newPoints) {
163
+ if (needMove && numTypes == 0) {
164
+ throw new RuntimeException("missing initial moveto "
165
+ + "in path definition");
166
+ }
167
+ int size = pointTypes.length;
168
+ if (numTypes >= size) {
169
+ int grow = size;
170
+ if (grow > EXPAND_MAX) {
171
+ grow = EXPAND_MAX;
172
+ }
173
+ pointTypes = copyOf(pointTypes, size + grow);
174
+ }
175
+ size = floatCoords.length;
176
+ if (numCoords + newPoints * 2 > size) {
177
+ int grow = size;
178
+ if (grow > EXPAND_MAX * 2) {
179
+ grow = EXPAND_MAX * 2;
180
+ }
181
+ if (grow < newPoints * 2) {
182
+ grow = newPoints * 2;
183
+ }
184
+ floatCoords = copyOf(floatCoords, size + grow);
185
+ }
186
+ size = pointColors.length;
187
+ if (numCoords / 2 + newPoints > size) {
188
+ int grow = size;
189
+ if (grow > EXPAND_MAX) {
190
+ grow = EXPAND_MAX;
191
+ }
192
+ if (grow < newPoints) {
193
+ grow = newPoints;
194
+ }
195
+ pointColors = copyOf(pointColors, size + grow);
196
+ }
197
+ }
336
198
 
337
- static final int curvecoords[] = { 2, 2, 0 };
199
+ /**
200
+ * Adds a point to the path by moving to the specified coordinates specified
201
+ * in float precision.
202
+ * <p>
203
+ * This method provides a single precision variant of the double precision
204
+ * {@code moveTo()} method on the base {@code LinePath} class.
205
+ *
206
+ * @param x the specified X coordinate
207
+ * @param y the specified Y coordinate
208
+ * @see LinePath#moveTo
209
+ */
210
+ public final void moveTo(float x, float y, int c) {
211
+ if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
212
+ floatCoords[numCoords - 2] = x;
213
+ floatCoords[numCoords - 1] = y;
214
+ pointColors[numCoords / 2 - 1] = c;
215
+ } else {
216
+ needRoom(false, 1);
217
+ pointTypes[numTypes++] = SEG_MOVETO;
218
+ floatCoords[numCoords++] = x;
219
+ floatCoords[numCoords++] = y;
220
+ pointColors[numCoords / 2 - 1] = c;
221
+ }
222
+ }
338
223
 
339
- PathIterator(LinePath p2df) {
340
- this.path = p2df;
341
- this.floatCoords = p2df.floatCoords;
342
- pointIdx = 0;
343
- colorIdx = 0;
224
+ /**
225
+ * Adds a point to the path by drawing a straight line from the current
226
+ * coordinates to the new specified coordinates specified in float
227
+ * precision.
228
+ * <p>
229
+ * This method provides a single precision variant of the double precision
230
+ * {@code lineTo()} method on the base {@code LinePath} class.
231
+ *
232
+ * @param x the specified X coordinate
233
+ * @param y the specified Y coordinate
234
+ * @see LinePath#lineTo
235
+ */
236
+ public final void lineTo(float x, float y, int c) {
237
+ needRoom(true, 1);
238
+ pointTypes[numTypes++] = SEG_LINETO;
239
+ floatCoords[numCoords++] = x;
240
+ floatCoords[numCoords++] = y;
241
+ pointColors[numCoords / 2 - 1] = c;
344
242
  }
345
243
 
346
- public int currentSegment(float[] coords) {
347
- int type = path.pointTypes[typeIdx];
348
- int numCoords = curvecoords[type];
349
- if (numCoords > 0) {
350
- System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
351
- int color = path.pointColors[colorIdx];
352
- coords[numCoords + 0] = (color >> 24) & 0xFF;
353
- coords[numCoords + 1] = (color >> 16) & 0xFF;
354
- coords[numCoords + 2] = (color >> 8) & 0xFF;
355
- coords[numCoords + 3] = (color >> 0) & 0xFF;
356
- }
357
- return type;
244
+ /**
245
+ * The iterator for this class is not multi-threaded safe, which means that
246
+ * the {@code LinePath} class does not guarantee that modifications to the
247
+ * geometry of this {@code LinePath} object do not affect any iterations of
248
+ * that geometry that are already in process.
249
+ */
250
+ public PathIterator getPathIterator() {
251
+ return new PathIterator(this);
358
252
  }
359
253
 
360
- public int currentSegment(double[] coords) {
361
- int type = path.pointTypes[typeIdx];
362
- int numCoords = curvecoords[type];
363
- if (numCoords > 0) {
364
- for (int i = 0; i < numCoords; i++) {
365
- coords[i] = floatCoords[pointIdx + i];
254
+ /**
255
+ * Closes the current subpath by drawing a straight line back to the
256
+ * coordinates of the last {@code moveTo}. If the path is already closed
257
+ * then this method has no effect.
258
+ */
259
+ public final void closePath() {
260
+ if (numTypes == 0 || pointTypes[numTypes - 1] != SEG_CLOSE) {
261
+ needRoom(false, 0);
262
+ pointTypes[numTypes++] = SEG_CLOSE;
366
263
  }
367
- int color = path.pointColors[colorIdx];
368
- coords[numCoords + 0] = (color >> 24) & 0xFF;
369
- coords[numCoords + 1] = (color >> 16) & 0xFF;
370
- coords[numCoords + 2] = (color >> 8) & 0xFF;
371
- coords[numCoords + 3] = (color >> 0) & 0xFF;
372
- }
373
- return type;
374
264
  }
375
265
 
376
- public int getWindingRule() {
377
- return path.getWindingRule();
266
+ /**
267
+ * Returns the fill style winding rule.
268
+ *
269
+ * @return an integer representing the current winding rule.
270
+ * @see #WIND_EVEN_ODD
271
+ * @see #WIND_NON_ZERO
272
+ * @see #setWindingRule
273
+ */
274
+ public final int getWindingRule() {
275
+ return windingRule;
378
276
  }
379
277
 
380
- public boolean isDone() {
381
- return (typeIdx >= path.numTypes);
278
+ /**
279
+ * Sets the winding rule for this path to the specified value.
280
+ *
281
+ * @param rule an integer representing the specified winding rule
282
+ * @exception IllegalArgumentException if {@code rule} is not either
283
+ * {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
284
+ * @see #getWindingRule
285
+ */
286
+ public final void setWindingRule(int rule) {
287
+ if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
288
+ throw new IllegalArgumentException("winding rule must be "
289
+ + "WIND_EVEN_ODD or " + "WIND_NON_ZERO");
290
+ }
291
+ windingRule = rule;
382
292
  }
383
293
 
384
- public void next() {
385
- int type = path.pointTypes[typeIdx++];
386
- if (0 < curvecoords[type]) {
387
- pointIdx += curvecoords[type];
388
- colorIdx++;
389
- }
390
- }
391
- }
392
-
393
-
394
- /////////////////////////////////////////////////////////////////////////////
395
- //
396
- // Stroked path methods
397
-
398
-
399
- static public LinePath createStrokedPath(LinePath src, float weight,
400
- int caps, int join) {
401
- return createStrokedPath(src, weight, caps, join, defaultMiterlimit, null);
402
- }
403
-
404
-
405
- static public LinePath createStrokedPath(LinePath src, float weight,
406
- int caps, int join, float miterlimit) {
407
- return createStrokedPath(src, weight, caps, join, miterlimit, null);
408
- }
409
-
410
-
411
- /**
412
- * Constructs a solid <code>LinePath</code> with the specified attributes.
413
- *
414
- * @param src
415
- * the original path to be stroked
416
- * @param weight
417
- * the weight of the stroked path
418
- * @param caps
419
- * the decoration of the ends of the segments in the path
420
- * @param join
421
- * the decoration applied where path segments meet
422
- * @param miterlimit
423
- * @param transform
424
- *
425
- */
426
- static public LinePath createStrokedPath(LinePath src, float weight,
427
- int caps, int join,
428
- float miterlimit, PMatrix2D transform) {
429
- final LinePath dest = new LinePath();
430
-
431
- strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
432
- @Override
433
- public void moveTo(int x0, int y0, int c0) {
434
- dest.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0), c0);
435
- }
436
-
437
- @Override
438
- public void lineJoin() {
439
- }
440
-
441
- @Override
442
- public void lineTo(int x1, int y1, int c1) {
443
- dest.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1), c1);
444
- }
445
-
446
- @Override
447
- public void close() {
448
- dest.closePath();
449
- }
450
-
451
- @Override
452
- public void end() {
453
- }
454
- });
455
-
456
- return dest;
457
- }
458
-
459
-
460
- private static void strokeTo(LinePath src, float width, int caps, int join,
461
- float miterlimit, PMatrix2D transform,
462
- LineStroker lsink) {
463
- lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
464
- FloatToS15_16(miterlimit),
465
- transform == null ? identity : transform);
466
-
467
- PathIterator pi = src.getPathIterator();
468
- pathTo(pi, lsink);
469
- }
470
-
471
-
472
- private static void pathTo(PathIterator pi, LineStroker lsink) {
473
- float coords[] = new float[6];
474
- while (!pi.isDone()) {
475
- int color;
476
- switch (pi.currentSegment(coords)) {
477
- case SEG_MOVETO:
478
- color = ((int)coords[2]<<24) |
479
- ((int)coords[3]<<16) |
480
- ((int)coords[4]<< 8) |
481
- (int)coords[5];
482
- lsink.moveTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
483
- break;
484
- case SEG_LINETO:
485
- color = ((int)coords[2]<<24) |
486
- ((int)coords[3]<<16) |
487
- ((int)coords[4]<< 8) |
488
- (int)coords[5];
489
- lsink.lineJoin();
490
- lsink.lineTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
491
- break;
492
- case SEG_CLOSE:
493
- lsink.lineJoin();
494
- lsink.close();
495
- break;
496
- default:
497
- throw new InternalError("unknown flattened segment type");
498
- }
499
- pi.next();
294
+ /**
295
+ * Resets the path to empty. The append position is set back to the
296
+ * beginning of the path and all coordinates and point types are forgotten.
297
+ */
298
+ public final void reset() {
299
+ numTypes = numCoords = 0;
500
300
  }
501
- lsink.end();
502
- }
503
301
 
302
+ static public class PathIterator {
504
303
 
505
- /////////////////////////////////////////////////////////////////////////////
506
- //
507
- // Utility methods
304
+ float floatCoords[];
508
305
 
306
+ int typeIdx;
509
307
 
510
- public static float[] copyOf(float[] source, int length) {
511
- float[] target = new float[length];
512
- for (int i = 0; i < target.length; i++) {
513
- if (i > source.length - 1)
514
- target[i] = 0f;
515
- else
516
- target[i] = source[i];
517
- }
518
- return target;
519
- }
308
+ int pointIdx;
520
309
 
310
+ int colorIdx;
521
311
 
522
- public static byte[] copyOf(byte[] source, int length) {
523
- byte[] target = new byte[length];
524
- for (int i = 0; i < target.length; i++) {
525
- if (i > source.length - 1)
526
- target[i] = 0;
527
- else
528
- target[i] = source[i];
529
- }
530
- return target;
531
- }
312
+ LinePath path;
532
313
 
314
+ static final int curvecoords[] = {2, 2, 0};
533
315
 
534
- public static int[] copyOf(int[] source, int length) {
535
- int[] target = new int[length];
536
- for (int i = 0; i < target.length; i++) {
537
- if (i > source.length - 1)
538
- target[i] = 0;
539
- else
540
- target[i] = source[i];
541
- }
542
- return target;
543
- }
316
+ PathIterator(LinePath p2df) {
317
+ this.path = p2df;
318
+ this.floatCoords = p2df.floatCoords;
319
+ pointIdx = 0;
320
+ colorIdx = 0;
321
+ }
544
322
 
323
+ public int currentSegment(float[] coords) {
324
+ int type = path.pointTypes[typeIdx];
325
+ int numCoords = curvecoords[type];
326
+ if (numCoords > 0) {
327
+ System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
328
+ int color = path.pointColors[colorIdx];
329
+ coords[numCoords + 0] = (color >> 24) & 0xFF;
330
+ coords[numCoords + 1] = (color >> 16) & 0xFF;
331
+ coords[numCoords + 2] = (color >> 8) & 0xFF;
332
+ coords[numCoords + 3] = (color >> 0) & 0xFF;
333
+ }
334
+ return type;
335
+ }
545
336
 
546
- // From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
547
- public static int isqrt(int x) {
548
- int fracbits = 16;
337
+ public int currentSegment(double[] coords) {
338
+ int type = path.pointTypes[typeIdx];
339
+ int numCoords = curvecoords[type];
340
+ if (numCoords > 0) {
341
+ for (int i = 0; i < numCoords; i++) {
342
+ coords[i] = floatCoords[pointIdx + i];
343
+ }
344
+ int color = path.pointColors[colorIdx];
345
+ coords[numCoords + 0] = (color >> 24) & 0xFF;
346
+ coords[numCoords + 1] = (color >> 16) & 0xFF;
347
+ coords[numCoords + 2] = (color >> 8) & 0xFF;
348
+ coords[numCoords + 3] = (color >> 0) & 0xFF;
349
+ }
350
+ return type;
351
+ }
549
352
 
550
- int root = 0;
551
- int remHi = 0;
552
- int remLo = x;
553
- int count = 15 + fracbits / 2;
353
+ public int getWindingRule() {
354
+ return path.getWindingRule();
355
+ }
554
356
 
555
- do {
556
- remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
557
- remLo <<= 2;
558
- root <<= 1;
559
- int testdiv = (root << 1) + 1;
560
- if (remHi >= testdiv) {
561
- remHi -= testdiv;
562
- root++;
563
- }
564
- } while (count-- != 0);
357
+ public boolean isDone() {
358
+ return (typeIdx >= path.numTypes);
359
+ }
565
360
 
566
- return root;
567
- }
361
+ public void next() {
362
+ int type = path.pointTypes[typeIdx++];
363
+ if (0 < curvecoords[type]) {
364
+ pointIdx += curvecoords[type];
365
+ colorIdx++;
366
+ }
367
+ }
368
+ }
568
369
 
370
+ /////////////////////////////////////////////////////////////////////////////
371
+ //
372
+ // Stroked path methods
373
+ static public LinePath createStrokedPath(LinePath src, float weight,
374
+ int caps, int join) {
375
+ return createStrokedPath(src, weight, caps, join, defaultMiterlimit, null);
376
+ }
569
377
 
570
- public static long lsqrt(long x) {
571
- int fracbits = 16;
378
+ static public LinePath createStrokedPath(LinePath src, float weight,
379
+ int caps, int join, float miterlimit) {
380
+ return createStrokedPath(src, weight, caps, join, miterlimit, null);
381
+ }
572
382
 
573
- long root = 0;
574
- long remHi = 0;
575
- long remLo = x;
576
- int count = 31 + fracbits / 2;
383
+ /**
384
+ * Constructs a solid <code>LinePath</code> with the specified attributes.
385
+ *
386
+ * @param src the original path to be stroked
387
+ * @param weight the weight of the stroked path
388
+ * @param caps the decoration of the ends of the segments in the path
389
+ * @param join the decoration applied where path segments meet
390
+ * @param miterlimit
391
+ * @param transform
392
+ *
393
+ */
394
+ static public LinePath createStrokedPath(LinePath src, float weight,
395
+ int caps, int join,
396
+ float miterlimit, PMatrix2D transform) {
397
+ final LinePath dest = new LinePath();
398
+
399
+ strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
400
+ @Override
401
+ public void moveTo(int x0, int y0, int c0) {
402
+ dest.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0), c0);
403
+ }
404
+
405
+ @Override
406
+ public void lineJoin() {
407
+ }
408
+
409
+ @Override
410
+ public void lineTo(int x1, int y1, int c1) {
411
+ dest.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1), c1);
412
+ }
413
+
414
+ @Override
415
+ public void close() {
416
+ dest.closePath();
417
+ }
418
+
419
+ @Override
420
+ public void end() {
421
+ }
422
+ });
423
+
424
+ return dest;
425
+ }
577
426
 
578
- do {
579
- remHi = (remHi << 2) | (remLo >>> 62); // N.B. - unsigned shift R
580
- remLo <<= 2;
581
- root <<= 1;
582
- long testDiv = (root << 1) + 1;
583
- if (remHi >= testDiv) {
584
- remHi -= testDiv;
585
- root++;
586
- }
587
- } while (count-- != 0);
427
+ private static void strokeTo(LinePath src, float width, int caps, int join,
428
+ float miterlimit, PMatrix2D transform,
429
+ LineStroker lsink) {
430
+ lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
431
+ FloatToS15_16(miterlimit),
432
+ transform == null ? identity : transform);
588
433
 
589
- return root;
590
- }
434
+ PathIterator pi = src.getPathIterator();
435
+ pathTo(pi, lsink);
436
+ }
591
437
 
438
+ private static void pathTo(PathIterator pi, LineStroker lsink) {
439
+ float coords[] = new float[6];
440
+ while (!pi.isDone()) {
441
+ int color;
442
+ switch (pi.currentSegment(coords)) {
443
+ case SEG_MOVETO:
444
+ color = ((int) coords[2] << 24)
445
+ | ((int) coords[3] << 16)
446
+ | ((int) coords[4] << 8)
447
+ | (int) coords[5];
448
+ lsink.moveTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
449
+ break;
450
+ case SEG_LINETO:
451
+ color = ((int) coords[2] << 24)
452
+ | ((int) coords[3] << 16)
453
+ | ((int) coords[4] << 8)
454
+ | (int) coords[5];
455
+ lsink.lineJoin();
456
+ lsink.lineTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
457
+ break;
458
+ case SEG_CLOSE:
459
+ lsink.lineJoin();
460
+ lsink.close();
461
+ break;
462
+ default:
463
+ throw new InternalError("unknown flattened segment type");
464
+ }
465
+ pi.next();
466
+ }
467
+ lsink.end();
468
+ }
592
469
 
593
- public static double hypot(double x, double y) {
594
- return Math.sqrt(x * x + y * y);
595
- }
470
+ /////////////////////////////////////////////////////////////////////////////
471
+ //
472
+ // Utility methods
473
+ public static float[] copyOf(float[] source, int length) {
474
+ float[] target = new float[length];
475
+ for (int i = 0; i < target.length; i++) {
476
+ if (i > source.length - 1) {
477
+ target[i] = 0f;
478
+ } else {
479
+ target[i] = source[i];
480
+ }
481
+ }
482
+ return target;
483
+ }
596
484
 
485
+ public static byte[] copyOf(byte[] source, int length) {
486
+ byte[] target = new byte[length];
487
+ for (int i = 0; i < target.length; i++) {
488
+ if (i > source.length - 1) {
489
+ target[i] = 0;
490
+ } else {
491
+ target[i] = source[i];
492
+ }
493
+ }
494
+ return target;
495
+ }
597
496
 
598
- public static int hypot(int x, int y) {
599
- return (int) ((lsqrt((long) x * x + (long) y * y) + 128) >> 8);
600
- }
497
+ public static int[] copyOf(int[] source, int length) {
498
+ int[] target = new int[length];
499
+ for (int i = 0; i < target.length; i++) {
500
+ if (i > source.length - 1) {
501
+ target[i] = 0;
502
+ } else {
503
+ target[i] = source[i];
504
+ }
505
+ }
506
+ return target;
507
+ }
601
508
 
509
+ // From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
510
+ public static int isqrt(int x) {
511
+ int fracbits = 16;
512
+
513
+ int root = 0;
514
+ int remHi = 0;
515
+ int remLo = x;
516
+ int count = 15 + fracbits / 2;
517
+
518
+ do {
519
+ remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
520
+ remLo <<= 2;
521
+ root <<= 1;
522
+ int testdiv = (root << 1) + 1;
523
+ if (remHi >= testdiv) {
524
+ remHi -= testdiv;
525
+ root++;
526
+ }
527
+ } while (count-- != 0);
528
+
529
+ return root;
530
+ }
602
531
 
603
- public static long hypot(long x, long y) {
604
- return (lsqrt(x * x + y * y) + 128) >> 8;
605
- }
532
+ public static long lsqrt(long x) {
533
+ int fracbits = 16;
534
+
535
+ long root = 0;
536
+ long remHi = 0;
537
+ long remLo = x;
538
+ int count = 31 + fracbits / 2;
539
+
540
+ do {
541
+ remHi = (remHi << 2) | (remLo >>> 62); // N.B. - unsigned shift R
542
+ remLo <<= 2;
543
+ root <<= 1;
544
+ long testDiv = (root << 1) + 1;
545
+ if (remHi >= testDiv) {
546
+ remHi -= testDiv;
547
+ root++;
548
+ }
549
+ } while (count-- != 0);
550
+
551
+ return root;
552
+ }
606
553
 
554
+ public static double hypot(double x, double y) {
555
+ return Math.sqrt(x * x + y * y);
556
+ }
557
+
558
+ public static int hypot(int x, int y) {
559
+ return (int) ((lsqrt((long) x * x + (long) y * y) + 128) >> 8);
560
+ }
607
561
 
608
- static int FloatToS15_16(float flt) {
609
- flt = flt * 65536f + 0.5f;
610
- if (flt <= -(65536f * 65536f)) {
611
- return Integer.MIN_VALUE;
612
- } else if (flt >= (65536f * 65536f)) {
613
- return Integer.MAX_VALUE;
614
- } else {
615
- return (int) Math.floor(flt);
562
+ public static long hypot(long x, long y) {
563
+ return (lsqrt(x * x + y * y) + 128) >> 8;
616
564
  }
617
- }
618
565
 
566
+ static int FloatToS15_16(float flt) {
567
+ flt = flt * 65536f + 0.5f;
568
+ if (flt <= -(65536f * 65536f)) {
569
+ return Integer.MIN_VALUE;
570
+ } else if (flt >= (65536f * 65536f)) {
571
+ return Integer.MAX_VALUE;
572
+ } else {
573
+ return (int) Math.floor(flt);
574
+ }
575
+ }
619
576
 
620
- static float S15_16ToFloat(int fix) {
621
- return (fix / 65536f);
622
- }
577
+ static float S15_16ToFloat(int fix) {
578
+ return (fix / 65536f);
579
+ }
623
580
  }