propane 3.4.0-java → 3.7.0.pre-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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -2
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -2
  5. data/.travis.yml +2 -2
  6. data/CHANGELOG.md +12 -0
  7. data/Gemfile +2 -0
  8. data/README.md +17 -8
  9. data/Rakefile +10 -11
  10. data/bin/propane +3 -1
  11. data/lib/propane.rb +6 -4
  12. data/lib/propane/app.rb +20 -10
  13. data/lib/propane/creators/sketch_class.rb +7 -1
  14. data/lib/propane/creators/sketch_factory.rb +4 -2
  15. data/lib/propane/creators/sketch_writer.rb +1 -0
  16. data/lib/propane/helper_methods.rb +23 -24
  17. data/lib/propane/helpers/numeric.rb +2 -0
  18. data/lib/propane/helpers/version_error.rb +1 -0
  19. data/lib/propane/library.rb +5 -1
  20. data/lib/propane/library_loader.rb +2 -0
  21. data/lib/propane/native_folder.rb +10 -9
  22. data/lib/propane/native_loader.rb +3 -0
  23. data/lib/propane/runner.rb +14 -6
  24. data/lib/propane/version.rb +2 -1
  25. data/library/boids/boids.rb +21 -11
  26. data/library/color_group/color_group.rb +28 -0
  27. data/library/control_panel/control_panel.rb +8 -5
  28. data/library/dxf/dxf.rb +6 -0
  29. data/library/file_chooser/chooser.rb +10 -9
  30. data/library/file_chooser/file_chooser.rb +10 -9
  31. data/library/library_proxy/library_proxy.rb +2 -0
  32. data/library/net/net.rb +7 -0
  33. data/library/simplex_noise/simplex_noise.rb +2 -0
  34. data/library/slider/slider.rb +23 -22
  35. data/library/vector_utils/vector_utils.rb +4 -0
  36. data/library/video_event/video_event.rb +4 -1
  37. data/pom.rb +37 -36
  38. data/pom.xml +7 -7
  39. data/propane.gemspec +16 -12
  40. data/src/main/java/monkstone/ColorUtil.java +13 -1
  41. data/src/main/java/monkstone/MathToolModule.java +253 -203
  42. data/src/main/java/monkstone/PropaneLibrary.java +2 -2
  43. data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
  44. data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
  45. data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
  46. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  47. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  48. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
  49. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  50. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  51. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  52. data/src/main/java/monkstone/slider/WheelHandler.java +7 -6
  53. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  54. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  55. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +3 -3
  56. data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
  57. data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
  58. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  59. data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
  60. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  61. data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
  62. data/src/main/java/processing/awt/PSurfaceAWT.java +309 -209
  63. data/src/main/java/processing/awt/ShimAWT.java +581 -0
  64. data/src/main/java/processing/core/PApplet.java +4510 -4503
  65. data/src/main/java/processing/core/PConstants.java +477 -447
  66. data/src/main/java/processing/core/PFont.java +914 -880
  67. data/src/main/java/processing/core/PGraphics.java +193 -177
  68. data/src/main/java/processing/core/PImage.java +611 -309
  69. data/src/main/java/processing/core/PMatrix.java +172 -159
  70. data/src/main/java/processing/core/PMatrix2D.java +478 -415
  71. data/src/main/java/processing/core/PMatrix3D.java +762 -735
  72. data/src/main/java/processing/core/PShape.java +2888 -2652
  73. data/src/main/java/processing/core/PShapeOBJ.java +97 -92
  74. data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
  75. data/src/main/java/processing/core/PStyle.java +40 -37
  76. data/src/main/java/processing/core/PSurface.java +139 -97
  77. data/src/main/java/processing/core/PSurfaceNone.java +296 -218
  78. data/src/main/java/processing/core/PVector.java +997 -965
  79. data/src/main/java/processing/core/ThinkDifferent.java +15 -13
  80. data/src/main/java/processing/data/DoubleDict.java +756 -710
  81. data/src/main/java/processing/data/DoubleList.java +749 -696
  82. data/src/main/java/processing/data/FloatDict.java +748 -702
  83. data/src/main/java/processing/data/FloatList.java +751 -697
  84. data/src/main/java/processing/data/IntDict.java +720 -673
  85. data/src/main/java/processing/data/IntList.java +699 -633
  86. data/src/main/java/processing/data/JSONArray.java +931 -873
  87. data/src/main/java/processing/data/JSONObject.java +1262 -1165
  88. data/src/main/java/processing/data/JSONTokener.java +351 -341
  89. data/src/main/java/processing/data/LongDict.java +710 -663
  90. data/src/main/java/processing/data/LongList.java +701 -635
  91. data/src/main/java/processing/data/Sort.java +37 -41
  92. data/src/main/java/processing/data/StringDict.java +525 -486
  93. data/src/main/java/processing/data/StringList.java +626 -580
  94. data/src/main/java/processing/data/Table.java +3690 -3510
  95. data/src/main/java/processing/data/TableRow.java +182 -183
  96. data/src/main/java/processing/data/XML.java +957 -883
  97. data/src/main/java/processing/dxf/RawDXF.java +404 -0
  98. data/src/main/java/processing/event/Event.java +87 -67
  99. data/src/main/java/processing/event/KeyEvent.java +48 -41
  100. data/src/main/java/processing/event/MouseEvent.java +88 -113
  101. data/src/main/java/processing/event/TouchEvent.java +10 -6
  102. data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
  103. data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
  104. data/src/main/java/processing/net/Client.java +744 -0
  105. data/src/main/java/processing/net/Server.java +388 -0
  106. data/src/main/java/processing/opengl/FontTexture.java +289 -270
  107. data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
  108. data/src/main/java/processing/opengl/LinePath.java +547 -500
  109. data/src/main/java/processing/opengl/LineStroker.java +588 -581
  110. data/src/main/java/processing/opengl/PGL.java +3047 -2914
  111. data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
  112. data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
  113. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
  114. data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
  115. data/src/main/java/processing/opengl/PShader.java +1266 -1257
  116. data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
  117. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
  118. data/src/main/java/processing/opengl/Texture.java +1492 -1401
  119. data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
  120. data/test/create_test.rb +21 -20
  121. data/test/deglut_spec_test.rb +4 -2
  122. data/test/helper_methods_test.rb +49 -20
  123. data/test/math_tool_test.rb +39 -32
  124. data/test/native_folder.rb +47 -0
  125. data/test/respond_to_test.rb +3 -2
  126. data/test/sketches/key_event.rb +2 -2
  127. data/test/sketches/library/my_library/my_library.rb +3 -0
  128. data/test/test_helper.rb +2 -0
  129. data/test/vecmath_spec_test.rb +35 -22
  130. data/vendors/Rakefile +33 -62
  131. metadata +56 -48
  132. data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
  133. data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
  134. data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
  135. data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
  136. data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
  137. data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
  138. data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
  139. data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
  140. data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
  141. data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
  142. data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
  143. data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
  144. data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
  145. data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
  146. data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
  147. data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
  148. data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
  149. data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
  150. data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
  151. data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
  152. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  153. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  154. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  155. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -0,0 +1,404 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+ /*
4
+ * RawDXF - Code to write DXF files with beginRaw/endRaw
5
+ * An extension for the Processing project - http://processing.org
6
+ * <p/>
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ * <p/>
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ * <p/>
17
+ * You should have received a copy of the GNU Lesser General
18
+ * Public License along with the Processing project; if not,
19
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
20
+ * Suite 330, Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ package processing.dxf;
24
+
25
+ import java.io.File;
26
+ import java.io.IOException;
27
+ import java.io.FileWriter;
28
+ import java.io.PrintWriter;
29
+ import processing.core.PGraphics;
30
+
31
+
32
+ /**
33
+ * A simple library to write DXF files with Processing.
34
+ * Because this is used with beginRaw() and endRaw(), only individual
35
+ * triangles and (discontinuous) line segments will be written to the file.
36
+ * <p>
37
+ * Use something like a keyPressed() in PApplet to trigger it,
38
+ * to avoid writing a bazillion .dxf files.
39
+ * <p>
40
+ * Usually, the file will be saved to the sketch's folder.
41
+ * Use Sketch &rarr; Show Sketch Folder to see it from the PDE.
42
+ * <p>
43
+ * A simple example of how to use:
44
+ * <PRE>
45
+ * import processing.dxf.*;
46
+ *
47
+ * boolean record;
48
+ *
49
+ * void setup() {
50
+ * size(500, 500, P3D);
51
+ * }
52
+ *
53
+ * void keyPressed() {
54
+ * // use a key press so that it doesn't make a million files
55
+ * if (key == 'r') record = true;
56
+ * }
57
+ *
58
+ * void draw() {
59
+ * if (record) {
60
+ * beginRaw(DXF, "output.dxf");
61
+ * }
62
+ *
63
+ * // do all your drawing here
64
+ *
65
+ * if (record) {
66
+ * endRaw();
67
+ * record = false;
68
+ * }
69
+ * }
70
+ * </PRE>
71
+ * or to use it and be able to control the current layer:
72
+ * <PRE>
73
+ * import processing.dxf.*;
74
+ *
75
+ * boolean record;
76
+ * RawDXF dxf;
77
+ *
78
+ * void setup() {
79
+ * size(500, 500, P3D);
80
+ * }
81
+ *
82
+ * void keyPressed() {
83
+ * // use a key press so that it doesn't make a million files
84
+ * if (key == 'r') record = true;
85
+ * }
86
+ *
87
+ * void draw() {
88
+ * if (record) {
89
+ * dxf = (RawDXF) createGraphics(width, height, DXF, "output.dxf");
90
+ * beginRaw(dxf);
91
+ * }
92
+ *
93
+ * // do all your drawing here, and to set the layer, call:
94
+ * // if (record) {
95
+ * // dxf.setLayer(num);
96
+ * // }
97
+ * // where 'num' is an integer.
98
+ * // the default is zero, or you can set it to whatever.
99
+ *
100
+ * if (record) {
101
+ * endRaw();
102
+ * record = false;
103
+ * dxf = null;
104
+ * }
105
+ * }
106
+ * </PRE>
107
+ * Note that even though this class is a subclass of PGraphics, it only
108
+ * implements the parts of the API that are necessary for beginRaw/endRaw.
109
+ * <p>
110
+ * Based on the original DXF writer from Simon Greenwold, February 2004.
111
+ * Updated for Processing 0070 by Ben Fry in September 2004,
112
+ * and again for Processing beta in April 2005.
113
+ * Rewritten to support beginRaw/endRaw by Ben Fry in February 2006.
114
+ * Updated again for inclusion as a core library in March 2006.
115
+ * Constructor modifications in September 2008 as we approach 1.0.
116
+ */
117
+ public class RawDXF extends PGraphics {
118
+
119
+ File file;
120
+ PrintWriter writer;
121
+ int currentLayer;
122
+
123
+
124
+ public RawDXF() { }
125
+
126
+ @Override
127
+ public void setPath(String path) {
128
+ this.path = path;
129
+ if (path != null) {
130
+ file = new File(path);
131
+ if (!file.isAbsolute()) file = null;
132
+ }
133
+ if (file == null) {
134
+ throw new RuntimeException("DXF export requires an absolute path " +
135
+ "for the location of the output file.");
136
+ }
137
+ }
138
+
139
+
140
+ // ..............................................................
141
+
142
+
143
+ protected void allocate() {
144
+ /*
145
+ for (int i = 0; i < MAX_TRI_LAYERS; i++) {
146
+ layerList[i] = NO_LAYER;
147
+ }
148
+ */
149
+ setLayer(0);
150
+ }
151
+
152
+
153
+ @Override
154
+ public void dispose() {
155
+ writeFooter();
156
+
157
+ writer.flush();
158
+ writer.close();
159
+ writer = null;
160
+ }
161
+
162
+ @Override
163
+ public boolean displayable() {
164
+ return false; // just in case someone wants to use this on its own
165
+ }
166
+
167
+ @Override
168
+ public boolean is2D() {
169
+ return false;
170
+ }
171
+
172
+
173
+ @Override
174
+ public boolean is3D() {
175
+ return true;
176
+ }
177
+ // ..............................................................
178
+
179
+ @Override
180
+ public void beginDraw() {
181
+ // have to create file object here, because the name isn't yet
182
+ // available in allocate()
183
+ if (writer == null) {
184
+ try {
185
+ writer = new PrintWriter(new FileWriter(file));
186
+ } catch (IOException e) {
187
+ throw new RuntimeException(e); // java 1.4+
188
+ }
189
+ writeHeader();
190
+ }
191
+ }
192
+
193
+ @Override
194
+ public void endDraw() {
195
+ writer.flush();
196
+ }
197
+
198
+
199
+ // ..............................................................
200
+
201
+
202
+ /**
203
+ * Set the current layer being used in the DXF file.The default is zero.
204
+ * @param layer
205
+ */
206
+ public void setLayer(int layer) {
207
+ currentLayer = layer;
208
+ }
209
+
210
+
211
+ // ..............................................................
212
+
213
+
214
+ private void writeHeader() {
215
+ writer.println("0");
216
+ writer.println("SECTION");
217
+ writer.println("2");
218
+ writer.println("ENTITIES");
219
+ }
220
+
221
+
222
+ private void writeFooter() {
223
+ writer.println("0");
224
+ writer.println("ENDSEC");
225
+ writer.println("0");
226
+ writer.println("EOF");
227
+ }
228
+
229
+
230
+ /**
231
+ * Write a command on one line (as a String), then start a new line
232
+ * and write out a formatted float.Available for anyone who wants to
233
+ insert additional commands into the DXF stream.
234
+ * @param cmd
235
+ * @param val
236
+ */
237
+ public void write(String cmd, float val) {
238
+ writer.println(cmd);
239
+ // Don't number format, will cause trouble on systems that aren't en-US
240
+ // http://dev.processing.org/bugs/show_bug.cgi?id=495
241
+ writer.println(val);
242
+ }
243
+
244
+
245
+ /**
246
+ * Write a line to the dxf file.Available for anyone who wants to
247
+ insert additional commands into the DXF stream.
248
+ * @param what
249
+ */
250
+ public void println(String what) {
251
+ writer.println(what);
252
+ }
253
+
254
+
255
+ protected void writeLine(int index1, int index2) {
256
+ writer.println("0");
257
+ writer.println("LINE");
258
+
259
+ // write out the layer
260
+ writer.println("8");
261
+ writer.println(String.valueOf(currentLayer));
262
+
263
+ write("10", vertices[index1][X]);
264
+ write("20", vertices[index1][Y]);
265
+ write("30", vertices[index1][Z]);
266
+
267
+ write("11", vertices[index2][X]);
268
+ write("21", vertices[index2][Y]);
269
+ write("31", vertices[index2][Z]);
270
+ }
271
+
272
+
273
+ /*
274
+ protected void writeLineStrip() {
275
+ writeLine();
276
+ // shift the last vertex to be the first vertex
277
+ System.arraycopy(vertices[1], 0, vertices[0], 0, vertices[1].length);
278
+ vertexCount = 1;
279
+ }
280
+ */
281
+
282
+ protected void writeTriangle() {
283
+ writer.println("0");
284
+ writer.println("3DFACE");
285
+
286
+ // write out the layer
287
+ writer.println("8");
288
+ /*
289
+ if (i < MAX_TRI_LAYERS) {
290
+ if (layerList[i] >= 0) {
291
+ currentLayer = layerList[i];
292
+ }
293
+ }
294
+ */
295
+ writer.println(String.valueOf(currentLayer));
296
+
297
+ write("10", vertices[0][X]);
298
+ write("20", vertices[0][Y]);
299
+ write("30", vertices[0][Z]);
300
+
301
+ write("11", vertices[1][X]);
302
+ write("21", vertices[1][Y]);
303
+ write("31", vertices[1][Z]);
304
+
305
+ write("12", vertices[2][X]);
306
+ write("22", vertices[2][Y]);
307
+ write("32", vertices[2][Z]);
308
+
309
+ // Without adding EPSILON, Rhino kinda freaks out.
310
+ // A face is actually a quad, not a triangle,
311
+ // so instead kinda fudging the final point here.
312
+ write("13", vertices[2][X] + EPSILON);
313
+ write("23", vertices[2][Y] + EPSILON);
314
+ write("33", vertices[2][Z] + EPSILON);
315
+
316
+ vertexCount = 0;
317
+ }
318
+ // ..............................................................
319
+
320
+ @Override
321
+ public void beginShape(int kind) {
322
+ shape = kind;
323
+
324
+ if ((shape != LINES) &&
325
+ (shape != TRIANGLES) &&
326
+ (shape != POLYGON)) {
327
+ String err =
328
+ "RawDXF can only be used with beginRaw(), " +
329
+ "because it only supports lines and triangles";
330
+ throw new RuntimeException(err);
331
+ }
332
+
333
+ if ((shape == POLYGON) && fill) {
334
+ throw new RuntimeException("DXF Export only supports non-filled shapes.");
335
+ }
336
+
337
+ vertexCount = 0;
338
+ }
339
+
340
+ @Override
341
+ public void vertex(float x, float y) {
342
+ vertex(x, y, 0);
343
+ }
344
+
345
+ @Override
346
+ public void vertex(float x, float y, float z) {
347
+ float vertex[] = vertices[vertexCount];
348
+ vertex[X] = x; // note: not mx, my, mz like PGraphics3
349
+ vertex[Y] = y;
350
+ vertex[Z] = z;
351
+
352
+ if (fill) {
353
+ vertex[R] = fillR;
354
+ vertex[G] = fillG;
355
+ vertex[B] = fillB;
356
+ vertex[A] = fillA;
357
+ }
358
+
359
+ if (stroke) {
360
+ vertex[SR] = strokeR;
361
+ vertex[SG] = strokeG;
362
+ vertex[SB] = strokeB;
363
+ vertex[SA] = strokeA;
364
+ vertex[SW] = strokeWeight;
365
+ }
366
+
367
+ if (textureImage != null) { // for the future?
368
+ vertex[U] = textureU;
369
+ vertex[V] = textureV;
370
+ }
371
+ vertexCount++;
372
+
373
+ if ((shape == LINES) && (vertexCount == 2)) {
374
+ writeLine(0, 1);
375
+ vertexCount = 0;
376
+
377
+ /*
378
+ } else if ((shape == LINE_STRIP) && (vertexCount == 2)) {
379
+ writeLineStrip();
380
+ */
381
+
382
+ } else if ((shape == TRIANGLES) && (vertexCount == 3)) {
383
+ writeTriangle();
384
+ }
385
+ }
386
+
387
+ @Override
388
+ public void endShape(int mode) {
389
+ if (shape == POLYGON) {
390
+ for (int i = 0; i < vertexCount - 1; i++) {
391
+ writeLine(i, i+1);
392
+ }
393
+ if (mode == CLOSE) {
394
+ writeLine(vertexCount - 1, 0);
395
+ }
396
+ }
397
+ /*
398
+ if ((vertexCount != 0) &&
399
+ ((shape != LINE_STRIP) && (vertexCount != 1))) {
400
+ System.err.println("Extra vertex boogers found.");
401
+ }
402
+ */
403
+ }
404
+ }
@@ -1,3 +1,5 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
1
3
  /*
2
4
  Part of the Processing project - http://processing.org
3
5
 
@@ -16,90 +18,108 @@
16
18
  Public License along with this library; if not, write to the
17
19
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18
20
  Boston, MA 02111-1307 USA
19
- */
21
+ */
22
+
20
23
  package processing.event;
