propane 3.6.0-java → 3.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +5 -1
  5. data/README.md +6 -13
  6. data/Rakefile +7 -6
  7. data/lib/java/japplemenubar/JAppleMenuBar.java +88 -0
  8. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  9. data/lib/java/monkstone/ColorUtil.java +127 -0
  10. data/lib/java/monkstone/MathToolModule.java +287 -0
  11. data/lib/java/monkstone/PropaneLibrary.java +46 -0
  12. data/lib/java/monkstone/core/LibraryProxy.java +136 -0
  13. data/lib/java/monkstone/fastmath/DegLutTables.java +111 -0
  14. data/lib/java/monkstone/fastmath/Deglut.java +71 -0
  15. data/lib/java/monkstone/fastmath/package-info.java +6 -0
  16. data/lib/java/monkstone/filechooser/Chooser.java +39 -0
  17. data/lib/java/monkstone/noise/FastTerrain.java +874 -0
  18. data/lib/java/monkstone/noise/Noise.java +90 -0
  19. data/lib/java/monkstone/noise/NoiseGenerator.java +75 -0
  20. data/lib/java/monkstone/noise/NoiseMode.java +28 -0
  21. data/lib/java/monkstone/noise/OpenSimplex2F.java +881 -0
  22. data/lib/java/monkstone/noise/OpenSimplex2S.java +1106 -0
  23. data/lib/java/monkstone/noise/SmoothTerrain.java +1099 -0
  24. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +164 -0
  25. data/lib/java/monkstone/slider/CustomVerticalSlider.java +178 -0
  26. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +145 -0
  27. data/lib/java/monkstone/slider/SimpleSlider.java +166 -0
  28. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +157 -0
  29. data/lib/java/monkstone/slider/Slider.java +61 -0
  30. data/lib/java/monkstone/slider/SliderBar.java +245 -0
  31. data/lib/java/monkstone/slider/SliderGroup.java +56 -0
  32. data/lib/java/monkstone/slider/WheelHandler.java +35 -0
  33. data/lib/java/monkstone/vecmath/GfxRender.java +86 -0
  34. data/lib/java/monkstone/vecmath/JRender.java +56 -0
  35. data/lib/java/monkstone/vecmath/ShapeRender.java +87 -0
  36. data/lib/java/monkstone/vecmath/package-info.java +20 -0
  37. data/lib/java/monkstone/vecmath/vec2/Vec2.java +802 -0
  38. data/lib/java/monkstone/vecmath/vec2/package-info.java +6 -0
  39. data/lib/java/monkstone/vecmath/vec3/Vec3.java +727 -0
  40. data/lib/java/monkstone/vecmath/vec3/package-info.java +6 -0
  41. data/lib/java/monkstone/videoevent/CaptureEvent.java +27 -0
  42. data/lib/java/monkstone/videoevent/MovieEvent.java +32 -0
  43. data/lib/java/monkstone/videoevent/package-info.java +20 -0
  44. data/lib/java/processing/awt/PGraphicsJava2D.java +3040 -0
  45. data/lib/java/processing/awt/PImageAWT.java +377 -0
  46. data/lib/java/processing/awt/PShapeJava2D.java +387 -0
  47. data/lib/java/processing/awt/PSurfaceAWT.java +1581 -0
  48. data/lib/java/processing/awt/ShimAWT.java +581 -0
  49. data/lib/java/processing/core/PApplet.java +15156 -0
  50. data/lib/java/processing/core/PConstants.java +523 -0
  51. data/lib/java/processing/core/PFont.java +1126 -0
  52. data/lib/java/processing/core/PGraphics.java +8600 -0
  53. data/lib/java/processing/core/PImage.java +3377 -0
  54. data/lib/java/processing/core/PMatrix.java +208 -0
  55. data/lib/java/processing/core/PMatrix2D.java +562 -0
  56. data/lib/java/processing/core/PMatrix3D.java +890 -0
  57. data/lib/java/processing/core/PShape.java +3561 -0
  58. data/lib/java/processing/core/PShapeOBJ.java +483 -0
  59. data/lib/java/processing/core/PShapeSVG.java +2016 -0
  60. data/lib/java/processing/core/PStyle.java +63 -0
  61. data/lib/java/processing/core/PSurface.java +198 -0
  62. data/lib/java/processing/core/PSurfaceNone.java +431 -0
  63. data/lib/java/processing/core/PVector.java +1066 -0
  64. data/lib/java/processing/core/ThinkDifferent.java +115 -0
  65. data/lib/java/processing/data/DoubleDict.java +850 -0
  66. data/lib/java/processing/data/DoubleList.java +928 -0
  67. data/lib/java/processing/data/FloatDict.java +847 -0
  68. data/lib/java/processing/data/FloatList.java +936 -0
  69. data/lib/java/processing/data/IntDict.java +807 -0
  70. data/lib/java/processing/data/IntList.java +936 -0
  71. data/lib/java/processing/data/JSONArray.java +1260 -0
  72. data/lib/java/processing/data/JSONObject.java +2282 -0
  73. data/lib/java/processing/data/JSONTokener.java +435 -0
  74. data/lib/java/processing/data/LongDict.java +802 -0
  75. data/lib/java/processing/data/LongList.java +937 -0
  76. data/lib/java/processing/data/Sort.java +46 -0
  77. data/lib/java/processing/data/StringDict.java +613 -0
  78. data/lib/java/processing/data/StringList.java +800 -0
  79. data/lib/java/processing/data/Table.java +4936 -0
  80. data/lib/java/processing/data/TableRow.java +198 -0
  81. data/lib/java/processing/data/XML.java +1156 -0
  82. data/lib/java/processing/dxf/RawDXF.java +404 -0
  83. data/lib/java/processing/event/Event.java +125 -0
  84. data/lib/java/processing/event/KeyEvent.java +70 -0
  85. data/lib/java/processing/event/MouseEvent.java +114 -0
  86. data/lib/java/processing/event/TouchEvent.java +57 -0
  87. data/lib/java/processing/javafx/PGraphicsFX2D.java +32 -0
  88. data/lib/java/processing/javafx/PSurfaceFX.java +173 -0
  89. data/lib/java/processing/net/Client.java +744 -0
  90. data/lib/java/processing/net/Server.java +388 -0
  91. data/lib/java/processing/opengl/FontTexture.java +378 -0
  92. data/lib/java/processing/opengl/FrameBuffer.java +513 -0
  93. data/lib/java/processing/opengl/LinePath.java +627 -0
  94. data/lib/java/processing/opengl/LineStroker.java +681 -0
  95. data/lib/java/processing/opengl/PGL.java +3483 -0
  96. data/lib/java/processing/opengl/PGraphics2D.java +615 -0
  97. data/lib/java/processing/opengl/PGraphics3D.java +281 -0
  98. data/lib/java/processing/opengl/PGraphicsOpenGL.java +13753 -0
  99. data/lib/java/processing/opengl/PJOGL.java +2008 -0
  100. data/lib/java/processing/opengl/PShader.java +1484 -0
  101. data/lib/java/processing/opengl/PShapeOpenGL.java +5269 -0
  102. data/lib/java/processing/opengl/PSurfaceJOGL.java +1385 -0
  103. data/lib/java/processing/opengl/Texture.java +1696 -0
  104. data/lib/java/processing/opengl/VertexBuffer.java +88 -0
  105. data/lib/java/processing/opengl/cursors/arrow.png +0 -0
  106. data/lib/java/processing/opengl/cursors/cross.png +0 -0
  107. data/lib/java/processing/opengl/cursors/hand.png +0 -0
  108. data/lib/java/processing/opengl/cursors/license.txt +27 -0
  109. data/lib/java/processing/opengl/cursors/move.png +0 -0
  110. data/lib/java/processing/opengl/cursors/text.png +0 -0
  111. data/lib/java/processing/opengl/cursors/wait.png +0 -0
  112. data/lib/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  113. data/lib/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  114. data/lib/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  115. data/lib/java/processing/opengl/shaders/LightVert.glsl +151 -0
  116. data/lib/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  117. data/lib/java/processing/opengl/shaders/LineVert.glsl +100 -0
  118. data/lib/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  119. data/lib/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  120. data/lib/java/processing/opengl/shaders/PointVert.glsl +56 -0
  121. data/lib/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  122. data/lib/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  123. data/lib/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  124. data/lib/java/processing/opengl/shaders/TexVert.glsl +38 -0
  125. data/lib/java/processing/pdf/PGraphicsPDF.java +581 -0
  126. data/lib/java/processing/svg/PGraphicsSVG.java +378 -0
  127. data/lib/propane/app.rb +9 -10
  128. data/lib/propane/runner.rb +10 -12
  129. data/lib/propane/version.rb +1 -1
  130. data/library/pdf/pdf.rb +7 -0
  131. data/library/svg/svg.rb +7 -0
  132. data/mvnw +3 -3
  133. data/mvnw.cmd +2 -2
  134. data/pom.rb +30 -3
  135. data/pom.xml +54 -3
  136. data/propane.gemspec +7 -3
  137. data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
  138. data/src/main/java/monkstone/MathToolModule.java +30 -30
  139. data/src/main/java/monkstone/PropaneLibrary.java +2 -0
  140. data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
  141. data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
  142. data/src/main/java/monkstone/fastmath/Deglut.java +6 -56
  143. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  144. data/src/main/java/monkstone/noise/OpenSimplex2F.java +813 -0
  145. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -0
  146. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  147. data/src/main/java/monkstone/vecmath/JRender.java +6 -6
  148. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +20 -19
  149. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +12 -12
  150. data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -3
  151. data/src/main/java/processing/core/PApplet.java +13242 -13374
  152. data/src/main/java/processing/core/PConstants.java +155 -163
  153. data/src/main/java/processing/core/PGraphics.java +118 -111
  154. data/src/main/java/processing/opengl/PJOGL.java +6 -5
  155. data/src/main/java/processing/pdf/PGraphicsPDF.java +581 -0
  156. data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
  157. data/test/deglut_spec_test.rb +2 -2
  158. data/vendors/Rakefile +1 -1
  159. metadata +146 -17
  160. data/library/simplex_noise/simplex_noise.rb +0 -5
  161. data/src/main/java/monkstone/noise/SimplexNoise.java +0 -436
@@ -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
+ }
@@ -0,0 +1,125 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+ /*
4
+ Part of the Processing project - http://processing.org
5
+
6
+ Copyright (c) 2012 The Processing Foundation
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
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
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ package processing.event;
24
+
25
+
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
+ }
70
+
71
+
72
+ // public void setNative(Object nativeObject) {
73
+ // this.nativeObject = nativeObject;
74
+ // }
75
+
76
+
77
+ public long getMillis() {
78
+ return millis;
79
+ }
80
+
81
+
82
+ // public void setMillis(long millis) {
83
+ // this.millis = millis;
84
+ // }
85
+
86
+
87
+ public int getAction() {
88
+ return action;
89
+ }
90
+
91
+
92
+ // public void setAction(int action) {
93
+ // this.action = action;
94
+ // }
95
+
96
+
97
+ public int getModifiers() {
98
+ return modifiers;
99
+ }
100
+
101
+
102
+ // public void setModifiers(int modifiers) {
103
+ // this.modifiers = modifiers;
104
+ // }
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
+ }