propane 3.4.2-java → 3.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.md +9 -1
- data/Gemfile +2 -0
- data/README.md +7 -10
- data/Rakefile +10 -11
- data/bin/propane +3 -1
- data/lib/propane.rb +4 -2
- data/lib/propane/app.rb +5 -1
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +22 -23
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +20 -14
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +2 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/pom.rb +37 -36
- data/pom.xml +7 -7
- data/propane.gemspec +13 -9
- data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
- data/src/main/java/monkstone/ColorUtil.java +1 -3
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +6 -56
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/Noise.java +116 -0
- data/src/main/java/monkstone/noise/NoiseGenerator.java +63 -0
- data/src/main/java/monkstone/noise/NoiseMode.java +15 -0
- data/src/main/java/monkstone/noise/SimplexNoise.java +137 -103
- data/src/main/java/monkstone/noise/ValueNoise.java +170 -0
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
- data/src/main/java/processing/awt/PSurfaceAWT.java +308 -208
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +13142 -13883
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +152 -136
- data/src/main/java/processing/core/PImage.java +275 -372
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -415
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2887 -2651
- data/src/main/java/processing/core/PShapeOBJ.java +97 -92
- data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -218
- data/src/main/java/processing/core/PVector.java +995 -963
- data/src/main/java/processing/core/ThinkDifferent.java +12 -8
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +20 -20
- data/src/main/java/processing/net/Server.java +9 -9
- data/src/main/java/processing/opengl/FontTexture.java +286 -266
- data/src/main/java/processing/opengl/FrameBuffer.java +389 -377
- data/src/main/java/processing/opengl/LinePath.java +132 -89
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +660 -567
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +369 -461
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +35 -40
- metadata +47 -23
- data/library/simplex_noise/simplex_noise.rb +0 -3
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -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,7 +18,8 @@
|
|
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.awt;
|
21
24
|
|
22
25
|
import java.awt.Canvas;
|
@@ -38,6 +41,7 @@ import java.awt.Toolkit;
|
|
38
41
|
import java.awt.event.*;
|
39
42
|
import java.awt.geom.Rectangle2D;
|
40
43
|
import java.awt.image.*;
|
44
|
+
import java.io.File;
|
41
45
|
import java.lang.management.ManagementFactory;
|
42
46
|
import java.lang.reflect.InvocationTargetException;
|
43
47
|
import java.lang.reflect.Method;
|
@@ -46,7 +50,6 @@ import java.util.ArrayList;
|
|
46
50
|
import java.util.List;
|
47
51
|
|
48
52
|
import javax.swing.JFrame;
|
49
|
-
import processing.core.ThinkDifferent;
|
50
53
|
|
51
54
|
import processing.core.PApplet;
|
52
55
|
import processing.core.PConstants;
|
@@ -56,12 +59,13 @@ import processing.core.PSurfaceNone;
|
|
56
59
|
import processing.event.KeyEvent;
|
57
60
|
import processing.event.MouseEvent;
|
58
61
|
|
59
|
-
public class PSurfaceAWT extends PSurfaceNone {
|
60
62
|
|
63
|
+
public class PSurfaceAWT extends PSurfaceNone {
|
61
64
|
GraphicsDevice displayDevice;
|
62
65
|
|
63
66
|
// used for canvas to determine whether resizable or not
|
64
67
|
// boolean resizable; // default is false
|
68
|
+
|
65
69
|
// Internally, we know it's always a JFrame (not just a Frame)
|
66
70
|
// JFrame frame;
|
67
71
|
// Trying Frame again with a11 to see if this avoids some Swing nastiness.
|
@@ -79,15 +83,18 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
79
83
|
|
80
84
|
// 3.0a5 didn't use strategy, and active was shut off during init() w/ retina
|
81
85
|
// boolean useStrategy = true;
|
86
|
+
|
82
87
|
Canvas canvas;
|
83
88
|
// Component canvas;
|
84
89
|
|
85
90
|
// PGraphics graphics; // moved to PSurfaceNone
|
91
|
+
|
86
92
|
int sketchWidth;
|
87
93
|
int sketchHeight;
|
88
94
|
|
89
95
|
int windowScaleFactor;
|
90
96
|
|
97
|
+
|
91
98
|
public PSurfaceAWT(PGraphics graphics) {
|
92
99
|
//this.graphics = graphics;
|
93
100
|
super(graphics);
|
@@ -113,7 +120,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
113
120
|
// flicker--pushing pixels out before the screen has finished rendering.
|
114
121
|
// useStrategy = false;
|
115
122
|
}
|
116
|
-
|
123
|
+
*/
|
117
124
|
canvas = new SmoothCanvas();
|
118
125
|
// if (useStrategy) {
|
119
126
|
//canvas.setIgnoreRepaint(true);
|
@@ -129,8 +136,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
129
136
|
// make sure this is a real resize event, not just initial setup
|
130
137
|
// https://github.com/processing/processing/issues/3310
|
131
138
|
Dimension canvasSize = canvas.getSize();
|
132
|
-
if (canvasSize.width != sketch.sketchWidth()
|
133
|
-
|
139
|
+
if (canvasSize.width != sketch.sketchWidth() ||
|
140
|
+
canvasSize.height != sketch.sketchHeight()) {
|
134
141
|
sketch.redraw();
|
135
142
|
}
|
136
143
|
}
|
@@ -139,6 +146,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
139
146
|
addListeners();
|
140
147
|
}
|
141
148
|
|
149
|
+
|
142
150
|
// /**
|
143
151
|
// * Handle grabbing the focus on startup. Other renderers can override this
|
144
152
|
// * if handling needs to be different. For the AWT, the request is invoked
|
@@ -173,33 +181,41 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
173
181
|
// }
|
174
182
|
// });
|
175
183
|
// }
|
184
|
+
|
185
|
+
|
176
186
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
177
|
-
public class SmoothCanvas extends Canvas {
|
178
187
|
|
188
|
+
|
189
|
+
public class SmoothCanvas extends Canvas {
|
179
190
|
private Dimension oldSize = new Dimension(0, 0);
|
180
191
|
private Dimension newSize = new Dimension(0, 0);
|
181
192
|
|
193
|
+
|
182
194
|
// Turns out getParent() returns a JPanel on a JFrame. Yech.
|
183
195
|
public Frame getFrame() {
|
184
196
|
return frame;
|
185
197
|
}
|
186
198
|
|
199
|
+
|
187
200
|
@Override
|
188
201
|
public Dimension getPreferredSize() {
|
189
202
|
return new Dimension(sketchWidth, sketchHeight);
|
190
203
|
}
|
191
204
|
|
205
|
+
|
192
206
|
@Override
|
193
207
|
public Dimension getMinimumSize() {
|
194
208
|
return getPreferredSize();
|
195
209
|
}
|
196
210
|
|
211
|
+
|
197
212
|
@Override
|
198
213
|
public Dimension getMaximumSize() {
|
199
214
|
//return resizable ? super.getMaximumSize() : getPreferredSize();
|
200
215
|
return frame.isResizable() ? super.getMaximumSize() : getPreferredSize();
|
201
216
|
}
|
202
217
|
|
218
|
+
|
203
219
|
@Override
|
204
220
|
public void validate() {
|
205
221
|
super.validate();
|
@@ -221,12 +237,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
221
237
|
}
|
222
238
|
}
|
223
239
|
|
240
|
+
|
224
241
|
@Override
|
225
242
|
public void update(Graphics g) {
|
226
243
|
// System.out.println("updating");
|
227
244
|
paint(g);
|
228
245
|
}
|
229
246
|
|
247
|
+
|
230
248
|
@Override
|
231
249
|
public void paint(Graphics screen) {
|
232
250
|
// System.out.println("painting");
|
@@ -237,7 +255,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
237
255
|
System.out.println("drawing to screen " + canvas);
|
238
256
|
screen.drawImage(graphics.image, 0, 0, sketchWidth, sketchHeight, null);
|
239
257
|
}
|
240
|
-
|
258
|
+
*/
|
241
259
|
|
242
260
|
// } else {
|
243
261
|
//// new Exception("painting").printStackTrace(System.out);
|
@@ -254,7 +272,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
254
272
|
}
|
255
273
|
}
|
256
274
|
|
257
|
-
|
275
|
+
/*
|
258
276
|
@Override
|
259
277
|
public void addNotify() {
|
260
278
|
// System.out.println("adding notify");
|
@@ -262,10 +280,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
262
280
|
// prior to Java 7 on OS X, this no longer works [121222]
|
263
281
|
// createBufferStrategy(2);
|
264
282
|
}
|
265
|
-
|
283
|
+
*/
|
284
|
+
|
285
|
+
|
266
286
|
synchronized protected void render() {
|
267
|
-
if (canvas.isDisplayable()
|
268
|
-
|
287
|
+
if (canvas.isDisplayable() &&
|
288
|
+
graphics.image != null) {
|
269
289
|
if (canvas.getBufferStrategy() == null) {
|
270
290
|
canvas.createBufferStrategy(2);
|
271
291
|
}
|
@@ -335,7 +355,44 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
335
355
|
}
|
336
356
|
}
|
337
357
|
}
|
338
|
-
|
358
|
+
*/
|
359
|
+
|
360
|
+
|
361
|
+
/*
|
362
|
+
@Override
|
363
|
+
public int displayDensity() {
|
364
|
+
return shim.displayDensity();
|
365
|
+
}
|
366
|
+
|
367
|
+
|
368
|
+
@Override
|
369
|
+
public int displayDensity(int display) {
|
370
|
+
return shim.displayDensity(display);
|
371
|
+
}
|
372
|
+
*/
|
373
|
+
|
374
|
+
|
375
|
+
@Override
|
376
|
+
public void selectInput(String prompt, String callback,
|
377
|
+
File file, Object callbackObject) {
|
378
|
+
ShimAWT.selectInput(prompt, callback, file, callbackObject);
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
@Override
|
383
|
+
public void selectOutput(String prompt, String callback,
|
384
|
+
File file, Object callbackObject) {
|
385
|
+
ShimAWT.selectOutput(prompt, callback, file, callbackObject);
|
386
|
+
}
|
387
|
+
|
388
|
+
|
389
|
+
@Override
|
390
|
+
public void selectFolder(String prompt, String callback,
|
391
|
+
File file, Object callbackObject) {
|
392
|
+
ShimAWT.selectFolder(prompt, callback, file, callbackObject);
|
393
|
+
}
|
394
|
+
|
395
|
+
|
339
396
|
// what needs to happen here?
|
340
397
|
@Override
|
341
398
|
public void initOffscreen(PApplet sketch) {
|
@@ -349,9 +406,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
349
406
|
// but don't show it
|
350
407
|
return dummy;
|
351
408
|
}
|
352
|
-
|
409
|
+
*/
|
353
410
|
|
354
|
-
|
411
|
+
/*
|
355
412
|
@Override
|
356
413
|
public Component initComponent(PApplet sketch) {
|
357
414
|
this.sketch = sketch;
|
@@ -362,14 +419,16 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
362
419
|
|
363
420
|
return canvas;
|
364
421
|
}
|
365
|
-
|
422
|
+
*/
|
423
|
+
|
424
|
+
|
366
425
|
@Override
|
367
426
|
public void initFrame(final PApplet sketch) {/*, int backgroundColor,
|
368
427
|
int deviceIndex, boolean fullScreen, boolean spanDisplays) {*/
|
369
428
|
this.sketch = sketch;
|
370
429
|
|
371
|
-
GraphicsEnvironment environment
|
372
|
-
|
430
|
+
GraphicsEnvironment environment =
|
431
|
+
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
373
432
|
|
374
433
|
int displayNum = sketch.sketchDisplay();
|
375
434
|
// System.out.println("display from sketch is " + displayNum);
|
@@ -378,10 +437,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
378
437
|
if (displayNum <= devices.length) {
|
379
438
|
displayDevice = devices[displayNum - 1];
|
380
439
|
} else {
|
381
|
-
System.err.format("Display %d does not exist, "
|
382
|
-
|
440
|
+
System.err.format("Display %d does not exist, " +
|
441
|
+
"using the default display instead.%n", displayNum);
|
383
442
|
for (int i = 0; i < devices.length; i++) {
|
384
|
-
System.err.format("Display %d is %s%n", (i
|
443
|
+
System.err.format("Display %d is %s%n", (i+1), devices[i]);
|
385
444
|
}
|
386
445
|
}
|
387
446
|
}
|
@@ -393,8 +452,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
393
452
|
// because pack() will cause the bounds to go to zero.
|
394
453
|
// http://dev.processing.org/bugs/show_bug.cgi?id=923
|
395
454
|
boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN;
|
396
|
-
screenRect = spanDisplays ? getDisplaySpan()
|
397
|
-
|
455
|
+
screenRect = spanDisplays ? getDisplaySpan() :
|
456
|
+
displayDevice.getDefaultConfiguration().getBounds();
|
398
457
|
// DisplayMode doesn't work here, because we can't get the upper-left
|
399
458
|
// corner of the display, which is important for multi-display setups.
|
400
459
|
|
@@ -403,8 +462,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
403
462
|
sketch.displayWidth = screenRect.width;
|
404
463
|
sketch.displayHeight = screenRect.height;
|
405
464
|
|
406
|
-
windowScaleFactor = PApplet.platform == PConstants.
|
407
|
-
|
465
|
+
windowScaleFactor = PApplet.platform == PConstants.MACOS ?
|
466
|
+
1 : sketch.pixelDensity;
|
408
467
|
|
409
468
|
sketchWidth = sketch.sketchWidth() * windowScaleFactor;
|
410
469
|
sketchHeight = sketch.sketchHeight() * windowScaleFactor;
|
@@ -422,7 +481,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
422
481
|
fullScreen = true;
|
423
482
|
sketch.fullScreen(); // won't change the renderer
|
424
483
|
}
|
425
|
-
|
484
|
+
*/
|
426
485
|
|
427
486
|
if (fullScreen || spanDisplays) {
|
428
487
|
sketchWidth = screenRect.width;
|
@@ -462,6 +521,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
462
521
|
// and launches the Thread that will kick off setup().
|
463
522
|
// http://dev.processing.org/bugs/show_bug.cgi?id=891
|
464
523
|
// http://dev.processing.org/bugs/show_bug.cgi?id=908
|
524
|
+
|
465
525
|
frame.add(canvas);
|
466
526
|
setSize(sketchWidth / windowScaleFactor, sketchHeight / windowScaleFactor);
|
467
527
|
|
@@ -488,7 +548,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
488
548
|
// will be set visible in placeWindow() [3.0a10]
|
489
549
|
//frame.setVisible(true); // re-add native resources
|
490
550
|
}
|
491
|
-
|
551
|
+
*/
|
492
552
|
frame.setLayout(null);
|
493
553
|
//frame.add(applet);
|
494
554
|
|
@@ -497,7 +557,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
497
557
|
// spanScreens was in use.
|
498
558
|
// pg = sketch.makePrimaryGraphics(sketchWidth, sketchHeight);
|
499
559
|
// pg = sketch.makePrimaryGraphics();
|
560
|
+
|
500
561
|
// resize sketch to sketchWidth/sketchHeight here
|
562
|
+
|
501
563
|
if (fullScreen) {
|
502
564
|
frame.invalidate();
|
503
565
|
} else {
|
@@ -506,6 +568,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
506
568
|
|
507
569
|
// insufficient, places the 100x100 sketches offset strangely
|
508
570
|
//frame.validate();
|
571
|
+
|
509
572
|
// disabling resize has to happen after pack() to avoid apparent Apple bug
|
510
573
|
// http://code.google.com/p/processing/issues/detail?id=467
|
511
574
|
frame.setResizable(false);
|
@@ -520,37 +583,36 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
520
583
|
// sketch.setFrame(frame);
|
521
584
|
}
|
522
585
|
|
586
|
+
|
523
587
|
@Override
|
524
588
|
public Object getNative() {
|
525
589
|
return canvas;
|
526
590
|
}
|
527
591
|
|
592
|
+
|
528
593
|
// public Toolkit getToolkit() {
|
529
594
|
// return canvas.getToolkit();
|
530
595
|
// }
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
* @param title
|
535
|
-
*/
|
596
|
+
|
597
|
+
|
598
|
+
/** Set the window (and dock, or whatever necessary) title.
|
599
|
+
* @param title */
|
536
600
|
@Override
|
537
601
|
public void setTitle(String title) {
|
538
602
|
frame.setTitle(title);
|
539
603
|
// Workaround for apparent Java bug on OS X?
|
540
604
|
// https://github.com/processing/processing/issues/3472
|
541
|
-
if (cursorVisible
|
542
|
-
|
543
|
-
|
605
|
+
if (cursorVisible &&
|
606
|
+
(PApplet.platform == PConstants.MACOS) &&
|
607
|
+
(cursorType != PConstants.ARROW)) {
|
544
608
|
hideCursor();
|
545
609
|
showCursor();
|
546
610
|
}
|
547
611
|
}
|
548
612
|
|
549
|
-
|
550
|
-
|
551
|
-
*
|
552
|
-
* @param resizable
|
553
|
-
*/
|
613
|
+
|
614
|
+
/** Set true if we want to resize things (default is not resizable)
|
615
|
+
* @param resizable */
|
554
616
|
@Override
|
555
617
|
public void setResizable(boolean resizable) {
|
556
618
|
//this.resizable = resizable; // really only used for canvas
|
@@ -560,80 +622,103 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
560
622
|
}
|
561
623
|
}
|
562
624
|
|
625
|
+
|
563
626
|
@Override
|
564
627
|
public void setIcon(PImage image) {
|
565
628
|
Image awtImage = (Image) image.getNative();
|
566
|
-
|
567
|
-
|
629
|
+
|
630
|
+
if (PApplet.platform != PConstants.MACOS) {
|
631
|
+
frame.setIconImage(awtImage);
|
632
|
+
|
633
|
+
} else {
|
634
|
+
try {
|
635
|
+
final String td = "processing.core.ThinkDifferent";
|
636
|
+
Class<?> thinkDifferent =
|
637
|
+
Thread.currentThread().getContextClassLoader().loadClass(td);
|
638
|
+
Method method =
|
639
|
+
thinkDifferent.getMethod("setIconImage", Image.class);
|
640
|
+
method.invoke(null, awtImage);
|
641
|
+
} catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
|
642
|
+
// That's unfortunate
|
643
|
+
|
644
|
+
}
|
645
|
+
}
|
568
646
|
}
|
569
647
|
|
648
|
+
|
570
649
|
@Override
|
571
650
|
public void setAlwaysOnTop(boolean always) {
|
572
651
|
frame.setAlwaysOnTop(always);
|
573
652
|
}
|
574
653
|
|
654
|
+
|
575
655
|
@Override
|
576
656
|
public void setLocation(int x, int y) {
|
577
657
|
frame.setLocation(x, y);
|
578
658
|
}
|
579
659
|
|
660
|
+
|
580
661
|
List<Image> iconImages;
|
581
662
|
|
582
663
|
protected void setProcessingIcon(Frame frame) {
|
583
664
|
// On OS X, this only affects what shows up in the dock when minimized.
|
584
665
|
// So replacing it is actually a step backwards. Brilliant.
|
585
|
-
if (PApplet.platform != PConstants.
|
666
|
+
if (PApplet.platform != PConstants.MACOS) {
|
586
667
|
//Image image = Toolkit.getDefaultToolkit().createImage(ICON_IMAGE);
|
587
668
|
//frame.setIconImage(image);
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
669
|
+
try {
|
670
|
+
if (iconImages == null) {
|
671
|
+
iconImages = new ArrayList<>();
|
672
|
+
final int[] sizes = { 16, 32, 48, 64, 128, 256, 512 };
|
673
|
+
|
674
|
+
for (int sz : sizes) {
|
675
|
+
//URL url = getClass().getResource("/icon/icon-" + sz + ".png");
|
676
|
+
URL url = PApplet.class.getResource("/icon/icon-" + sz + ".png");
|
677
|
+
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
678
|
+
iconImages.add(image);
|
679
|
+
//iconImages.add(Toolkit.getLibImage("icons/pde-" + sz + ".png", frame));
|
680
|
+
}
|
599
681
|
}
|
600
|
-
|
601
|
-
|
682
|
+
frame.setIconImages(iconImages);
|
683
|
+
|
684
|
+
} catch (Exception e) { } // harmless; keep this to ourselves
|
602
685
|
|
603
|
-
// } catch (Exception e) {
|
604
|
-
// } // harmless; keep this to ourselves
|
605
686
|
} else { // handle OS X differently
|
606
687
|
if (!dockIconSpecified()) { // don't override existing -Xdock param
|
607
688
|
// On OS X, set this for AWT surfaces, which handles the dock image
|
608
689
|
// as well as the cmd-tab image that's shown. Just one size, I guess.
|
609
690
|
URL url = PApplet.class.getResource("/icon/icon-512.png");
|
610
691
|
// Seems dangerous to have this in code instead of using reflection, no?
|
611
|
-
//
|
692
|
+
//ThinkDifferent.setIconImage(Toolkit.getDefaultToolkit().getImage(url));
|
612
693
|
try {
|
613
694
|
final String td = "processing.core.ThinkDifferent";
|
614
|
-
Class<?> thinkDifferent
|
615
|
-
|
616
|
-
Method method
|
617
|
-
|
618
|
-
method.invoke(null,
|
695
|
+
Class<?> thinkDifferent =
|
696
|
+
Thread.currentThread().getContextClassLoader().loadClass(td);
|
697
|
+
Method method =
|
698
|
+
thinkDifferent.getMethod("setIconImage", Image.class);
|
699
|
+
method.invoke(null, Toolkit.getDefaultToolkit().getImage(url));
|
619
700
|
} catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
|
620
701
|
// That's unfortunate
|
702
|
+
|
621
703
|
}
|
622
704
|
}
|
623
705
|
}
|
624
706
|
}
|
625
707
|
|
708
|
+
|
626
709
|
/**
|
627
710
|
* @return true if -Xdock:icon was specified on the command line
|
628
711
|
*/
|
629
712
|
private boolean dockIconSpecified() {
|
630
713
|
// TODO This is incomplete... Haven't yet found a way to figure out if
|
631
714
|
// the app has an icns file specified already. Help?
|
632
|
-
List<String> jvmArgs
|
633
|
-
|
634
|
-
|
715
|
+
List<String> jvmArgs =
|
716
|
+
ManagementFactory.getRuntimeMXBean().getInputArguments();
|
717
|
+
// dock image already set
|
718
|
+
return jvmArgs.stream().anyMatch((arg) -> (arg.startsWith("-Xdock:icon")));
|
635
719
|
}
|
636
720
|
|
721
|
+
|
637
722
|
@Override
|
638
723
|
public void setVisible(boolean visible) {
|
639
724
|
frame.setVisible(visible);
|
@@ -659,9 +744,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
659
744
|
insets.top + insets.bottom);
|
660
745
|
}
|
661
746
|
}
|
662
|
-
|
747
|
+
*/
|
663
748
|
}
|
664
749
|
|
750
|
+
|
665
751
|
//public void placeFullScreen(boolean hideStop) {
|
666
752
|
@Override
|
667
753
|
public void placePresent(int stopColor) {
|
@@ -670,13 +756,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
670
756
|
// After the pack(), the screen bounds are gonna be 0s
|
671
757
|
// frame.setBounds(screenRect); // already called in setFullFrame()
|
672
758
|
canvas.setBounds((screenRect.width - sketchWidth) / 2,
|
673
|
-
|
674
|
-
|
759
|
+
(screenRect.height - sketchHeight) / 2,
|
760
|
+
sketchWidth, sketchHeight);
|
675
761
|
|
676
762
|
// if (PApplet.platform == PConstants.MACOSX) {
|
677
763
|
// macosxFullScreenEnable(frame);
|
678
764
|
// macosxFullScreenToggle(frame);
|
679
765
|
// }
|
766
|
+
|
680
767
|
if (stopColor != 0) {
|
681
768
|
Label label = new Label("stop");
|
682
769
|
label.setForeground(new Color(stopColor, false));
|
@@ -746,21 +833,22 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
746
833
|
frame.setVisible(true);
|
747
834
|
}
|
748
835
|
}
|
749
|
-
|
836
|
+
*/
|
837
|
+
|
838
|
+
|
750
839
|
private void setCanvasSize() {
|
751
840
|
// System.out.format("setting canvas size %d %d%n", sketchWidth, sketchHeight);
|
752
841
|
// new Exception().printStackTrace(System.out);
|
753
842
|
int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH);
|
754
843
|
int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT);
|
755
844
|
|
756
|
-
canvas.setBounds((contentW - sketchWidth)
|
757
|
-
|
758
|
-
|
845
|
+
canvas.setBounds((contentW - sketchWidth)/2,
|
846
|
+
(contentH - sketchHeight)/2,
|
847
|
+
sketchWidth, sketchHeight);
|
759
848
|
}
|
760
849
|
|
761
|
-
|
762
|
-
|
763
|
-
*/
|
850
|
+
|
851
|
+
/** Resize frame for these sketch (canvas) dimensions. */
|
764
852
|
private Dimension setFrameSize() { //int sketchWidth, int sketchHeight) {
|
765
853
|
// https://github.com/processing/processing/pull/3162
|
766
854
|
frame.addNotify(); // using instead of show() to add the peer [fry]
|
@@ -768,24 +856,24 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
768
856
|
// System.out.format("setting frame size %d %d %n", sketchWidth, sketchHeight);
|
769
857
|
// new Exception().printStackTrace(System.out);
|
770
858
|
currentInsets = frame.getInsets();
|
771
|
-
int windowW = Math.max(sketchWidth, MIN_WINDOW_WIDTH)
|
772
|
-
|
773
|
-
int windowH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT)
|
774
|
-
|
859
|
+
int windowW = Math.max(sketchWidth, MIN_WINDOW_WIDTH) +
|
860
|
+
currentInsets.left + currentInsets.right;
|
861
|
+
int windowH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT) +
|
862
|
+
currentInsets.top + currentInsets.bottom;
|
775
863
|
frame.setSize(windowW, windowH);
|
776
864
|
return new Dimension(windowW, windowH);
|
777
865
|
}
|
778
866
|
|
867
|
+
|
779
868
|
private void setFrameCentered() {
|
780
869
|
// Can't use frame.setLocationRelativeTo(null) because it sends the
|
781
870
|
// frame to the main display, which undermines the --display setting.
|
782
871
|
frame.setLocation(screenRect.x + (screenRect.width - sketchWidth) / 2,
|
783
|
-
|
872
|
+
screenRect.y + (screenRect.height - sketchHeight) / 2);
|
784
873
|
}
|
785
874
|
|
786
|
-
|
787
|
-
|
788
|
-
*/
|
875
|
+
|
876
|
+
/** Hide the menu bar, make the Frame undecorated, set it to screenRect. */
|
789
877
|
private void setFullFrame() {
|
790
878
|
// Called here because the graphics device is needed before we can
|
791
879
|
// determine whether the sketch wants size(displayWidth, displayHeight),
|
@@ -795,6 +883,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
795
883
|
// Tried to use this to fix the 'present' mode issue.
|
796
884
|
// Did not help, and the screenRect setup seems to work fine.
|
797
885
|
//frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
886
|
+
|
798
887
|
// https://github.com/processing/processing/pull/3162
|
799
888
|
//frame.dispose(); // release native resources, allows setUndecorated()
|
800
889
|
frame.removeNotify();
|
@@ -807,6 +896,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
807
896
|
//frame.setVisible(true); // re-add native resources
|
808
897
|
}
|
809
898
|
|
899
|
+
|
810
900
|
@Override
|
811
901
|
public void placeWindow(int[] location, int[] editorLocation) {
|
812
902
|
//Dimension window = setFrameSize(sketchWidth, sketchHeight);
|
@@ -850,7 +940,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
850
940
|
locationX = (sketch.displayWidth - window.width) / 2;
|
851
941
|
locationY = (sketch.displayHeight - window.height) / 2;
|
852
942
|
}
|
853
|
-
|
943
|
+
*/
|
854
944
|
frame.setLocation(locationX, locationY);
|
855
945
|
}
|
856
946
|
} else { // just center on screen
|
@@ -864,9 +954,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
864
954
|
}
|
865
955
|
}
|
866
956
|
|
867
|
-
canvas.setBounds((contentW - sketchWidth)
|
868
|
-
|
869
|
-
|
957
|
+
canvas.setBounds((contentW - sketchWidth)/2,
|
958
|
+
(contentH - sketchHeight)/2,
|
959
|
+
sketchWidth, sketchHeight);
|
870
960
|
|
871
961
|
// handle frame resizing events
|
872
962
|
setupFrameResizeListener();
|
@@ -882,12 +972,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
882
972
|
// canvas.requestFocus();
|
883
973
|
// }
|
884
974
|
}
|
885
|
-
|
975
|
+
*/
|
886
976
|
// if (sketch.getGraphics().displayable()) {
|
887
977
|
// setVisible(true);
|
888
978
|
// }
|
889
979
|
}
|
890
980
|
|
981
|
+
|
891
982
|
// needs to resize the frame, which will resize the canvas, and so on...
|
892
983
|
@Override
|
893
984
|
public void setSize(int wide, int high) {
|
@@ -905,9 +996,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
905
996
|
// //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
|
906
997
|
// new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
|
907
998
|
// }
|
999
|
+
|
908
1000
|
//if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
|
909
|
-
if (wide == sketch.width && high == sketch.height
|
910
|
-
|
1001
|
+
if (wide == sketch.width && high == sketch.height &&
|
1002
|
+
(frame == null || currentInsets.equals(frame.getInsets()))) {
|
911
1003
|
// if (PApplet.DEBUG) {
|
912
1004
|
// new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
|
913
1005
|
// }
|
@@ -928,6 +1020,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
928
1020
|
// }
|
929
1021
|
|
930
1022
|
//initImage(graphics, wide, high);
|
1023
|
+
|
931
1024
|
//throw new RuntimeException("implement me, see readme.md");
|
932
1025
|
sketch.setSize(wide, high);
|
933
1026
|
// sketch.width = wide;
|
@@ -938,6 +1031,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
938
1031
|
// System.out.println("out of setSize()");
|
939
1032
|
}
|
940
1033
|
|
1034
|
+
|
941
1035
|
//public void initImage(PGraphics gr, int wide, int high) {
|
942
1036
|
/*
|
943
1037
|
@Override
|
@@ -956,14 +1050,20 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
956
1050
|
int high = graphics.height * graphics.pixelFactor;
|
957
1051
|
graphics.image = gc.createCompatibleImage(wide, high);
|
958
1052
|
}
|
959
|
-
|
1053
|
+
*/
|
1054
|
+
|
1055
|
+
|
960
1056
|
// @Override
|
961
1057
|
// public Component getComponent() {
|
962
1058
|
// return canvas;
|
963
1059
|
// }
|
1060
|
+
|
1061
|
+
|
964
1062
|
// @Override
|
965
1063
|
// public void setSmooth(int level) {
|
966
1064
|
// }
|
1065
|
+
|
1066
|
+
|
967
1067
|
/*
|
968
1068
|
private boolean checkRetina() {
|
969
1069
|
if (PApplet.platform == PConstants.MACOSX) {
|
@@ -990,14 +1090,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
990
1090
|
}
|
991
1091
|
return false;
|
992
1092
|
}
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
1093
|
+
*/
|
1094
|
+
|
1095
|
+
|
1096
|
+
/** Get the bounds rectangle for all displays. */
|
997
1097
|
static Rectangle getDisplaySpan() {
|
998
1098
|
Rectangle bounds = new Rectangle();
|
999
|
-
GraphicsEnvironment environment
|
1000
|
-
|
1099
|
+
GraphicsEnvironment environment =
|
1100
|
+
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
1001
1101
|
for (GraphicsDevice device : environment.getScreenDevices()) {
|
1002
1102
|
for (GraphicsConfiguration config : device.getConfigurations()) {
|
1003
1103
|
Rectangle2D.union(bounds, config.getBounds(), bounds);
|
@@ -1021,13 +1121,15 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1021
1121
|
}
|
1022
1122
|
}
|
1023
1123
|
}
|
1024
|
-
|
1124
|
+
*/
|
1125
|
+
|
1126
|
+
|
1025
1127
|
/**
|
1026
1128
|
* Set this sketch to communicate its state back to the PDE.
|
1027
1129
|
*
|
1028
|
-
* This uses the stderr stream to write positions of the window
|
1029
|
-
* will be saved by the PDE for the next run) and
|
1030
|
-
* notes in the Worker class.
|
1130
|
+
* This uses the stderr stream to write positions of the window
|
1131
|
+
* (so that it will be saved by the PDE for the next run) and
|
1132
|
+
* notify on quit. See more notes in the Worker class.
|
1031
1133
|
*/
|
1032
1134
|
@Override
|
1033
1135
|
public void setupExternalMessages() {
|
@@ -1040,9 +1142,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1040
1142
|
});
|
1041
1143
|
}
|
1042
1144
|
|
1145
|
+
|
1043
1146
|
/**
|
1044
|
-
* Set up a listener that will fire proper component resize events
|
1045
|
-
* where frame.setResizable(true) is called.
|
1147
|
+
* Set up a listener that will fire proper component resize events
|
1148
|
+
* in cases where frame.setResizable(true) is called.
|
1046
1149
|
*/
|
1047
1150
|
private void setupFrameResizeListener() {
|
1048
1151
|
frame.addWindowStateListener((WindowEvent e) -> {
|
@@ -1097,6 +1200,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1097
1200
|
});
|
1098
1201
|
}
|
1099
1202
|
|
1203
|
+
|
1100
1204
|
// /**
|
1101
1205
|
// * (No longer in use) Use reflection to call
|
1102
1206
|
// * <code>com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(window, true);</code>
|
@@ -1137,7 +1241,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1137
1241
|
// e.printStackTrace();
|
1138
1242
|
// }
|
1139
1243
|
// }
|
1244
|
+
|
1245
|
+
|
1140
1246
|
//////////////////////////////////////////////////////////////
|
1247
|
+
|
1248
|
+
|
1141
1249
|
/*
|
1142
1250
|
// disabling for now; requires Java 1.7 and "precise" semantics are odd...
|
1143
1251
|
// returns 0.1 for tick-by-tick scrolling on OS X, but it's not a matter of
|
@@ -1151,12 +1259,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1151
1259
|
// ignored, the method will just be set to null
|
1152
1260
|
}
|
1153
1261
|
}
|
1154
|
-
|
1262
|
+
*/
|
1263
|
+
|
1264
|
+
|
1155
1265
|
/**
|
1156
|
-
* Figure out how to process a mouse event.When loop() has been
|
1157
|
-
|
1158
|
-
* called, then events will happen immediately.
|
1159
|
-
*
|
1266
|
+
* Figure out how to process a mouse event.When loop() has been
|
1267
|
+
called, the events will be queued up until drawing is complete. If noLoop() has been called, then events will happen immediately.
|
1160
1268
|
* @param nativeEvent
|
1161
1269
|
*/
|
1162
1270
|
protected void nativeMouseEvent(java.awt.event.MouseEvent nativeEvent) {
|
@@ -1166,31 +1274,31 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1166
1274
|
|
1167
1275
|
int peAction = 0;
|
1168
1276
|
switch (nativeEvent.getID()) {
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1277
|
+
case java.awt.event.MouseEvent.MOUSE_PRESSED:
|
1278
|
+
peAction = MouseEvent.PRESS;
|
1279
|
+
break;
|
1280
|
+
case java.awt.event.MouseEvent.MOUSE_RELEASED:
|
1281
|
+
peAction = MouseEvent.RELEASE;
|
1282
|
+
break;
|
1283
|
+
case java.awt.event.MouseEvent.MOUSE_CLICKED:
|
1284
|
+
peAction = MouseEvent.CLICK;
|
1285
|
+
break;
|
1286
|
+
case java.awt.event.MouseEvent.MOUSE_DRAGGED:
|
1287
|
+
peAction = MouseEvent.DRAG;
|
1288
|
+
break;
|
1289
|
+
case java.awt.event.MouseEvent.MOUSE_MOVED:
|
1290
|
+
peAction = MouseEvent.MOVE;
|
1291
|
+
break;
|
1292
|
+
case java.awt.event.MouseEvent.MOUSE_ENTERED:
|
1293
|
+
peAction = MouseEvent.ENTER;
|
1294
|
+
break;
|
1295
|
+
case java.awt.event.MouseEvent.MOUSE_EXITED:
|
1296
|
+
peAction = MouseEvent.EXIT;
|
1297
|
+
break;
|
1298
|
+
//case java.awt.event.MouseWheelEvent.WHEEL_UNIT_SCROLL:
|
1299
|
+
case java.awt.event.MouseEvent.MOUSE_WHEEL:
|
1300
|
+
peAction = MouseEvent.WHEEL;
|
1301
|
+
/*
|
1194
1302
|
if (preciseWheelMethod != null) {
|
1195
1303
|
try {
|
1196
1304
|
peAmount = ((Double) preciseWheelMethod.invoke(nativeEvent, (Object[]) null)).floatValue();
|
@@ -1198,95 +1306,71 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1198
1306
|
preciseWheelMethod = null;
|
1199
1307
|
}
|
1200
1308
|
}
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1309
|
+
*/
|
1310
|
+
peCount = ((MouseWheelEvent) nativeEvent).getWheelRotation();
|
1311
|
+
break;
|
1204
1312
|
}
|
1205
1313
|
|
1206
|
-
//
|
1207
|
-
//
|
1208
|
-
//
|
1209
|
-
int modifiers = nativeEvent.getModifiers();
|
1210
|
-
|
1211
|
-
int peModifiers = modifiers
|
1212
|
-
& (InputEvent.SHIFT_MASK
|
1213
|
-
| InputEvent.CTRL_MASK
|
1214
|
-
| InputEvent.META_MASK
|
1215
|
-
| InputEvent.ALT_MASK);
|
1216
|
-
|
1217
|
-
// Windows and OS X seem to disagree on how to handle this. Windows only
|
1218
|
-
// sets BUTTON1_DOWN_MASK, while OS X seems to set BUTTON1_MASK.
|
1219
|
-
// This is an issue in particular with mouse release events:
|
1314
|
+
// Switching to getModifiersEx() for 4.0a2 because of Java 9 deprecation.
|
1315
|
+
// Had trouble with this in the past and rolled it back because it was
|
1316
|
+
// optional at the time. This time around, just need to iron out the issue.
|
1220
1317
|
// http://code.google.com/p/processing/issues/detail?id=1294
|
1221
|
-
// The fix for which led to a regression (fixed here by checking both):
|
1222
1318
|
// http://code.google.com/p/processing/issues/detail?id=1332
|
1319
|
+
int modifiers = nativeEvent.getModifiersEx();
|
1320
|
+
|
1223
1321
|
int peButton = 0;
|
1224
|
-
|
1225
|
-
// (modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
|
1226
|
-
// peButton = LEFT;
|
1227
|
-
// } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0 ||
|
1228
|
-
// (modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
|
1229
|
-
// peButton = CENTER;
|
1230
|
-
// } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0 ||
|
1231
|
-
// (modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
|
1232
|
-
// peButton = RIGHT;
|
1233
|
-
// }
|
1234
|
-
if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
|
1322
|
+
if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
|
1235
1323
|
peButton = PConstants.LEFT;
|
1236
|
-
} else if ((modifiers & InputEvent.
|
1324
|
+
} else if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
|
1237
1325
|
peButton = PConstants.CENTER;
|
1238
|
-
} else if ((modifiers & InputEvent.
|
1326
|
+
} else if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
|
1239
1327
|
peButton = PConstants.RIGHT;
|
1240
1328
|
}
|
1241
1329
|
|
1242
|
-
// If running on Mac OS, allow ctrl-click as right mouse. Prior to 0215,
|
1243
|
-
// this used isPopupTrigger() on the native event, but that doesn't work
|
1244
|
-
// for mouseClicked and mouseReleased (or others).
|
1245
|
-
if (PApplet.platform == PConstants.MACOSX) {
|
1246
|
-
//if (nativeEvent.isPopupTrigger()) {
|
1247
|
-
if ((modifiers & InputEvent.CTRL_MASK) != 0) {
|
1248
|
-
peButton = PConstants.RIGHT;
|
1249
|
-
}
|
1250
|
-
}
|
1251
|
-
|
1252
1330
|
sketch.postEvent(new MouseEvent(nativeEvent, nativeEvent.getWhen(),
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1331
|
+
peAction, modifiers,
|
1332
|
+
nativeEvent.getX() / windowScaleFactor,
|
1333
|
+
nativeEvent.getY() / windowScaleFactor,
|
1334
|
+
peButton,
|
1335
|
+
peCount));
|
1258
1336
|
}
|
1259
1337
|
|
1338
|
+
|
1260
1339
|
protected void nativeKeyEvent(java.awt.event.KeyEvent event) {
|
1261
1340
|
int peAction = 0;
|
1262
1341
|
switch (event.getID()) {
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1342
|
+
case java.awt.event.KeyEvent.KEY_PRESSED:
|
1343
|
+
peAction = KeyEvent.PRESS;
|
1344
|
+
break;
|
1345
|
+
case java.awt.event.KeyEvent.KEY_RELEASED:
|
1346
|
+
peAction = KeyEvent.RELEASE;
|
1347
|
+
break;
|
1348
|
+
case java.awt.event.KeyEvent.KEY_TYPED:
|
1349
|
+
peAction = KeyEvent.TYPE;
|
1350
|
+
break;
|
1272
1351
|
}
|
1273
1352
|
|
1353
|
+
int modifiers = event.getModifiersEx();
|
1354
|
+
|
1355
|
+
/*
|
1274
1356
|
// int peModifiers = event.getModifiersEx() &
|
1275
1357
|
// (InputEvent.SHIFT_DOWN_MASK |
|
1276
1358
|
// InputEvent.CTRL_DOWN_MASK |
|
1277
1359
|
// InputEvent.META_DOWN_MASK |
|
1278
1360
|
// InputEvent.ALT_DOWN_MASK);
|
1279
|
-
int peModifiers = event.getModifiers()
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1361
|
+
int peModifiers = event.getModifiers() &
|
1362
|
+
(InputEvent.SHIFT_MASK |
|
1363
|
+
InputEvent.CTRL_MASK |
|
1364
|
+
InputEvent.META_MASK |
|
1365
|
+
InputEvent.ALT_MASK);
|
1366
|
+
*/
|
1284
1367
|
|
1285
1368
|
sketch.postEvent(new KeyEvent(event, event.getWhen(),
|
1286
|
-
|
1287
|
-
|
1369
|
+
peAction, modifiers,
|
1370
|
+
event.getKeyChar(), event.getKeyCode()));
|
1288
1371
|
}
|
1289
1372
|
|
1373
|
+
|
1290
1374
|
// listeners, for all my men!
|
1291
1375
|
protected void addListeners() {
|
1292
1376
|
|
@@ -1325,6 +1409,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1325
1409
|
nativeMouseEvent(e);
|
1326
1410
|
}
|
1327
1411
|
|
1412
|
+
@Override
|
1328
1413
|
public void mouseMoved(java.awt.event.MouseEvent e) {
|
1329
1414
|
nativeMouseEvent(e);
|
1330
1415
|
}
|
@@ -1341,11 +1426,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1341
1426
|
nativeKeyEvent(e);
|
1342
1427
|
}
|
1343
1428
|
|
1429
|
+
|
1344
1430
|
@Override
|
1345
1431
|
public void keyReleased(java.awt.event.KeyEvent e) {
|
1346
1432
|
nativeKeyEvent(e);
|
1347
1433
|
}
|
1348
1434
|
|
1435
|
+
|
1349
1436
|
@Override
|
1350
1437
|
public void keyTyped(java.awt.event.KeyEvent e) {
|
1351
1438
|
nativeKeyEvent(e);
|
@@ -1386,7 +1473,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1386
1473
|
comp.removeKeyListener(this);
|
1387
1474
|
comp.removeFocusListener(this);
|
1388
1475
|
}
|
1389
|
-
|
1476
|
+
*/
|
1477
|
+
|
1478
|
+
|
1390
1479
|
// /**
|
1391
1480
|
// * Call to remove, then add, listeners to a component.
|
1392
1481
|
// * Avoids issues with double-adding.
|
@@ -1395,16 +1484,22 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1395
1484
|
// removeListeners(comp);
|
1396
1485
|
// addListeners(comp);
|
1397
1486
|
// }
|
1487
|
+
|
1488
|
+
|
1489
|
+
|
1398
1490
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
1491
|
+
|
1492
|
+
|
1399
1493
|
int cursorType = PConstants.ARROW;
|
1400
1494
|
boolean cursorVisible = true;
|
1401
1495
|
Cursor invisibleCursor;
|
1402
1496
|
|
1497
|
+
|
1403
1498
|
@Override
|
1404
1499
|
public void setCursor(int kind) {
|
1405
1500
|
// Swap the HAND cursor because MOVE doesn't seem to be available on OS X
|
1406
1501
|
// https://github.com/processing/processing/issues/2358
|
1407
|
-
if (PApplet.platform == PConstants.
|
1502
|
+
if (PApplet.platform == PConstants.MACOS && kind == PConstants.MOVE) {
|
1408
1503
|
kind = PConstants.HAND;
|
1409
1504
|
}
|
1410
1505
|
canvas.setCursor(Cursor.getPredefinedCursor(kind));
|
@@ -1412,6 +1507,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1412
1507
|
this.cursorType = kind;
|
1413
1508
|
}
|
1414
1509
|
|
1510
|
+
|
1415
1511
|
@Override
|
1416
1512
|
public void setCursor(PImage img, int x, int y) {
|
1417
1513
|
// Don't set cursorType, instead use cursorType to save the last
|
@@ -1424,14 +1520,15 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1424
1520
|
return;
|
1425
1521
|
}
|
1426
1522
|
|
1427
|
-
Cursor cursor
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1523
|
+
Cursor cursor =
|
1524
|
+
canvas.getToolkit().createCustomCursor((Image) img.getNative(),
|
1525
|
+
new Point(x, y),
|
1526
|
+
"custom");
|
1431
1527
|
canvas.setCursor(cursor);
|
1432
1528
|
cursorVisible = true;
|
1433
1529
|
}
|
1434
1530
|
|
1531
|
+
|
1435
1532
|
@Override
|
1436
1533
|
public void showCursor() {
|
1437
1534
|
// Maybe should always set here? Seems dangerous, since it's likely that
|
@@ -1443,27 +1540,29 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1443
1540
|
}
|
1444
1541
|
}
|
1445
1542
|
|
1543
|
+
|
1446
1544
|
@Override
|
1447
1545
|
public void hideCursor() {
|
1448
1546
|
// Because the OS may have shown the cursor on its own,
|
1449
1547
|
// don't return if 'cursorVisible' is set to true. [rev 0216]
|
1450
1548
|
|
1451
1549
|
if (invisibleCursor == null) {
|
1452
|
-
BufferedImage cursorImg
|
1453
|
-
|
1550
|
+
BufferedImage cursorImg =
|
1551
|
+
new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
1454
1552
|
// this is a temporary workaround for the CHIP, will be removed
|
1455
1553
|
Dimension cursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(16, 16);
|
1456
1554
|
if (cursorSize.width == 0 || cursorSize.height == 0) {
|
1457
1555
|
invisibleCursor = Cursor.getDefaultCursor();
|
1458
1556
|
} else {
|
1459
|
-
invisibleCursor
|
1460
|
-
|
1557
|
+
invisibleCursor =
|
1558
|
+
canvas.getToolkit().createCustomCursor(cursorImg, new Point(8, 8), "blank");
|
1461
1559
|
}
|
1462
1560
|
}
|
1463
1561
|
canvas.setCursor(invisibleCursor);
|
1464
1562
|
cursorVisible = false;
|
1465
1563
|
}
|
1466
1564
|
|
1565
|
+
|
1467
1566
|
@Override
|
1468
1567
|
public Thread createThread() {
|
1469
1568
|
return new AnimationThread() {
|
@@ -1475,7 +1574,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1475
1574
|
};
|
1476
1575
|
}
|
1477
1576
|
|
1478
|
-
|
1577
|
+
|
1578
|
+
void debug(String format, Object ... args) {
|
1479
1579
|
System.out.format(format + "%n", args);
|
1480
1580
|
}
|
1481
1581
|
}
|