21
24
 
25
+
22
26
  public class Event {
27
+ protected Object nativeObject;
28
+
29
+ protected long millis;
30
+ protected int action;
31
+
32
+ // These correspond to the java.awt.Event modifiers (not to be confused with
33
+ // the newer getModifiersEx), though they're not guaranteed to in the future.
34
+ static public final int SHIFT = 1 << 0;
35
+ static public final int CTRL = 1 << 1;
36
+ static public final int META = 1 << 2;
37
+ static public final int ALT = 1 << 3;
38
+ protected int modifiers;
39
+
40
+ // Types of events. As with all constants in Processing, brevity's preferred.
41
+ static public final int KEY = 1;
42
+ static public final int MOUSE = 2;
43
+ static public final int TOUCH = 3;
44
+ protected int flavor;
45
+
46
+
47
+ public Event(Object nativeObject, long millis, int action, int modifiers) {
48
+ this.nativeObject = nativeObject;
49
+ this.millis = millis;
50
+ this.action = action;
51
+ this.modifiers = modifiers;
52
+ }
53
+
54
+
55
+ public int getFlavor() {
56
+ return flavor;
57
+ }
58
+
59
+
60
+ /**
61
+ * Get the platform-native event object. This might be the java.awt event
62
+ * on the desktop, though if you're using OpenGL on the desktop it'll be a
63
+ * NEWT event that JOGL uses. Android events are something else altogether.
64
+ * Bottom line, use this only if you know what you're doing, and don't make
65
+ * assumptions about the class type.
66
+ */
67
+ public Object getNative() {
68
+ return nativeObject;
69
+ }
23
70
 
24
- protected Object nativeObject;
25
-
26
- protected long millis;
27
- protected int action;
28
-
29
- // These correspond to the java.awt.Event modifiers (not to be confused with
30
- // the newer getModifiersEx), though they're not guaranteed to in the future.
31
- static public final int SHIFT = 1;
32
- static public final int CTRL = 1 << 1;
33
- static public final int META = 1 << 2;
34
- static public final int ALT = 1 << 3;
35
- protected int modifiers;
36
-
37
- // Types of events. As with all constants in Processing, brevity's preferred.
38
- static public final int KEY = 1;
39
- static public final int MOUSE = 2;
40
- static public final int TOUCH = 3;
41
- protected int flavor;
42
-
43
- public Event(Object nativeObject, long millis, int action, int modifiers) {
44
- this.nativeObject = nativeObject;
45
- this.millis = millis;
46
- this.action = action;
47
- this.modifiers = modifiers;
48
- }
49
-
50
- public int getFlavor() {
51
- return flavor;
52
- }
53
-
54
- /**
55
- * Get the platform-native event object.This might be the java.awt event on
56
- the desktop, though if you're using OpenGL on the desktop it'll be a NEWT
57
- event that JOGL uses. Android events are something else altogether.
58
- Bottom line, use this only if you know what you're doing, and don't make
59
- assumptions about the class type.
60
- * @return
61
- */
62
- public Object getNative() {
63
- return nativeObject;
64
- }
65
71
 
66
72
  // public void setNative(Object nativeObject) {
67
73
  // this.nativeObject = nativeObject;
68
74
  // }
69
- public long getMillis() {
70
- return millis;
71
- }
75
+
76
+
77
+ public long getMillis() {
78
+ return millis;
79
+ }
80
+
72
81
 
73
82
  // public void setMillis(long millis) {
74
83
  // this.millis = millis;
75
84
  // }
76
- public int getAction() {
77
- return action;
78
- }
85
+
86
+
87
+ public int getAction() {
88
+ return action;
89
+ }
90
+
79
91
 
80
92
  // public void setAction(int action) {
81
93
  // this.action = action;
82
94
  // }
83
- public int getModifiers() {
84
- return modifiers;
85
- }
95
+
96
+
97
+ public int getModifiers() {
98
+ return modifiers;
99
+ }
100
+
86
101
 
87
102
  // public void setModifiers(int modifiers) {
88
103
  // this.modifiers = modifiers;
89
104
  // }
90
- public boolean isShiftDown() {
91
- return (modifiers & SHIFT) != 0;
92
- }
93
-
94
- public boolean isControlDown() {
95
- return (modifiers & CTRL) != 0;
96
- }
97
-
98
- public boolean isMetaDown() {
99
- return (modifiers & META) != 0;
100
- }
101
-
102
- public boolean isAltDown() {
103
- return (modifiers & ALT) != 0;
104
- }
105
- }
105
+
106
+
107
+ public boolean isShiftDown() {
108
+ return (modifiers & SHIFT) != 0;
109
+ }
110
+
111
+
112
+ public boolean isControlDown() {
113
+ return (modifiers & CTRL) != 0;
114
+ }
115
+
116
+
117
+ public boolean isMetaDown() {
118
+ return (modifiers & META) != 0;
119
+ }
120
+
121
+
122
+ public boolean isAltDown() {
123
+ return (modifiers & ALT) != 0;
124
+ }
125
+ }