picrate 0.7.0-java → 0.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/.gitignore +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
- data/.mvn/wrapper/maven-wrapper.properties +2 -1
- data/.travis.yml +2 -5
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/Rakefile +15 -27
- data/docs/_config.yml +1 -1
- data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -1
- data/docs/_posts/2018-11-18-building-gem.md +1 -1
- data/lib/picrate/app.rb +1 -1
- data/lib/picrate/native_folder.rb +1 -1
- data/lib/picrate/version.rb +1 -1
- data/mvnw +127 -51
- data/mvnw.cmd +182 -0
- data/pom.rb +39 -30
- data/pom.xml +50 -37
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/core/LibraryProxy.java +0 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +1 -1
- data/src/main/java/monkstone/vecmath/GfxRender.java +87 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +48 -50
- data/src/main/java/processing/awt/PShapeJava2D.java +10 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +315 -371
- data/src/main/java/processing/core/PApplet.java +15424 -15495
- data/src/main/java/processing/core/PConstants.java +4 -4
- data/src/main/java/processing/core/PFont.java +394 -369
- data/src/main/java/processing/core/PGraphics.java +11 -10
- data/src/main/java/processing/core/PImage.java +1389 -1435
- data/src/main/java/processing/core/PMatrix2D.java +297 -294
- data/src/main/java/processing/core/PMatrix3D.java +641 -594
- data/src/main/java/processing/core/PShape.java +1755 -1784
- data/src/main/java/processing/core/PShapeOBJ.java +145 -133
- data/src/main/java/processing/core/PShapeSVG.java +808 -801
- data/src/main/java/processing/core/PStyle.java +141 -149
- data/src/main/java/processing/core/PSurface.java +111 -117
- data/src/main/java/processing/core/PSurfaceNone.java +178 -187
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +349 -346
- data/src/main/java/processing/opengl/FontTexture.java +40 -59
- data/src/main/java/processing/opengl/FrameBuffer.java +28 -18
- data/src/main/java/processing/opengl/LinePath.java +7 -7
- data/src/main/java/processing/opengl/LineStroker.java +6 -10
- data/src/main/java/processing/opengl/PGL.java +56 -44
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +909 -2338
- data/src/main/java/processing/opengl/PJOGL.java +1722 -1763
- data/src/main/java/processing/opengl/PShader.java +1308 -1192
- data/src/main/java/processing/opengl/PShapeOpenGL.java +487 -1811
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +482 -497
- data/src/main/java/processing/opengl/Texture.java +99 -76
- data/src/main/java/processing/opengl/VertexBuffer.java +41 -43
- data/vendors/Rakefile +1 -1
- metadata +7 -4
@@ -407,7 +407,7 @@ public class Vec2 extends RubyObject {
|
|
407
407
|
@JRubyMethod(name = "set_mag")
|
408
408
|
|
409
409
|
public IRubyObject set_mag(ThreadContext context, IRubyObject scalar, Block block) {
|
410
|
-
double new_mag =
|
410
|
+
double new_mag = scalar.toJava(Double.class);
|
411
411
|
if (block.isGiven()) {
|
412
412
|
if (!(boolean) block.yield(context, scalar).toJava(Boolean.class)) {
|
413
413
|
return this;
|
@@ -1030,12 +1030,9 @@ public class PGraphicsJava2D extends PGraphics {
|
|
1030
1030
|
/**
|
1031
1031
|
* ( begin auto-generated from blendMode.xml )
|
1032
1032
|
*
|
1033
|
-
* This is a new reference entry for Processing 2.0.
|
1034
|
-
*
|
1035
|
-
* ( end auto-generated )
|
1033
|
+
* This is a new reference entry for Processing 2.0.It will be updated shortly. ( end auto-generated )
|
1036
1034
|
*
|
1037
1035
|
* @webref Rendering
|
1038
|
-
* @param mode the blending mode to use
|
1039
1036
|
*/
|
1040
1037
|
@Override
|
1041
1038
|
protected void blendModeImpl() {
|
@@ -1043,15 +1040,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
1043
1040
|
g2.setComposite(defaultComposite);
|
1044
1041
|
|
1045
1042
|
} else {
|
1046
|
-
g2.setComposite(new
|
1047
|
-
|
1048
|
-
@Override
|
1049
|
-
public CompositeContext createContext(ColorModel srcColorModel,
|
1050
|
-
ColorModel dstColorModel,
|
1051
|
-
RenderingHints hints) {
|
1052
|
-
return new BlendingContext(blendMode);
|
1053
|
-
}
|
1054
|
-
});
|
1043
|
+
g2.setComposite((ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints1) -> new BlendingContext(blendMode));
|
1055
1044
|
}
|
1056
1045
|
}
|
1057
1046
|
|
@@ -1060,14 +1049,16 @@ public class PGraphicsJava2D extends PGraphics {
|
|
1060
1049
|
// demo and terrific writeup on blending modes in Java 2D.
|
1061
1050
|
// http://www.curious-creature.org/2006/09/20/new-blendings-modes-for-java2d/
|
1062
1051
|
private static final class BlendingContext implements CompositeContext {
|
1063
|
-
private int mode;
|
1052
|
+
private final int mode;
|
1064
1053
|
|
1065
1054
|
private BlendingContext(int mode) {
|
1066
1055
|
this.mode = mode;
|
1067
1056
|
}
|
1068
1057
|
|
1058
|
+
@Override
|
1069
1059
|
public void dispose() { }
|
1070
1060
|
|
1061
|
+
@Override
|
1071
1062
|
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
|
1072
1063
|
// not sure if this is really necessary, since we control our buffers
|
1073
1064
|
if (src.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
|
@@ -1336,17 +1327,21 @@ public class PGraphicsJava2D extends PGraphics {
|
|
1336
1327
|
int fillMode = Arc2D.PIE;
|
1337
1328
|
int strokeMode = Arc2D.OPEN;
|
1338
1329
|
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1330
|
+
switch (mode) {
|
1331
|
+
case OPEN:
|
1332
|
+
fillMode = Arc2D.OPEN;
|
1333
|
+
//strokeMode = Arc2D.OPEN;
|
1334
|
+
break;
|
1335
|
+
case PIE:
|
1336
|
+
//fillMode = Arc2D.PIE;
|
1337
|
+
strokeMode = Arc2D.PIE;
|
1338
|
+
break;
|
1339
|
+
case CHORD:
|
1340
|
+
fillMode = Arc2D.CHORD;
|
1341
|
+
strokeMode = Arc2D.CHORD;
|
1342
|
+
break;
|
1343
|
+
default:
|
1344
|
+
break;
|
1350
1345
|
}
|
1351
1346
|
|
1352
1347
|
if (fill) {
|
@@ -1792,38 +1787,41 @@ public class PGraphicsJava2D extends PGraphics {
|
|
1792
1787
|
} else {
|
1793
1788
|
int index = 0;
|
1794
1789
|
for (int y = 0; y < source.pixelHeight; y++) {
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
int
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1790
|
+
switch (source.format) {
|
1791
|
+
case RGB:
|
1792
|
+
int alpha = tintColor & 0xFF000000;
|
1793
|
+
for (int x = 0; x < source.pixelWidth; x++) {
|
1794
|
+
int argb1 = source.pixels[index++];
|
1795
|
+
int r1 = (argb1 >> 16) & 0xff;
|
1796
|
+
int g1 = (argb1 >> 8) & 0xff;
|
1797
|
+
int b1 = (argb1) & 0xff;
|
1798
|
+
tintedTemp[x] = alpha |
|
1803
1799
|
(((r2 * r1) & 0xff00) << 8) |
|
1804
1800
|
((g2 * g1) & 0xff00) |
|
1805
1801
|
(((b2 * b1) & 0xff00) >> 8);
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1802
|
+
} break;
|
1803
|
+
case ARGB:
|
1804
|
+
for (int x = 0; x < source.pixelWidth; x++) {
|
1805
|
+
int argb1 = source.pixels[index++];
|
1806
|
+
int a1 = (argb1 >> 24) & 0xff;
|
1807
|
+
int r1 = (argb1 >> 16) & 0xff;
|
1808
|
+
int g1 = (argb1 >> 8) & 0xff;
|
1809
|
+
int b1 = (argb1) & 0xff;
|
1810
|
+
tintedTemp[x] =
|
1815
1811
|
(((a2 * a1) & 0xff00) << 16) |
|
1816
1812
|
(((r2 * r1) & 0xff00) << 8) |
|
1817
1813
|
((g2 * g1) & 0xff00) |
|
1818
1814
|
(((b2 * b1) & 0xff00) >> 8);
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1815
|
+
} break;
|
1816
|
+
case ALPHA:
|
1817
|
+
int lower = tintColor & 0xFFFFFF;
|
1818
|
+
for (int x = 0; x < source.pixelWidth; x++) {
|
1819
|
+
int a1 = source.pixels[index++];
|
1820
|
+
tintedTemp[x] =
|
1825
1821
|
(((a2 * a1) & 0xff00) << 16) | lower;
|
1826
|
-
|
1822
|
+
} break;
|
1823
|
+
default:
|
1824
|
+
break;
|
1827
1825
|
}
|
1828
1826
|
wr.setDataElements(0, y, source.pixelWidth, 1, tintedTemp);
|
1829
1827
|
}
|
@@ -1960,7 +1958,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
1960
1958
|
|
1961
1959
|
/**
|
1962
1960
|
* Same as parent, but override for native version of the font.
|
1963
|
-
*
|
1961
|
+
*
|
1964
1962
|
* Called from textFontImpl and textSizeImpl, so the metrics
|
1965
1963
|
* will get recorded properly.
|
1966
1964
|
*/
|
@@ -131,6 +131,7 @@ public class PShapeJava2D extends PShapeSVG {
|
|
131
131
|
this.opacity = opacity;
|
132
132
|
}
|
133
133
|
|
134
|
+
@Override
|
134
135
|
public PaintContext createContext(ColorModel cm,
|
135
136
|
Rectangle deviceBounds, Rectangle2D userBounds,
|
136
137
|
AffineTransform xform, RenderingHints hints) {
|
@@ -140,6 +141,7 @@ public class PShapeJava2D extends PShapeSVG {
|
|
140
141
|
(float) t2.getX(), (float) t2.getY());
|
141
142
|
}
|
142
143
|
|
144
|
+
@Override
|
143
145
|
public int getTransparency() {
|
144
146
|
return TRANSLUCENT; // why not.. rather than checking each color
|
145
147
|
}
|
@@ -155,10 +157,13 @@ public class PShapeJava2D extends PShapeSVG {
|
|
155
157
|
this.ty2 = ty2;
|
156
158
|
}
|
157
159
|
|
160
|
+
@Override
|
158
161
|
public void dispose() { }
|
159
162
|
|
163
|
+
@Override
|
160
164
|
public ColorModel getColorModel() { return ColorModel.getRGBdefault(); }
|
161
165
|
|
166
|
+
@Override
|
162
167
|
public Raster getRaster(int x, int y, int w, int h) {
|
163
168
|
WritableRaster raster =
|
164
169
|
getColorModel().createCompatibleWritableRaster(w, h);
|
@@ -255,12 +260,14 @@ public class PShapeJava2D extends PShapeSVG {
|
|
255
260
|
this.opacity = opacity;
|
256
261
|
}
|
257
262
|
|
263
|
+
@Override
|
258
264
|
public PaintContext createContext(ColorModel cm,
|
259
265
|
Rectangle deviceBounds, Rectangle2D userBounds,
|
260
266
|
AffineTransform xform, RenderingHints hints) {
|
261
267
|
return new RadialGradientContext();
|
262
268
|
}
|
263
269
|
|
270
|
+
@Override
|
264
271
|
public int getTransparency() {
|
265
272
|
return TRANSLUCENT;
|
266
273
|
}
|
@@ -268,10 +275,13 @@ public class PShapeJava2D extends PShapeSVG {
|
|
268
275
|
public class RadialGradientContext implements PaintContext {
|
269
276
|
int ACCURACY = 5;
|
270
277
|
|
278
|
+
@Override
|
271
279
|
public void dispose() {}
|
272
280
|
|
281
|
+
@Override
|
273
282
|
public ColorModel getColorModel() { return ColorModel.getRGBdefault(); }
|
274
283
|
|
284
|
+
@Override
|
275
285
|
public Raster getRaster(int x, int y, int w, int h) {
|
276
286
|
WritableRaster raster =
|
277
287
|
getColorModel().createCompatibleWritableRaster(w, h);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
2
|
|
3
|
-
/*
|
3
|
+
/*
|
4
4
|
Part of the Processing project - http://processing.org
|
5
5
|
|
6
6
|
Copyright (c) 2014-15 The Processing Foundation
|
@@ -18,8 +18,7 @@
|
|
18
18
|
Public License along with this library; if not, write to the
|
19
19
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
20
|
Boston, MA 02111-1307 USA
|
21
|
-
*/
|
22
|
-
|
21
|
+
*/
|
23
22
|
package processing.awt;
|
24
23
|
|
25
24
|
import java.awt.Canvas;
|
@@ -42,7 +41,6 @@ import java.awt.event.*;
|
|
42
41
|
import java.awt.geom.Rectangle2D;
|
43
42
|
import java.awt.image.*;
|
44
43
|
import java.lang.management.ManagementFactory;
|
45
|
-
import java.lang.reflect.Method;
|
46
44
|
import java.net.URL;
|
47
45
|
import java.util.ArrayList;
|
48
46
|
import java.util.List;
|
@@ -62,11 +60,11 @@ import processing.event.MouseEvent;
|
|
62
60
|
* @author Martin Prout
|
63
61
|
*/
|
64
62
|
public class PSurfaceAWT extends PSurfaceNone {
|
63
|
+
|
65
64
|
GraphicsDevice displayDevice;
|
66
65
|
|
67
66
|
// used for canvas to determine whether resizable or not
|
68
67
|
// boolean resizable; // default is false
|
69
|
-
|
70
68
|
// Internally, we know it's always a JFrame (not just a Frame)
|
71
69
|
// JFrame frame;
|
72
70
|
// Trying Frame again with a11 to see if this avoids some Swing nastiness.
|
@@ -84,22 +82,20 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
84
82
|
|
85
83
|
// 3.0a5 didn't use strategy, and active was shut off during init() w/ retina
|
86
84
|
// boolean useStrategy = true;
|
87
|
-
|
88
85
|
Canvas canvas;
|
89
86
|
// Component canvas;
|
90
87
|
|
91
88
|
// PGraphics graphics; // moved to PSurfaceNone
|
92
|
-
|
93
89
|
int sketchWidth;
|
94
90
|
int sketchHeight;
|
95
91
|
|
96
92
|
int windowScaleFactor;
|
97
93
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
94
|
+
/**
|
95
|
+
*
|
96
|
+
* @param graphics
|
97
|
+
*/
|
98
|
+
public PSurfaceAWT(PGraphics graphics) {
|
103
99
|
//this.graphics = graphics;
|
104
100
|
super(graphics);
|
105
101
|
|
@@ -124,7 +120,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
124
120
|
// flicker--pushing pixels out before the screen has finished rendering.
|
125
121
|
// useStrategy = false;
|
126
122
|
}
|
127
|
-
|
123
|
+
*/
|
128
124
|
canvas = new SmoothCanvas();
|
129
125
|
// if (useStrategy) {
|
130
126
|
//canvas.setIgnoreRepaint(true);
|
@@ -140,8 +136,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
140
136
|
// make sure this is a real resize event, not just initial setup
|
141
137
|
// https://github.com/processing/processing/issues/3310
|
142
138
|
Dimension canvasSize = canvas.getSize();
|
143
|
-
if (canvasSize.width != sketch.sketchWidth()
|
144
|
-
|
139
|
+
if (canvasSize.width != sketch.sketchWidth()
|
140
|
+
|| canvasSize.height != sketch.sketchHeight()) {
|
145
141
|
sketch.redraw();
|
146
142
|
}
|
147
143
|
}
|
@@ -150,7 +146,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
150
146
|
addListeners();
|
151
147
|
}
|
152
148
|
|
153
|
-
|
154
149
|
// /**
|
155
150
|
// * Handle grabbing the focus on startup. Other renderers can override this
|
156
151
|
// * if handling needs to be different. For the AWT, the request is invoked
|
@@ -185,62 +180,56 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
185
180
|
// }
|
186
181
|
// });
|
187
182
|
// }
|
188
|
-
|
189
|
-
|
190
183
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
*/
|
195
|
-
|
196
|
-
|
184
|
+
/**
|
185
|
+
*
|
186
|
+
*/
|
197
187
|
public class SmoothCanvas extends Canvas {
|
188
|
+
|
198
189
|
private Dimension oldSize = new Dimension(0, 0);
|
199
190
|
private Dimension newSize = new Dimension(0, 0);
|
200
191
|
|
201
|
-
|
202
192
|
// Turns out getParent() returns a JPanel on a JFrame. Yech.
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
*/
|
193
|
+
/**
|
194
|
+
*
|
195
|
+
* @return
|
196
|
+
*/
|
208
197
|
public Frame getFrame() {
|
209
198
|
return frame;
|
210
199
|
}
|
211
200
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
201
|
+
/**
|
202
|
+
*
|
203
|
+
* @return
|
204
|
+
*/
|
205
|
+
@Override
|
217
206
|
public Dimension getPreferredSize() {
|
218
207
|
return new Dimension(sketchWidth, sketchHeight);
|
219
208
|
}
|
220
209
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
210
|
+
/**
|
211
|
+
*
|
212
|
+
* @return
|
213
|
+
*/
|
214
|
+
@Override
|
226
215
|
public Dimension getMinimumSize() {
|
227
216
|
return getPreferredSize();
|
228
217
|
}
|
229
218
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
219
|
+
/**
|
220
|
+
*
|
221
|
+
* @return
|
222
|
+
*/
|
223
|
+
@Override
|
235
224
|
public Dimension getMaximumSize() {
|
236
225
|
//return resizable ? super.getMaximumSize() : getPreferredSize();
|
237
226
|
return frame.isResizable() ? super.getMaximumSize() : getPreferredSize();
|
238
227
|
}
|
239
228
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
229
|
+
/**
|
230
|
+
*
|
231
|
+
*/
|
232
|
+
@Override
|
244
233
|
public void validate() {
|
245
234
|
super.validate();
|
246
235
|
newSize.width = getWidth();
|
@@ -261,21 +250,21 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
261
250
|
}
|
262
251
|
}
|
263
252
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
253
|
+
/**
|
254
|
+
*
|
255
|
+
* @param g
|
256
|
+
*/
|
257
|
+
@Override
|
269
258
|
public void update(Graphics g) {
|
270
259
|
// System.out.println("updating");
|
271
260
|
paint(g);
|
272
261
|
}
|
273
262
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
263
|
+
/**
|
264
|
+
*
|
265
|
+
* @param screen
|
266
|
+
*/
|
267
|
+
@Override
|
279
268
|
public void paint(Graphics screen) {
|
280
269
|
// System.out.println("painting");
|
281
270
|
// if (useStrategy) {
|
@@ -285,7 +274,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
285
274
|
System.out.println("drawing to screen " + canvas);
|
286
275
|
screen.drawImage(graphics.image, 0, 0, sketchWidth, sketchHeight, null);
|
287
276
|
}
|
288
|
-
|
277
|
+
*/
|
289
278
|
|
290
279
|
// } else {
|
291
280
|
//// new Exception("painting").printStackTrace(System.out);
|
@@ -302,7 +291,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
302
291
|
}
|
303
292
|
}
|
304
293
|
|
305
|
-
|
294
|
+
/*
|
306
295
|
@Override
|
307
296
|
public void addNotify() {
|
308
297
|
// System.out.println("adding notify");
|
@@ -310,14 +299,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
310
299
|
// prior to Java 7 on OS X, this no longer works [121222]
|
311
300
|
// createBufferStrategy(2);
|
312
301
|
}
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
graphics.image != null) {
|
302
|
+
*/
|
303
|
+
/**
|
304
|
+
*
|
305
|
+
*/
|
306
|
+
synchronized protected void render() {
|
307
|
+
if (canvas.isDisplayable()
|
308
|
+
&& graphics.image != null) {
|
321
309
|
if (canvas.getBufferStrategy() == null) {
|
322
310
|
canvas.createBufferStrategy(2);
|
323
311
|
}
|
@@ -387,15 +375,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
387
375
|
}
|
388
376
|
}
|
389
377
|
}
|
390
|
-
|
391
|
-
|
392
|
-
|
378
|
+
*/
|
393
379
|
// what needs to happen here?
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
*/
|
380
|
+
/**
|
381
|
+
*
|
382
|
+
* @param sketch
|
383
|
+
*/
|
399
384
|
@Override
|
400
385
|
public void initOffscreen(PApplet sketch) {
|
401
386
|
this.sketch = sketch;
|
@@ -408,9 +393,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
408
393
|
// but don't show it
|
409
394
|
return dummy;
|
410
395
|
}
|
411
|
-
|
396
|
+
*/
|
412
397
|
|
413
|
-
|
398
|
+
/*
|
414
399
|
@Override
|
415
400
|
public Component initComponent(PApplet sketch) {
|
416
401
|
this.sketch = sketch;
|
@@ -421,19 +406,18 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
421
406
|
|
422
407
|
return canvas;
|
423
408
|
}
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
@Override
|
409
|
+
*/
|
410
|
+
/**
|
411
|
+
*
|
412
|
+
* @param sketch
|
413
|
+
*/
|
414
|
+
@Override
|
431
415
|
public void initFrame(final PApplet sketch) {/*, int backgroundColor,
|
432
416
|
int deviceIndex, boolean fullScreen, boolean spanDisplays) {*/
|
433
417
|
this.sketch = sketch;
|
434
418
|
|
435
|
-
GraphicsEnvironment environment
|
436
|
-
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
419
|
+
GraphicsEnvironment environment
|
420
|
+
= GraphicsEnvironment.getLocalGraphicsEnvironment();
|
437
421
|
|
438
422
|
int displayNum = sketch.sketchDisplay();
|
439
423
|
// System.out.println("display from sketch is " + displayNum);
|
@@ -442,10 +426,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
442
426
|
if (displayNum <= devices.length) {
|
443
427
|
displayDevice = devices[displayNum - 1];
|
444
428
|
} else {
|
445
|
-
System.err.format("Display %d does not exist, "
|
446
|
-
"using the default display instead.%n", displayNum);
|
429
|
+
System.err.format("Display %d does not exist, "
|
430
|
+
+ "using the default display instead.%n", displayNum);
|
447
431
|
for (int i = 0; i < devices.length; i++) {
|
448
|
-
System.err.format("Display %d is %s%n", (i+1), devices[i]);
|
432
|
+
System.err.format("Display %d is %s%n", (i + 1), devices[i]);
|
449
433
|
}
|
450
434
|
}
|
451
435
|
}
|
@@ -457,8 +441,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
457
441
|
// because pack() will cause the bounds to go to zero.
|
458
442
|
// http://dev.processing.org/bugs/show_bug.cgi?id=923
|
459
443
|
boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN;
|
460
|
-
screenRect = spanDisplays ? getDisplaySpan()
|
461
|
-
displayDevice.getDefaultConfiguration().getBounds();
|
444
|
+
screenRect = spanDisplays ? getDisplaySpan()
|
445
|
+
: displayDevice.getDefaultConfiguration().getBounds();
|
462
446
|
// DisplayMode doesn't work here, because we can't get the upper-left
|
463
447
|
// corner of the display, which is important for multi-display setups.
|
464
448
|
|
@@ -467,8 +451,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
467
451
|
sketch.displayWidth = screenRect.width;
|
468
452
|
sketch.displayHeight = screenRect.height;
|
469
453
|
|
470
|
-
windowScaleFactor = PApplet.platform == PConstants.MACOSX
|
471
|
-
|
454
|
+
windowScaleFactor = PApplet.platform == PConstants.MACOSX
|
455
|
+
? 1 : sketch.pixelDensity;
|
472
456
|
|
473
457
|
sketchWidth = sketch.sketchWidth() * windowScaleFactor;
|
474
458
|
sketchHeight = sketch.sketchHeight() * windowScaleFactor;
|
@@ -486,7 +470,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
486
470
|
fullScreen = true;
|
487
471
|
sketch.fullScreen(); // won't change the renderer
|
488
472
|
}
|
489
|
-
|
473
|
+
*/
|
490
474
|
|
491
475
|
if (fullScreen || spanDisplays) {
|
492
476
|
sketchWidth = screenRect.width;
|
@@ -526,7 +510,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
526
510
|
// and launches the Thread that will kick off setup().
|
527
511
|
// http://dev.processing.org/bugs/show_bug.cgi?id=891
|
528
512
|
// http://dev.processing.org/bugs/show_bug.cgi?id=908
|
529
|
-
|
530
513
|
frame.add(canvas);
|
531
514
|
setSize(sketchWidth / windowScaleFactor, sketchHeight / windowScaleFactor);
|
532
515
|
|
@@ -553,7 +536,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
553
536
|
// will be set visible in placeWindow() [3.0a10]
|
554
537
|
//frame.setVisible(true); // re-add native resources
|
555
538
|
}
|
556
|
-
|
539
|
+
*/
|
557
540
|
frame.setLayout(null);
|
558
541
|
//frame.add(applet);
|
559
542
|
|
@@ -562,9 +545,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
562
545
|
// spanScreens was in use.
|
563
546
|
// pg = sketch.makePrimaryGraphics(sketchWidth, sketchHeight);
|
564
547
|
// pg = sketch.makePrimaryGraphics();
|
565
|
-
|
566
548
|
// resize sketch to sketchWidth/sketchHeight here
|
567
|
-
|
568
549
|
if (fullScreen) {
|
569
550
|
frame.invalidate();
|
570
551
|
} else {
|
@@ -573,7 +554,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
573
554
|
|
574
555
|
// insufficient, places the 100x100 sketches offset strangely
|
575
556
|
//frame.validate();
|
576
|
-
|
577
557
|
// disabling resize has to happen after pack() to avoid apparent Apple bug
|
578
558
|
// http://code.google.com/p/processing/issues/detail?id=467
|
579
559
|
frame.setResizable(false);
|
@@ -588,36 +568,37 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
588
568
|
// sketch.setFrame(frame);
|
589
569
|
}
|
590
570
|
|
591
|
-
|
592
571
|
@Override
|
593
572
|
public Object getNative() {
|
594
573
|
return canvas;
|
595
574
|
}
|
596
575
|
|
597
|
-
|
598
576
|
// public Toolkit getToolkit() {
|
599
577
|
// return canvas.getToolkit();
|
600
578
|
// }
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
579
|
+
/**
|
580
|
+
* Set the window (and dock, or whatever necessary) title.
|
581
|
+
*
|
582
|
+
* @param title
|
583
|
+
*/
|
605
584
|
@Override
|
606
585
|
public void setTitle(String title) {
|
607
586
|
frame.setTitle(title);
|
608
587
|
// Workaround for apparent Java bug on OS X?
|
609
588
|
// https://github.com/processing/processing/issues/3472
|
610
|
-
if (cursorVisible
|
611
|
-
|
612
|
-
|
589
|
+
if (cursorVisible
|
590
|
+
&& (PApplet.platform == PConstants.MACOSX)
|
591
|
+
&& (cursorType != PConstants.ARROW)) {
|
613
592
|
hideCursor();
|
614
593
|
showCursor();
|
615
594
|
}
|
616
595
|
}
|
617
596
|
|
618
|
-
|
619
|
-
|
620
|
-
|
597
|
+
/**
|
598
|
+
* Set true if we want to resize things (default is not resizable)
|
599
|
+
*
|
600
|
+
* @param resizable
|
601
|
+
*/
|
621
602
|
@Override
|
622
603
|
public void setResizable(boolean resizable) {
|
623
604
|
//this.resizable = resizable; // really only used for canvas
|
@@ -627,11 +608,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
627
608
|
}
|
628
609
|
}
|
629
610
|
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
611
|
+
/**
|
612
|
+
*
|
613
|
+
* @param image
|
614
|
+
*/
|
615
|
+
@Override
|
635
616
|
public void setIcon(PImage image) {
|
636
617
|
Image awtImage = (Image) image.getNative();
|
637
618
|
frame.setIconImage(awtImage);
|
@@ -652,51 +633,50 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
652
633
|
// }
|
653
634
|
}
|
654
635
|
|
655
|
-
|
656
636
|
@Override
|
657
637
|
public void setAlwaysOnTop(boolean always) {
|
658
638
|
frame.setAlwaysOnTop(always);
|
659
639
|
}
|
660
640
|
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
641
|
+
/**
|
642
|
+
*
|
643
|
+
* @param x
|
644
|
+
* @param y
|
645
|
+
*/
|
646
|
+
@Override
|
667
647
|
public void setLocation(int x, int y) {
|
668
648
|
frame.setLocation(x, y);
|
669
649
|
}
|
670
650
|
|
671
|
-
|
672
651
|
List<Image> iconImages;
|
673
652
|
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
653
|
+
/**
|
654
|
+
*
|
655
|
+
* @param frame
|
656
|
+
*/
|
657
|
+
protected void setProcessingIcon(Frame frame) {
|
679
658
|
// On OS X, this only affects what shows up in the dock when minimized.
|
680
659
|
// So replacing it is actually a step backwards. Brilliant.
|
681
660
|
// if (PApplet.platform != PConstants.MACOSX) {
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
}
|
661
|
+
//Image image = Toolkit.getDefaultToolkit().createImage(ICON_IMAGE);
|
662
|
+
//frame.setIconImage(image);
|
663
|
+
try {
|
664
|
+
if (iconImages == null) {
|
665
|
+
iconImages = new ArrayList<>();
|
666
|
+
final int[] sizes = {16, 32, 48, 64, 128, 256, 512};
|
667
|
+
|
668
|
+
for (int sz : sizes) {
|
669
|
+
//URL url = getClass().getResource("/icon/icon-" + sz + ".png");
|
670
|
+
URL url = PApplet.class.getResource("/icon/icon-" + sz + ".png");
|
671
|
+
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
672
|
+
iconImages.add(image);
|
673
|
+
//iconImages.add(Toolkit.getLibImage("icons/pde-" + sz + ".png", frame));
|
696
674
|
}
|
697
|
-
|
675
|
+
}
|
676
|
+
frame.setIconImages(iconImages);
|
698
677
|
|
699
|
-
|
678
|
+
} catch (Exception e) {
|
679
|
+
} // harmless; keep this to ourselves
|
700
680
|
|
701
681
|
// } else { // handle OS X differently
|
702
682
|
// if (!dockIconSpecified()) { // don't override existing -Xdock param
|
@@ -719,15 +699,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
719
699
|
// }
|
720
700
|
}
|
721
701
|
|
722
|
-
|
723
702
|
/**
|
724
703
|
* @return true if -Xdock:icon was specified on the command line
|
725
704
|
*/
|
726
705
|
private boolean dockIconSpecified() {
|
727
706
|
// TODO This is incomplete... Haven't yet found a way to figure out if
|
728
707
|
// the app has an icns file specified already. Help?
|
729
|
-
List<String> jvmArgs
|
730
|
-
ManagementFactory.getRuntimeMXBean().getInputArguments();
|
708
|
+
List<String> jvmArgs
|
709
|
+
= ManagementFactory.getRuntimeMXBean().getInputArguments();
|
731
710
|
for (String arg : jvmArgs) {
|
732
711
|
if (arg.startsWith("-Xdock:icon")) {
|
733
712
|
return true; // dock image already set
|
@@ -736,7 +715,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
736
715
|
return false;
|
737
716
|
}
|
738
717
|
|
739
|
-
|
740
718
|
@Override
|
741
719
|
public void setVisible(boolean visible) {
|
742
720
|
frame.setVisible(visible);
|
@@ -762,16 +740,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
762
740
|
insets.top + insets.bottom);
|
763
741
|
}
|
764
742
|
}
|
765
|
-
*/
|
743
|
+
*/
|
766
744
|
}
|
767
745
|
|
768
|
-
|
769
746
|
//public void placeFullScreen(boolean hideStop) {
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
*/
|
747
|
+
/**
|
748
|
+
*
|
749
|
+
* @param stopColor
|
750
|
+
*/
|
775
751
|
@Override
|
776
752
|
public void placePresent(int stopColor) {
|
777
753
|
setFullFrame();
|
@@ -779,14 +755,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
779
755
|
// After the pack(), the screen bounds are gonna be 0s
|
780
756
|
// frame.setBounds(screenRect); // already called in setFullFrame()
|
781
757
|
canvas.setBounds((screenRect.width - sketchWidth) / 2,
|
782
|
-
|
783
|
-
|
758
|
+
(screenRect.height - sketchHeight) / 2,
|
759
|
+
sketchWidth, sketchHeight);
|
784
760
|
|
785
761
|
// if (PApplet.platform == PConstants.MACOSX) {
|
786
762
|
// macosxFullScreenEnable(frame);
|
787
763
|
// macosxFullScreenToggle(frame);
|
788
764
|
// }
|
789
|
-
|
790
765
|
if (stopColor != 0) {
|
791
766
|
Label label = new Label("stop");
|
792
767
|
label.setForeground(new Color(stopColor, false));
|
@@ -856,22 +831,21 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
856
831
|
frame.setVisible(true);
|
857
832
|
}
|
858
833
|
}
|
859
|
-
|
860
|
-
|
861
|
-
|
834
|
+
*/
|
862
835
|
private void setCanvasSize() {
|
863
836
|
// System.out.format("setting canvas size %d %d%n", sketchWidth, sketchHeight);
|
864
837
|
// new Exception().printStackTrace(System.out);
|
865
838
|
int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH);
|
866
839
|
int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT);
|
867
840
|
|
868
|
-
canvas.setBounds((contentW - sketchWidth)/2,
|
869
|
-
|
870
|
-
|
841
|
+
canvas.setBounds((contentW - sketchWidth) / 2,
|
842
|
+
(contentH - sketchHeight) / 2,
|
843
|
+
sketchWidth, sketchHeight);
|
871
844
|
}
|
872
845
|
|
873
|
-
|
874
|
-
|
846
|
+
/**
|
847
|
+
* Resize frame for these sketch (canvas) dimensions.
|
848
|
+
*/
|
875
849
|
private Dimension setFrameSize() { //int sketchWidth, int sketchHeight) {
|
876
850
|
// https://github.com/processing/processing/pull/3162
|
877
851
|
frame.addNotify(); // using instead of show() to add the peer [fry]
|
@@ -879,24 +853,24 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
879
853
|
// System.out.format("setting frame size %d %d %n", sketchWidth, sketchHeight);
|
880
854
|
// new Exception().printStackTrace(System.out);
|
881
855
|
currentInsets = frame.getInsets();
|
882
|
-
int windowW = Math.max(sketchWidth, MIN_WINDOW_WIDTH)
|
883
|
-
currentInsets.left + currentInsets.right;
|
884
|
-
int windowH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT)
|
885
|
-
currentInsets.top + currentInsets.bottom;
|
856
|
+
int windowW = Math.max(sketchWidth, MIN_WINDOW_WIDTH)
|
857
|
+
+ currentInsets.left + currentInsets.right;
|
858
|
+
int windowH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT)
|
859
|
+
+ currentInsets.top + currentInsets.bottom;
|
886
860
|
frame.setSize(windowW, windowH);
|
887
861
|
return new Dimension(windowW, windowH);
|
888
862
|
}
|
889
863
|
|
890
|
-
|
891
864
|
private void setFrameCentered() {
|
892
865
|
// Can't use frame.setLocationRelativeTo(null) because it sends the
|
893
866
|
// frame to the main display, which undermines the --display setting.
|
894
867
|
frame.setLocation(screenRect.x + (screenRect.width - sketchWidth) / 2,
|
895
|
-
|
868
|
+
screenRect.y + (screenRect.height - sketchHeight) / 2);
|
896
869
|
}
|
897
870
|
|
898
|
-
|
899
|
-
|
871
|
+
/**
|
872
|
+
* Hide the menu bar, make the Frame undecorated, set it to screenRect.
|
873
|
+
*/
|
900
874
|
private void setFullFrame() {
|
901
875
|
// Called here because the graphics device is needed before we can
|
902
876
|
// determine whether the sketch wants size(displayWidth, displayHeight),
|
@@ -906,7 +880,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
906
880
|
// Tried to use this to fix the 'present' mode issue.
|
907
881
|
// Did not help, and the screenRect setup seems to work fine.
|
908
882
|
//frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
909
|
-
|
910
883
|
// https://github.com/processing/processing/pull/3162
|
911
884
|
//frame.dispose(); // release native resources, allows setUndecorated()
|
912
885
|
frame.removeNotify();
|
@@ -919,12 +892,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
919
892
|
//frame.setVisible(true); // re-add native resources
|
920
893
|
}
|
921
894
|
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
895
|
+
/**
|
896
|
+
*
|
897
|
+
* @param location
|
898
|
+
* @param editorLocation
|
899
|
+
*/
|
900
|
+
@Override
|
928
901
|
public void placeWindow(int[] location, int[] editorLocation) {
|
929
902
|
//Dimension window = setFrameSize(sketchWidth, sketchHeight);
|
930
903
|
Dimension window = setFrameSize(); //sketchWidth, sketchHeight);
|
@@ -967,7 +940,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
967
940
|
locationX = (sketch.displayWidth - window.width) / 2;
|
968
941
|
locationY = (sketch.displayHeight - window.height) / 2;
|
969
942
|
}
|
970
|
-
|
943
|
+
*/
|
971
944
|
frame.setLocation(locationX, locationY);
|
972
945
|
}
|
973
946
|
} else { // just center on screen
|
@@ -981,9 +954,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
981
954
|
}
|
982
955
|
}
|
983
956
|
|
984
|
-
canvas.setBounds((contentW - sketchWidth)/2,
|
985
|
-
|
986
|
-
|
957
|
+
canvas.setBounds((contentW - sketchWidth) / 2,
|
958
|
+
(contentH - sketchHeight) / 2,
|
959
|
+
sketchWidth, sketchHeight);
|
987
960
|
|
988
961
|
// handle frame resizing events
|
989
962
|
setupFrameResizeListener();
|
@@ -999,20 +972,18 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
999
972
|
// canvas.requestFocus();
|
1000
973
|
// }
|
1001
974
|
}
|
1002
|
-
|
975
|
+
*/
|
1003
976
|
// if (sketch.getGraphics().displayable()) {
|
1004
977
|
// setVisible(true);
|
1005
978
|
// }
|
1006
979
|
}
|
1007
980
|
|
1008
|
-
|
1009
981
|
// needs to resize the frame, which will resize the canvas, and so on...
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
*/
|
982
|
+
/**
|
983
|
+
*
|
984
|
+
* @param wide
|
985
|
+
* @param high
|
986
|
+
*/
|
1016
987
|
@Override
|
1017
988
|
public void setSize(int wide, int high) {
|
1018
989
|
// When the surface is set to resizable via surface.setResizable(true),
|
@@ -1029,10 +1000,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1029
1000
|
// //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
|
1030
1001
|
// new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
|
1031
1002
|
// }
|
1032
|
-
|
1033
1003
|
//if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
|
1034
|
-
if (wide == sketch.width && high == sketch.height
|
1035
|
-
|
1004
|
+
if (wide == sketch.width && high == sketch.height
|
1005
|
+
&& (frame == null || currentInsets.equals(frame.getInsets()))) {
|
1036
1006
|
// if (PApplet.DEBUG) {
|
1037
1007
|
// new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
|
1038
1008
|
// }
|
@@ -1053,7 +1023,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1053
1023
|
// }
|
1054
1024
|
|
1055
1025
|
//initImage(graphics, wide, high);
|
1056
|
-
|
1057
1026
|
//throw new RuntimeException("implement me, see readme.md");
|
1058
1027
|
sketch.setSize(wide, high);
|
1059
1028
|
// sketch.width = wide;
|
@@ -1064,7 +1033,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1064
1033
|
// System.out.println("out of setSize()");
|
1065
1034
|
}
|
1066
1035
|
|
1067
|
-
|
1068
1036
|
//public void initImage(PGraphics gr, int wide, int high) {
|
1069
1037
|
/*
|
1070
1038
|
@Override
|
@@ -1083,20 +1051,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1083
1051
|
int high = graphics.height * graphics.pixelFactor;
|
1084
1052
|
graphics.image = gc.createCompatibleImage(wide, high);
|
1085
1053
|
}
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1054
|
+
*/
|
1089
1055
|
// @Override
|
1090
1056
|
// public Component getComponent() {
|
1091
1057
|
// return canvas;
|
1092
1058
|
// }
|
1093
|
-
|
1094
|
-
|
1095
1059
|
// @Override
|
1096
1060
|
// public void setSmooth(int level) {
|
1097
1061
|
// }
|
1098
|
-
|
1099
|
-
|
1100
1062
|
/*
|
1101
1063
|
private boolean checkRetina() {
|
1102
1064
|
if (PApplet.platform == PConstants.MACOSX) {
|
@@ -1123,14 +1085,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1123
1085
|
}
|
1124
1086
|
return false;
|
1125
1087
|
}
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1088
|
+
*/
|
1089
|
+
/**
|
1090
|
+
* Get the bounds rectangle for all displays.
|
1091
|
+
*/
|
1130
1092
|
static Rectangle getDisplaySpan() {
|
1131
1093
|
Rectangle bounds = new Rectangle();
|
1132
|
-
GraphicsEnvironment environment
|
1133
|
-
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
1094
|
+
GraphicsEnvironment environment
|
1095
|
+
= GraphicsEnvironment.getLocalGraphicsEnvironment();
|
1134
1096
|
for (GraphicsDevice device : environment.getScreenDevices()) {
|
1135
1097
|
for (GraphicsConfiguration config : device.getConfigurations()) {
|
1136
1098
|
Rectangle2D.union(bounds, config.getBounds(), bounds);
|
@@ -1154,15 +1116,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1154
1116
|
}
|
1155
1117
|
}
|
1156
1118
|
}
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1119
|
+
*/
|
1160
1120
|
/**
|
1161
1121
|
* Set this sketch to communicate its state back to the PDE.
|
1162
|
-
*
|
1163
|
-
* This uses the stderr stream to write positions of the window
|
1164
|
-
*
|
1165
|
-
*
|
1122
|
+
*
|
1123
|
+
* This uses the stderr stream to write positions of the window (so that it
|
1124
|
+
* will be saved by the PDE for the next run) and notify on quit. See more
|
1125
|
+
* notes in the Worker class.
|
1166
1126
|
*/
|
1167
1127
|
@Override
|
1168
1128
|
public void setupExternalMessages() {
|
@@ -1175,33 +1135,26 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1175
1135
|
});
|
1176
1136
|
}
|
1177
1137
|
|
1178
|
-
|
1179
1138
|
/**
|
1180
|
-
* Set up a listener that will fire proper component resize events
|
1181
|
-
*
|
1139
|
+
* Set up a listener that will fire proper component resize events in cases
|
1140
|
+
* where frame.setResizable(true) is called.
|
1182
1141
|
*/
|
1183
1142
|
private void setupFrameResizeListener() {
|
1184
|
-
frame.addWindowStateListener(
|
1185
|
-
|
1186
|
-
//
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
//
|
1143
|
+
frame.addWindowStateListener((WindowEvent e) -> {
|
1144
|
+
// This seems to be firing when dragging the window on OS X
|
1145
|
+
// https://github.com/processing/processing/issues/3092
|
1146
|
+
if (Frame.MAXIMIZED_BOTH == e.getNewState()) {
|
1147
|
+
// Supposedly, sending the frame to back and then front is a
|
1148
|
+
// workaround for this bug:
|
1149
|
+
// http://stackoverflow.com/a/23897602
|
1150
|
+
// but is not working for me...
|
1151
|
+
//frame.toBack();
|
1152
|
+
//frame.toFront();
|
1153
|
+
// Packing the frame works, but that causes the window to collapse
|
1154
|
+
// on OS X when the window is dragged. Changing to addNotify() for
|
1191
1155
|
// https://github.com/processing/processing/issues/3092
|
1192
|
-
|
1193
|
-
|
1194
|
-
// workaround for this bug:
|
1195
|
-
// http://stackoverflow.com/a/23897602
|
1196
|
-
// but is not working for me...
|
1197
|
-
//frame.toBack();
|
1198
|
-
//frame.toFront();
|
1199
|
-
// Packing the frame works, but that causes the window to collapse
|
1200
|
-
// on OS X when the window is dragged. Changing to addNotify() for
|
1201
|
-
// https://github.com/processing/processing/issues/3092
|
1202
|
-
//frame.pack();
|
1203
|
-
frame.addNotify();
|
1204
|
-
}
|
1156
|
+
//frame.pack();
|
1157
|
+
frame.addNotify();
|
1205
1158
|
}
|
1206
1159
|
});
|
1207
1160
|
|
@@ -1239,7 +1192,6 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1239
1192
|
});
|
1240
1193
|
}
|
1241
1194
|
|
1242
|
-
|
1243
1195
|
// /**
|
1244
1196
|
// * (No longer in use) Use reflection to call
|
1245
1197
|
// * <code>com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(window, true);</code>
|
@@ -1280,11 +1232,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1280
1232
|
// e.printStackTrace();
|
1281
1233
|
// }
|
1282
1234
|
// }
|
1283
|
-
|
1284
|
-
|
1285
1235
|
//////////////////////////////////////////////////////////////
|
1286
|
-
|
1287
|
-
|
1288
1236
|
/*
|
1289
1237
|
// disabling for now; requires Java 1.7 and "precise" semantics are odd...
|
1290
1238
|
// returns 0.1 for tick-by-tick scrolling on OS X, but it's not a matter of
|
@@ -1298,14 +1246,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1298
1246
|
// ignored, the method will just be set to null
|
1299
1247
|
}
|
1300
1248
|
}
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1249
|
+
*/
|
1304
1250
|
/**
|
1305
|
-
* Figure out how to process a mouse event. When loop() has been
|
1306
|
-
*
|
1307
|
-
*
|
1308
|
-
|
1251
|
+
* Figure out how to process a mouse event. When loop() has been called, the
|
1252
|
+
* events will be queued up until drawing is complete. If noLoop() has been
|
1253
|
+
* called, then events will happen immediately.
|
1254
|
+
*
|
1255
|
+
* @param nativeEvent
|
1309
1256
|
*/
|
1310
1257
|
protected void nativeMouseEvent(java.awt.event.MouseEvent nativeEvent) {
|
1311
1258
|
// the 'amount' is the number of button clicks for a click event,
|
@@ -1314,31 +1261,31 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1314
1261
|
|
1315
1262
|
int peAction = 0;
|
1316
1263
|
switch (nativeEvent.getID()) {
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1264
|
+
case java.awt.event.MouseEvent.MOUSE_PRESSED:
|
1265
|
+
peAction = MouseEvent.PRESS;
|
1266
|
+
break;
|
1267
|
+
case java.awt.event.MouseEvent.MOUSE_RELEASED:
|
1268
|
+
peAction = MouseEvent.RELEASE;
|
1269
|
+
break;
|
1270
|
+
case java.awt.event.MouseEvent.MOUSE_CLICKED:
|
1271
|
+
peAction = MouseEvent.CLICK;
|
1272
|
+
break;
|
1273
|
+
case java.awt.event.MouseEvent.MOUSE_DRAGGED:
|
1274
|
+
peAction = MouseEvent.DRAG;
|
1275
|
+
break;
|
1276
|
+
case java.awt.event.MouseEvent.MOUSE_MOVED:
|
1277
|
+
peAction = MouseEvent.MOVE;
|
1278
|
+
break;
|
1279
|
+
case java.awt.event.MouseEvent.MOUSE_ENTERED:
|
1280
|
+
peAction = MouseEvent.ENTER;
|
1281
|
+
break;
|
1282
|
+
case java.awt.event.MouseEvent.MOUSE_EXITED:
|
1283
|
+
peAction = MouseEvent.EXIT;
|
1284
|
+
break;
|
1285
|
+
//case java.awt.event.MouseWheelEvent.WHEEL_UNIT_SCROLL:
|
1286
|
+
case java.awt.event.MouseEvent.MOUSE_WHEEL:
|
1287
|
+
peAction = MouseEvent.WHEEL;
|
1288
|
+
/*
|
1342
1289
|
if (preciseWheelMethod != null) {
|
1343
1290
|
try {
|
1344
1291
|
peAmount = ((Double) preciseWheelMethod.invoke(nativeEvent, (Object[]) null)).floatValue();
|
@@ -1346,9 +1293,9 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1346
1293
|
preciseWheelMethod = null;
|
1347
1294
|
}
|
1348
1295
|
}
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1296
|
+
*/
|
1297
|
+
peCount = ((MouseWheelEvent) nativeEvent).getWheelRotation();
|
1298
|
+
break;
|
1352
1299
|
}
|
1353
1300
|
|
1354
1301
|
//System.out.println(nativeEvent);
|
@@ -1356,11 +1303,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1356
1303
|
// If using getModifiersEx(), the regular modifiers don't set properly.
|
1357
1304
|
int modifiers = nativeEvent.getModifiers();
|
1358
1305
|
|
1359
|
-
int peModifiers = modifiers
|
1360
|
-
(InputEvent.SHIFT_MASK
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1306
|
+
int peModifiers = modifiers
|
1307
|
+
& (InputEvent.SHIFT_MASK
|
1308
|
+
| InputEvent.CTRL_MASK
|
1309
|
+
| InputEvent.META_MASK
|
1310
|
+
| InputEvent.ALT_MASK);
|
1364
1311
|
|
1365
1312
|
// Windows and OS X seem to disagree on how to handle this. Windows only
|
1366
1313
|
// sets BUTTON1_DOWN_MASK, while OS X seems to set BUTTON1_MASK.
|
@@ -1398,29 +1345,29 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1398
1345
|
}
|
1399
1346
|
|
1400
1347
|
sketch.postEvent(new MouseEvent(nativeEvent, nativeEvent.getWhen(),
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1348
|
+
peAction, peModifiers,
|
1349
|
+
nativeEvent.getX() / windowScaleFactor,
|
1350
|
+
nativeEvent.getY() / windowScaleFactor,
|
1351
|
+
peButton,
|
1352
|
+
peCount));
|
1406
1353
|
}
|
1407
1354
|
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1355
|
+
/**
|
1356
|
+
*
|
1357
|
+
* @param event
|
1358
|
+
*/
|
1359
|
+
protected void nativeKeyEvent(java.awt.event.KeyEvent event) {
|
1413
1360
|
int peAction = 0;
|
1414
1361
|
switch (event.getID()) {
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1362
|
+
case java.awt.event.KeyEvent.KEY_PRESSED:
|
1363
|
+
peAction = KeyEvent.PRESS;
|
1364
|
+
break;
|
1365
|
+
case java.awt.event.KeyEvent.KEY_RELEASED:
|
1366
|
+
peAction = KeyEvent.RELEASE;
|
1367
|
+
break;
|
1368
|
+
case java.awt.event.KeyEvent.KEY_TYPED:
|
1369
|
+
peAction = KeyEvent.TYPE;
|
1370
|
+
break;
|
1424
1371
|
}
|
1425
1372
|
|
1426
1373
|
// int peModifiers = event.getModifiersEx() &
|
@@ -1428,43 +1375,46 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1428
1375
|
// InputEvent.CTRL_DOWN_MASK |
|
1429
1376
|
// InputEvent.META_DOWN_MASK |
|
1430
1377
|
// InputEvent.ALT_DOWN_MASK);
|
1431
|
-
int peModifiers = event.getModifiers()
|
1432
|
-
(InputEvent.SHIFT_MASK
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1378
|
+
int peModifiers = event.getModifiers()
|
1379
|
+
& (InputEvent.SHIFT_MASK
|
1380
|
+
| InputEvent.CTRL_MASK
|
1381
|
+
| InputEvent.META_MASK
|
1382
|
+
| InputEvent.ALT_MASK);
|
1436
1383
|
|
1437
1384
|
sketch.postEvent(new KeyEvent(event, event.getWhen(),
|
1438
|
-
|
1439
|
-
|
1385
|
+
peAction, peModifiers,
|
1386
|
+
event.getKeyChar(), event.getKeyCode()));
|
1440
1387
|
}
|
1441
1388
|
|
1442
|
-
|
1443
1389
|
// listeners, for all my men!
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
protected void addListeners() {
|
1390
|
+
/**
|
1391
|
+
*
|
1392
|
+
*/
|
1393
|
+
protected final void addListeners() {
|
1449
1394
|
|
1450
1395
|
canvas.addMouseListener(new MouseListener() {
|
1451
1396
|
|
1397
|
+
@Override
|
1452
1398
|
public void mousePressed(java.awt.event.MouseEvent e) {
|
1453
1399
|
nativeMouseEvent(e);
|
1454
1400
|
}
|
1455
1401
|
|
1402
|
+
@Override
|
1456
1403
|
public void mouseReleased(java.awt.event.MouseEvent e) {
|
1457
1404
|
nativeMouseEvent(e);
|
1458
1405
|
}
|
1459
1406
|
|
1407
|
+
@Override
|
1460
1408
|
public void mouseClicked(java.awt.event.MouseEvent e) {
|
1461
1409
|
nativeMouseEvent(e);
|
1462
1410
|
}
|
1463
1411
|
|
1412
|
+
@Override
|
1464
1413
|
public void mouseEntered(java.awt.event.MouseEvent e) {
|
1465
1414
|
nativeMouseEvent(e);
|
1466
1415
|
}
|
1467
1416
|
|
1417
|
+
@Override
|
1468
1418
|
public void mouseExited(java.awt.event.MouseEvent e) {
|
1469
1419
|
nativeMouseEvent(e);
|
1470
1420
|
}
|
@@ -1472,34 +1422,34 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1472
1422
|
|
1473
1423
|
canvas.addMouseMotionListener(new MouseMotionListener() {
|
1474
1424
|
|
1425
|
+
@Override
|
1475
1426
|
public void mouseDragged(java.awt.event.MouseEvent e) {
|
1476
1427
|
nativeMouseEvent(e);
|
1477
1428
|
}
|
1478
1429
|
|
1430
|
+
@Override
|
1479
1431
|
public void mouseMoved(java.awt.event.MouseEvent e) {
|
1480
1432
|
nativeMouseEvent(e);
|
1481
1433
|
}
|
1482
1434
|
});
|
1483
1435
|
|
1484
|
-
canvas.addMouseWheelListener(
|
1485
|
-
|
1486
|
-
public void mouseWheelMoved(MouseWheelEvent e) {
|
1487
|
-
nativeMouseEvent(e);
|
1488
|
-
}
|
1436
|
+
canvas.addMouseWheelListener((MouseWheelEvent e) -> {
|
1437
|
+
nativeMouseEvent(e);
|
1489
1438
|
});
|
1490
1439
|
|
1491
1440
|
canvas.addKeyListener(new KeyListener() {
|
1492
1441
|
|
1442
|
+
@Override
|
1493
1443
|
public void keyPressed(java.awt.event.KeyEvent e) {
|
1494
1444
|
nativeKeyEvent(e);
|
1495
1445
|
}
|
1496
1446
|
|
1497
|
-
|
1447
|
+
@Override
|
1498
1448
|
public void keyReleased(java.awt.event.KeyEvent e) {
|
1499
1449
|
nativeKeyEvent(e);
|
1500
1450
|
}
|
1501
1451
|
|
1502
|
-
|
1452
|
+
@Override
|
1503
1453
|
public void keyTyped(java.awt.event.KeyEvent e) {
|
1504
1454
|
nativeKeyEvent(e);
|
1505
1455
|
}
|
@@ -1507,11 +1457,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1507
1457
|
|
1508
1458
|
canvas.addFocusListener(new FocusListener() {
|
1509
1459
|
|
1460
|
+
@Override
|
1510
1461
|
public void focusGained(FocusEvent e) {
|
1511
1462
|
sketch.focused = true;
|
1512
1463
|
sketch.focusGained();
|
1513
1464
|
}
|
1514
1465
|
|
1466
|
+
@Override
|
1515
1467
|
public void focusLost(FocusEvent e) {
|
1516
1468
|
sketch.focused = false;
|
1517
1469
|
sketch.focusLost();
|
@@ -1537,9 +1489,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1537
1489
|
comp.removeKeyListener(this);
|
1538
1490
|
comp.removeFocusListener(this);
|
1539
1491
|
}
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1492
|
+
*/
|
1543
1493
|
// /**
|
1544
1494
|
// * Call to remove, then add, listeners to a component.
|
1545
1495
|
// * Avoids issues with double-adding.
|
@@ -1548,21 +1498,16 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1548
1498
|
// removeListeners(comp);
|
1549
1499
|
// addListeners(comp);
|
1550
1500
|
// }
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
1501
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
1555
|
-
|
1556
|
-
|
1557
1502
|
int cursorType = PConstants.ARROW;
|
1558
1503
|
boolean cursorVisible = true;
|
1559
1504
|
Cursor invisibleCursor;
|
1560
1505
|
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1506
|
+
/**
|
1507
|
+
*
|
1508
|
+
* @param kind
|
1509
|
+
*/
|
1510
|
+
@Override
|
1566
1511
|
public void setCursor(int kind) {
|
1567
1512
|
// Swap the HAND cursor because MOVE doesn't seem to be available on OS X
|
1568
1513
|
// https://github.com/processing/processing/issues/2358
|
@@ -1574,13 +1519,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1574
1519
|
this.cursorType = kind;
|
1575
1520
|
}
|
1576
1521
|
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1522
|
+
/**
|
1523
|
+
*
|
1524
|
+
* @param img
|
1525
|
+
* @param x
|
1526
|
+
* @param y
|
1527
|
+
*/
|
1528
|
+
@Override
|
1584
1529
|
public void setCursor(PImage img, int x, int y) {
|
1585
1530
|
// Don't set cursorType, instead use cursorType to save the last
|
1586
1531
|
// regular cursor type used for when cursor() is called.
|
@@ -1592,18 +1537,18 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1592
1537
|
return;
|
1593
1538
|
}
|
1594
1539
|
|
1595
|
-
Cursor cursor
|
1596
|
-
canvas.getToolkit().createCustomCursor((Image) img.getNative(),
|
1597
|
-
|
1598
|
-
|
1540
|
+
Cursor cursor
|
1541
|
+
= canvas.getToolkit().createCustomCursor((Image) img.getNative(),
|
1542
|
+
new Point(x, y),
|
1543
|
+
"custom");
|
1599
1544
|
canvas.setCursor(cursor);
|
1600
1545
|
cursorVisible = true;
|
1601
1546
|
}
|
1602
1547
|
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1548
|
+
/**
|
1549
|
+
*
|
1550
|
+
*/
|
1551
|
+
@Override
|
1607
1552
|
public void showCursor() {
|
1608
1553
|
// Maybe should always set here? Seems dangerous, since it's likely that
|
1609
1554
|
// Java will set the cursor to something else on its own, and the sketch
|
@@ -1614,35 +1559,35 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1614
1559
|
}
|
1615
1560
|
}
|
1616
1561
|
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1562
|
+
/**
|
1563
|
+
*
|
1564
|
+
*/
|
1565
|
+
@Override
|
1621
1566
|
public void hideCursor() {
|
1622
1567
|
// Because the OS may have shown the cursor on its own,
|
1623
1568
|
// don't return if 'cursorVisible' is set to true. [rev 0216]
|
1624
1569
|
|
1625
1570
|
if (invisibleCursor == null) {
|
1626
|
-
BufferedImage cursorImg
|
1627
|
-
new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
1571
|
+
BufferedImage cursorImg
|
1572
|
+
= new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
1628
1573
|
// this is a temporary workaround for the CHIP, will be removed
|
1629
1574
|
Dimension cursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(16, 16);
|
1630
1575
|
if (cursorSize.width == 0 || cursorSize.height == 0) {
|
1631
1576
|
invisibleCursor = Cursor.getDefaultCursor();
|
1632
1577
|
} else {
|
1633
|
-
invisibleCursor
|
1634
|
-
canvas.getToolkit().createCustomCursor(cursorImg, new Point(8, 8), "blank");
|
1578
|
+
invisibleCursor
|
1579
|
+
= canvas.getToolkit().createCustomCursor(cursorImg, new Point(8, 8), "blank");
|
1635
1580
|
}
|
1636
1581
|
}
|
1637
1582
|
canvas.setCursor(invisibleCursor);
|
1638
1583
|
cursorVisible = false;
|
1639
1584
|
}
|
1640
1585
|
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1586
|
+
/**
|
1587
|
+
*
|
1588
|
+
* @return
|
1589
|
+
*/
|
1590
|
+
@Override
|
1646
1591
|
public Thread createThread() {
|
1647
1592
|
return new AnimationThread() {
|
1648
1593
|
@Override
|
@@ -1653,8 +1598,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1653
1598
|
};
|
1654
1599
|
}
|
1655
1600
|
|
1656
|
-
|
1657
|
-
void debug(String format, Object ... args) {
|
1601
|
+
void debug(String format, Object... args) {
|
1658
1602
|
System.out.format(format + "%n", args);
|
1659
1603
|
}
|
1660
1604
|
}
|