propane 3.5.0-java → 3.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -2
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG.md +3 -1
  7. data/README.md +5 -13
  8. data/Rakefile +1 -1
  9. data/lib/propane.rb +2 -1
  10. data/lib/propane/helper_methods.rb +0 -1
  11. data/lib/propane/runner.rb +2 -0
  12. data/lib/propane/version.rb +1 -1
  13. data/pom.rb +43 -43
  14. data/pom.xml +4 -4
  15. data/propane.gemspec +4 -3
  16. data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
  17. data/src/main/java/processing/awt/PGraphicsJava2D.java +8 -17
  18. data/src/main/java/processing/awt/PImageAWT.java +123 -6
  19. data/src/main/java/processing/awt/PShapeJava2D.java +1 -0
  20. data/src/main/java/processing/awt/PSurfaceAWT.java +9 -7
  21. data/src/main/java/processing/awt/ShimAWT.java +2 -1
  22. data/src/main/java/processing/core/PApplet.java +4605 -6014
  23. data/src/main/java/processing/core/PConstants.java +5 -5
  24. data/src/main/java/processing/core/PFont.java +5 -17
  25. data/src/main/java/processing/core/PGraphics.java +308 -320
  26. data/src/main/java/processing/core/PImage.java +1440 -1537
  27. data/src/main/java/processing/core/PMatrix2D.java +24 -7
  28. data/src/main/java/processing/core/PMatrix3D.java +12 -5
  29. data/src/main/java/processing/core/PShape.java +155 -173
  30. data/src/main/java/processing/core/PShapeOBJ.java +2 -0
  31. data/src/main/java/processing/core/PShapeSVG.java +632 -611
  32. data/src/main/java/processing/core/PSurface.java +15 -10
  33. data/src/main/java/processing/core/PSurfaceNone.java +8 -4
  34. data/src/main/java/processing/core/PVector.java +35 -28
  35. data/src/main/java/processing/data/Table.java +20 -20
  36. data/src/main/java/processing/data/XML.java +1 -1
  37. data/src/main/java/processing/event/Event.java +1 -1
  38. data/src/main/java/processing/event/MouseEvent.java +7 -6
  39. data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
  40. data/src/main/java/processing/javafx/PSurfaceFX.java +127 -125
  41. data/src/main/java/processing/opengl/FrameBuffer.java +2 -4
  42. data/src/main/java/processing/opengl/LinePath.java +4 -0
  43. data/src/main/java/processing/opengl/LineStroker.java +2 -6
  44. data/src/main/java/processing/opengl/PGL.java +72 -45
  45. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +106 -60
  46. data/src/main/java/processing/opengl/PJOGL.java +15 -3
  47. data/src/main/java/processing/opengl/PShader.java +26 -47
  48. data/src/main/java/processing/opengl/PShapeOpenGL.java +1041 -1001
  49. data/src/main/java/processing/opengl/PSurfaceJOGL.java +211 -208
  50. data/src/main/java/processing/opengl/Texture.java +7 -4
  51. data/src/main/java/processing/opengl/VertexBuffer.java +2 -2
  52. data/vendors/Rakefile +22 -33
  53. metadata +38 -18
@@ -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) 2012-15 The Processing Foundation
@@ -20,7 +20,8 @@
20
20
  Public License along with this library; if not, write to the
21
21
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
22
  Boston, MA 02111-1307 USA
23
- */
23
+ */
24
+
24
25
  package processing.opengl;
25
26
 
26
27
  import java.awt.Component;
@@ -78,11 +79,9 @@ import processing.awt.PImageAWT;
78
79
  // have this removed by 4.0 final
79
80
  import processing.awt.ShimAWT;
80
81
 
81
- public class PSurfaceJOGL implements PSurface {
82
82
 
83
- /**
84
- * Selected GL profile
85
- */
83
+ public class PSurfaceJOGL implements PSurface {
84
+ /** Selected GL profile */
86
85
  public static GLProfile profile;
87
86
 
88
87
  public PJOGL pgl;
@@ -115,9 +114,10 @@ public class PSurfaceJOGL implements PSurface {
115
114
 
116
115
  protected boolean external = false;
117
116
 
117
+
118
118
  public PSurfaceJOGL(PGraphics graphics) {
119
119
  this.graphics = graphics;
120
- this.pgl = (PJOGL) ((PGraphicsOpenGL) graphics).pgl;
120
+ this.pgl = (PJOGL) ((PGraphicsOpenGL)graphics).pgl;
121
121
  }
122
122
 
123
123
 
@@ -132,70 +132,63 @@ public class PSurfaceJOGL implements PSurface {
132
132
  public int displayDensity(int display) {
133
133
  return shim.displayDensity(display);
134
134
  }
135
- */
135
+ */
136
+
137
+
136
138
  // TODO rewrite before 4.0 release
137
139
  @Override
138
140
  public PImage loadImage(String path, Object... args) {
139
141
  return ShimAWT.loadImage(sketch, path, args);
140
142
  }
141
143
 
144
+
142
145
  @Override
143
146
  public void selectInput(String prompt, String callbackMethod,
144
- File file, Object callbackObject) {
147
+ File file, Object callbackObject) {
145
148
  EventQueue.invokeLater(() -> {
146
149
  // https://github.com/processing/processing/issues/3831
147
- boolean hide = (sketch != null)
148
- && (PApplet.platform == PConstants.WINDOWS);
149
- if (hide) {
150
- setVisible(false);
151
- }
150
+ boolean hide = (sketch != null) &&
151
+ (PApplet.platform == PConstants.WINDOWS);
152
+ if (hide) setVisible(false);
152
153
 
153
154
  ShimAWT.selectImpl(prompt, callbackMethod, file,
154
- callbackObject, null, FileDialog.LOAD);
155
+ callbackObject, null, FileDialog.LOAD);
155
156
 
156
- if (hide) {
157
- setVisible(true);
158
- }
157
+ if (hide) setVisible(true);
159
158
  });
160
159
  }
161
160
 
161
+
162
162
  @Override
163
163
  public void selectOutput(String prompt, String callbackMethod,
164
- File file, Object callbackObject) {
164
+ File file, Object callbackObject) {
165
165
  EventQueue.invokeLater(() -> {
166
166
  // https://github.com/processing/processing/issues/3831
167
- boolean hide = (sketch != null)
168
- && (PApplet.platform == PConstants.WINDOWS);
169
- if (hide) {
170
- setVisible(false);
171
- }
167
+ boolean hide = (sketch != null) &&
168
+ (PApplet.platform == PConstants.WINDOWS);
169
+ if (hide) setVisible(false);
172
170
 
173
171
  ShimAWT.selectImpl(prompt, callbackMethod, file,
174
- callbackObject, null, FileDialog.SAVE);
172
+ callbackObject, null, FileDialog.SAVE);
175
173
 
176
- if (hide) {
177
- setVisible(true);
178
- }
174
+ if (hide) setVisible(true);
179
175
  });
180
176
  }
181
177
 
178
+
182
179
  @Override
183
180
  public void selectFolder(String prompt, String callbackMethod,
184
- File file, Object callbackObject) {
181
+ File file, Object callbackObject) {
185
182
  EventQueue.invokeLater(() -> {
186
183
  // https://github.com/processing/processing/issues/3831
187
- boolean hide = (sketch != null)
188
- && (PApplet.platform == PConstants.WINDOWS);
189
- if (hide) {
190
- setVisible(false);
191
- }
192
-
184
+ boolean hide = (sketch != null) &&
185
+ (PApplet.platform == PConstants.WINDOWS);
186
+ if (hide) setVisible(false);
187
+
193
188
  ShimAWT.selectFolderImpl(prompt, callbackMethod, file,
194
189
  callbackObject, null);
195
-
196
- if (hide) {
197
- setVisible(true);
198
- }
190
+
191
+ if (hide) setVisible(true);
199
192
  });
200
193
  }
201
194
 
@@ -213,6 +206,7 @@ public class PSurfaceJOGL implements PSurface {
213
206
  }
214
207
  }
215
208
 
209
+
216
210
  @Override
217
211
  public void initFrame(PApplet sketch) {
218
212
  this.sketch = sketch;
@@ -225,11 +219,13 @@ public class PSurfaceJOGL implements PSurface {
225
219
  initAnimator();
226
220
  }
227
221
 
222
+
228
223
  @Override
229
224
  public Object getNative() {
230
225
  return window;
231
226
  }
232
227
 
228
+
233
229
  protected void initDisplay() {
234
230
  display = NewtFactory.createDisplay(null);
235
231
  display.addReference();
@@ -243,12 +239,12 @@ public class PSurfaceJOGL implements PSurface {
243
239
  int displayNum = sketch.sketchDisplay();
244
240
  if (displayNum > 0) { // if -1, use the default device
245
241
  if (displayNum <= awtDevices.length) {
246
- awtDisplayDevice = awtDevices[displayNum - 1];
242
+ awtDisplayDevice = awtDevices[displayNum-1];
247
243
  } else {
248
- System.err.format("Display %d does not exist, "
249
- + "using the default display instead.%n", displayNum);
244
+ System.err.format("Display %d does not exist, " +
245
+ "using the default display instead.%n", displayNum);
250
246
  for (int i = 0; i < awtDevices.length; i++) {
251
- System.err.format("Display %d is %s%n", i + 1, awtDevices[i]);
247
+ System.err.format("Display %d is %s%n", i+1, awtDevices[i]);
252
248
  }
253
249
  }
254
250
  } else if (0 < awtDevices.length) {
@@ -263,53 +259,48 @@ public class PSurfaceJOGL implements PSurface {
263
259
  displayRect = config.getBounds();
264
260
  }
265
261
 
262
+
266
263
  protected void initGL() {
267
264
  // System.out.println("*******************************");
268
265
  if (profile == null) {
269
266
  switch (PJOGL.profile) {
270
267
  case 1:
271
268
  try {
272
- profile = GLProfile.getGL2ES1();
273
- } catch (GLException ex) {
274
- profile = GLProfile.getMaxFixedFunc(true);
275
- }
276
- break;
269
+ profile = GLProfile.getGL2ES1();
270
+ } catch (GLException ex) {
271
+ profile = GLProfile.getMaxFixedFunc(true);
272
+ } break;
277
273
  case 2:
278
274
  try {
279
- profile = GLProfile.getGL2ES2();
280
-
281
- // workaround for https://jogamp.org/bugzilla/show_bug.cgi?id=1347
282
- if (!profile.isHardwareRasterizer()) {
283
- GLProfile hardware = GLProfile.getMaxProgrammable(true);
284
- if (hardware.isGL2ES2()) {
285
- profile = hardware;
275
+ profile = GLProfile.getGL2ES2();
276
+
277
+ // workaround for https://jogamp.org/bugzilla/show_bug.cgi?id=1347
278
+ if (!profile.isHardwareRasterizer()) {
279
+ GLProfile hardware = GLProfile.getMaxProgrammable(true);
280
+ if (hardware.isGL2ES2()) {
281
+ profile = hardware;
282
+ }
286
283
  }
287
- }
288
-
289
- } catch (GLException ex) {
290
- profile = GLProfile.getMaxProgrammable(true);
291
- }
292
- break;
284
+
285
+ } catch (GLException ex) {
286
+ profile = GLProfile.getMaxProgrammable(true);
287
+ } break;
293
288
  case 3:
294
289
  try {
295
- profile = GLProfile.getGL2GL3();
296
- } catch (GLException ex) {
297
- profile = GLProfile.getMaxProgrammable(true);
298
- }
299
- if (!profile.isGL3()) {
300
- PGraphics.showWarning("Requested profile GL3 but is not available, got: " + profile);
301
- }
302
- break;
290
+ profile = GLProfile.getGL2GL3();
291
+ } catch (GLException ex) {
292
+ profile = GLProfile.getMaxProgrammable(true);
293
+ } if (!profile.isGL3()) {
294
+ PGraphics.showWarning("Requested profile GL3 but is not available, got: " + profile);
295
+ } break;
303
296
  case 4:
304
297
  try {
305
- profile = GLProfile.getGL4ES3();
306
- } catch (GLException ex) {
307
- profile = GLProfile.getMaxProgrammable(true);
308
- }
309
- if (!profile.isGL4()) {
310
- PGraphics.showWarning("Requested profile GL4 but is not available, got: " + profile);
311
- }
312
- break;
298
+ profile = GLProfile.getGL4ES3();
299
+ } catch (GLException ex) {
300
+ profile = GLProfile.getMaxProgrammable(true);
301
+ } if (!profile.isGL4()) {
302
+ PGraphics.showWarning("Requested profile GL4 but is not available, got: " + profile);
303
+ } break;
313
304
  default:
314
305
  throw new RuntimeException(PGL.UNSUPPORTED_GLPROF_ERROR);
315
306
  }
@@ -323,6 +314,7 @@ public class PSurfaceJOGL implements PSurface {
323
314
 
324
315
  // caps.setPBuffer(false);
325
316
  // caps.setFBO(false);
317
+
326
318
  // pgl.reqNumSamples = PGL.smoothToSamples(graphics.smooth);
327
319
  caps.setSampleBuffers(true);
328
320
  caps.setNumSamples(PGL.smoothToSamples(graphics.smooth));
@@ -331,6 +323,7 @@ public class PSurfaceJOGL implements PSurface {
331
323
  pgl.setCaps(caps);
332
324
  }
333
325
 
326
+
334
327
  protected void initWindow() {
335
328
  window = GLWindow.create(screen, pgl.getCaps());
336
329
 
@@ -346,15 +339,16 @@ public class PSurfaceJOGL implements PSurface {
346
339
  // } else {
347
340
  // window = GLWindow.create(displayDevice.getScreen(), pgl.getCaps());
348
341
  // }
349
- windowScaleFactor = PApplet.platform == PConstants.MACOS
350
- ? 1 : sketch.pixelDensity;
342
+
343
+ windowScaleFactor = PApplet.platform == PConstants.MACOS ?
344
+ 1 : sketch.pixelDensity;
351
345
 
352
346
  boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN;
353
- screenRect = spanDisplays
354
- ? new Rectangle(screen.getX(), screen.getY(), screen.getWidth(), screen.getHeight())
355
- : new Rectangle((int) displayRect.getX(), (int) displayRect.getY(),
356
- (int) displayRect.getWidth(),
357
- (int) displayRect.getHeight());
347
+ screenRect = spanDisplays ?
348
+ new Rectangle(screen.getX(), screen.getY(), screen.getWidth(), screen.getHeight()) :
349
+ new Rectangle((int) displayRect.getX(), (int) displayRect.getY(),
350
+ (int) displayRect.getWidth(),
351
+ (int) displayRect.getHeight());
358
352
 
359
353
  // Set the displayWidth/Height variables inside PApplet, so that they're
360
354
  // usable and can even be returned by the sketchWidth()/Height() methods.
@@ -381,7 +375,8 @@ public class PSurfaceJOGL implements PSurface {
381
375
  // graphics.setSize(w, h - 22 - 22);
382
376
  System.err.println("setting width/height to " + w + " " + h);
383
377
  }
384
- */
378
+ */
379
+
385
380
  sketchWidth = sketch.sketchWidth();
386
381
  sketchHeight = sketch.sketchHeight();
387
382
  // System.out.println("init: " + sketchWidth + " " + sketchHeight);
@@ -399,7 +394,7 @@ public class PSurfaceJOGL implements PSurface {
399
394
  fullScreen = true;
400
395
  sketch.fullScreen();
401
396
  }
402
- */
397
+ */
403
398
 
404
399
  if (fullScreen || spanDisplays) {
405
400
  sketchWidth = screenRect.width / windowScaleFactor;
@@ -410,13 +405,13 @@ public class PSurfaceJOGL implements PSurface {
410
405
 
411
406
  float[] reqSurfacePixelScale;
412
407
  if (graphics.is2X() && PApplet.platform == PConstants.MACOS) {
413
- // Retina
414
- reqSurfacePixelScale = new float[]{ScalableSurface.AUTOMAX_PIXELSCALE,
415
- ScalableSurface.AUTOMAX_PIXELSCALE};
408
+ // Retina
409
+ reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE,
410
+ ScalableSurface.AUTOMAX_PIXELSCALE };
416
411
  } else {
417
412
  // Non-retina
418
- reqSurfacePixelScale = new float[]{ScalableSurface.IDENTITY_PIXELSCALE,
419
- ScalableSurface.IDENTITY_PIXELSCALE};
413
+ reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE,
414
+ ScalableSurface.IDENTITY_PIXELSCALE };
420
415
  }
421
416
  window.setSurfaceScale(reqSurfacePixelScale);
422
417
  window.setSize(sketchWidth * windowScaleFactor, sketchHeight * windowScaleFactor);
@@ -434,6 +429,7 @@ public class PSurfaceJOGL implements PSurface {
434
429
  }
435
430
  }
436
431
 
432
+
437
433
  protected void initListeners() {
438
434
  NEWTMouseListener mouseListener = new NEWTMouseListener();
439
435
  window.addMouseListener(mouseListener);
@@ -446,6 +442,7 @@ public class PSurfaceJOGL implements PSurface {
446
442
  window.addGLEventListener(drawlistener);
447
443
  }
448
444
 
445
+
449
446
  protected void initAnimator() {
450
447
  if (PApplet.platform == PConstants.WINDOWS) {
451
448
  // Force Windows to keep timer resolution high by
@@ -455,8 +452,7 @@ public class PSurfaceJOGL implements PSurface {
455
452
  Thread highResTimerThread = new Thread(() -> {
456
453
  try {
457
454
  Thread.sleep(Long.MAX_VALUE);
458
- } catch (InterruptedException ignore) {
459
- }
455
+ } catch (InterruptedException ignore) { }
460
456
  }, "HighResTimerThread");
461
457
  highResTimerThread.setDaemon(true);
462
458
  highResTimerThread.start();
@@ -500,6 +496,7 @@ public class PSurfaceJOGL implements PSurface {
500
496
  drawExceptionHandler.start();
501
497
  }
502
498
 
499
+
503
500
  @Override
504
501
  public void setTitle(final String title) {
505
502
  display.getEDTUtil().invoke(false, () -> {
@@ -507,6 +504,7 @@ public class PSurfaceJOGL implements PSurface {
507
504
  });
508
505
  }
509
506
 
507
+
510
508
  @Override
511
509
  public void setVisible(final boolean visible) {
512
510
  display.getEDTUtil().invoke(false, () -> {
@@ -514,6 +512,7 @@ public class PSurfaceJOGL implements PSurface {
514
512
  });
515
513
  }
516
514
 
515
+
517
516
  @Override
518
517
  public void setResizable(final boolean resizable) {
519
518
  display.getEDTUtil().invoke(false, () -> {
@@ -521,12 +520,14 @@ public class PSurfaceJOGL implements PSurface {
521
520
  });
522
521
  }
523
522
 
523
+
524
524
  @Override
525
525
  public void setIcon(PImage icon) {
526
- PGraphics.showWarning("Window icons for OpenGL sketches can only be set in settings()\n"
527
- + "using PJOGL.setIcon(filename).");
526
+ PGraphics.showWarning("Window icons for OpenGL sketches can only be set in settings()\n" +
527
+ "using PJOGL.setIcon(filename).");
528
528
  }
529
529
 
530
+
530
531
  @Override
531
532
  public void setAlwaysOnTop(final boolean always) {
532
533
  display.getEDTUtil().invoke(false, () -> {
@@ -534,18 +535,19 @@ public class PSurfaceJOGL implements PSurface {
534
535
  });
535
536
  }
536
537
 
538
+
537
539
  protected void initIcons() {
538
540
  IOUtil.ClassResources res = null;
539
541
  if (PJOGL.icons == null || PJOGL.icons.length == 0) {
540
542
  // Default Processing icons
541
- final int[] sizes = {16, 32, 48, 64, 128, 256, 512};
543
+ final int[] sizes = { 16, 32, 48, 64, 128, 256, 512 };
542
544
  String[] iconImages = new String[sizes.length];
543
545
  for (int i = 0; i < sizes.length; i++) {
544
- iconImages[i] = "/icon/icon-" + sizes[i] + ".png";
545
- }
546
- res = new ClassResources(iconImages,
547
- PApplet.class.getClassLoader(),
548
- PApplet.class);
546
+ iconImages[i] = "/icon/icon-" + sizes[i] + ".png";
547
+ }
548
+ res = new ClassResources(iconImages,
549
+ PApplet.class.getClassLoader(),
550
+ PApplet.class);
549
551
  } else {
550
552
  // Loading custom icons from user-provided files.
551
553
  String[] iconImages = new String[PJOGL.icons.length];
@@ -554,12 +556,13 @@ public class PSurfaceJOGL implements PSurface {
554
556
  }
555
557
 
556
558
  res = new ClassResources(iconImages,
557
- sketch.getClass().getClassLoader(),
558
- sketch.getClass());
559
+ sketch.getClass().getClassLoader(),
560
+ sketch.getClass());
559
561
  }
560
562
  NewtFactory.setWindowIcons(res);
561
563
  }
562
564
 
565
+
563
566
  @SuppressWarnings("resource")
564
567
  private String resourceFilename(String filename) {
565
568
  // The code below comes from PApplet.createInputRaw() with a few adaptations
@@ -585,21 +588,17 @@ public class PSurfaceJOGL implements PSurface {
585
588
  //if (filenameActual.equalsIgnoreCase(filenameShort) &&
586
589
  //!filenameActual.equals(filenameShort)) {
587
590
  if (!filenameActual.equals(filenameShort)) {
588
- throw new RuntimeException("This file is named "
589
- + filenameActual + " not "
590
- + filename + ". Rename the file "
591
- + "or change your code.");
591
+ throw new RuntimeException("This file is named " +
592
+ filenameActual + " not " +
593
+ filename + ". Rename the file " +
594
+ "or change your code.");
592
595
  }
593
- } catch (IOException e) {
594
- }
596
+ } catch (IOException e) { }
595
597
  }
596
598
 
597
599
  stream = new FileInputStream(file);
598
- if (stream != null) {
599
- stream.close();
600
- return file.getCanonicalPath();
601
- }
602
-
600
+ stream.close();
601
+ return file.getCanonicalPath();
603
602
  // have to break these out because a general Exception might
604
603
  // catch the RuntimeException being thrown above
605
604
  } catch (IOException | SecurityException ioe) {
@@ -634,8 +633,7 @@ public class PSurfaceJOGL implements PSurface {
634
633
  return filename;
635
634
  }
636
635
  }
637
- } catch (IOException e) {
638
- }
636
+ } catch (IOException e) { }
639
637
 
640
638
  try {
641
639
  // attempt to load from a local file, used when running as
@@ -644,34 +642,25 @@ public class PSurfaceJOGL implements PSurface {
644
642
  try {
645
643
  String path = sketch.dataPath(filename);
646
644
  stream = new FileInputStream(path);
647
- if (stream != null) {
648
- stream.close();
649
- return path;
650
- }
651
- } catch (IOException e2) {
652
- }
645
+ stream.close();
646
+ return path;
647
+ } catch (IOException e2) { }
653
648
 
654
649
  try {
655
650
  String path = sketch.sketchPath(filename);
656
651
  stream = new FileInputStream(path);
657
- if (stream != null) {
658
- stream.close();
659
- return path;
660
- }
661
- } catch (IOException e) {
662
- } // ignored
652
+ stream.close();
653
+ return path;
654
+ } catch (IOException e) { } // ignored
663
655
 
664
656
  try {
665
657
  stream = new FileInputStream(filename);
666
- if (stream != null) {
667
- stream.close();
668
- return filename;
669
- }
670
- } catch (IOException e1) {
671
- }
658
+ stream.close();
659
+ return filename;
660
+
661
+ } catch (IOException e1) { }
672
662
 
673
- } catch (SecurityException se) {
674
- } // online, whups
663
+ } catch (SecurityException se) { } // online, whups
675
664
 
676
665
  } catch (Exception e) {
677
666
  //die(e.getMessage(), e);
@@ -681,6 +670,7 @@ public class PSurfaceJOGL implements PSurface {
681
670
  return "";
682
671
  }
683
672
 
673
+
684
674
  @Override
685
675
  public void placeWindow(int[] location, int[] editorLocation) {
686
676
 
@@ -717,19 +707,19 @@ public class PSurfaceJOGL implements PSurface {
717
707
  if ((locationX + w > sketch.displayWidth - 33) ||
718
708
  (locationY + h > sketch.displayHeight - 33)) {
719
709
  // otherwise center on screen
720
- */
710
+ */
721
711
  locationX = (sketch.displayWidth - w) / 2;
722
712
  locationY = (sketch.displayHeight - h) / 2;
723
713
  /*
724
714
  }
725
- */
715
+ */
726
716
  window.setTopLevelPosition(locationX, locationY);
727
717
  }
728
718
  } else { // just center on screen
729
719
  // Can't use frame.setLocationRelativeTo(null) because it sends the
730
720
  // frame to the main display, which undermines the --display setting.
731
721
  window.setTopLevelPosition(screenRect.x + (screenRect.width - sketchWidth) / 2,
732
- screenRect.y + (screenRect.height - sketchHeight) / 2);
722
+ screenRect.y + (screenRect.height - sketchHeight) / 2);
733
723
  }
734
724
 
735
725
  Point frameLoc = new Point(x, y);
@@ -740,11 +730,12 @@ public class PSurfaceJOGL implements PSurface {
740
730
  }
741
731
  }
742
732
 
733
+
743
734
  @Override
744
735
  public void placePresent(int stopColor) {
745
736
  float scale = getPixelScale();
746
- pgl.initPresentMode(0.5f * (screenRect.width / scale - sketchWidth),
747
- 0.5f * (screenRect.height / scale - sketchHeight), stopColor);
737
+ pgl.initPresentMode(0.5f * (screenRect.width/scale - sketchWidth),
738
+ 0.5f * (screenRect.height/scale - sketchHeight), stopColor);
748
739
  PApplet.hideMenuBar();
749
740
 
750
741
  window.setUndecorated(true);
@@ -752,11 +743,13 @@ public class PSurfaceJOGL implements PSurface {
752
743
  window.setTopLevelSize((int) displayRect.getWidth(), (int) displayRect.getHeight());
753
744
  }
754
745
 
746
+
755
747
  @Override
756
748
  public void setupExternalMessages() {
757
749
  external = true;
758
750
  }
759
751
 
752
+
760
753
  @Override
761
754
  public void startThread() {
762
755
  if (animator != null) {
@@ -764,12 +757,15 @@ public class PSurfaceJOGL implements PSurface {
764
757
  }
765
758
  }
766
759
 
760
+
761
+ @Override
767
762
  public void pauseThread() {
768
763
  if (animator != null) {
769
764
  animator.pause();
770
765
  }
771
766
  }
772
767
 
768
+
773
769
  @Override
774
770
  public void resumeThread() {
775
771
  if (animator != null) {
@@ -777,6 +773,7 @@ public class PSurfaceJOGL implements PSurface {
777
773
  }
778
774
  }
779
775
 
776
+
780
777
  @Override
781
778
  public boolean stopThread() {
782
779
  if (drawExceptionHandler != null) {
@@ -790,6 +787,7 @@ public class PSurfaceJOGL implements PSurface {
790
787
  }
791
788
  }
792
789
 
790
+
793
791
  @Override
794
792
  public boolean isStopped() {
795
793
  if (animator != null) {
@@ -799,6 +797,7 @@ public class PSurfaceJOGL implements PSurface {
799
797
  }
800
798
  }
801
799
 
800
+
802
801
  @Override
803
802
  public void setLocation(final int x, final int y) {
804
803
  display.getEDTUtil().invoke(false, () -> {
@@ -806,11 +805,10 @@ public class PSurfaceJOGL implements PSurface {
806
805
  });
807
806
  }
808
807
 
808
+
809
809
  @Override
810
810
  public void setSize(int wide, int high) {
811
- if (pgl.presentMode()) {
812
- return;
813
- }
811
+ if (pgl.presentMode()) return;
814
812
 
815
813
  // When the surface is set to resizable via surface.setResizable(true),
816
814
  // a crash may occur if the user sets the window to size zero.
@@ -835,6 +833,7 @@ public class PSurfaceJOGL implements PSurface {
835
833
  }
836
834
  }
837
835
 
836
+
838
837
  public float getPixelScale() {
839
838
  if (graphics.pixelDensity == 1) {
840
839
  return 1;
@@ -854,10 +853,12 @@ public class PSurfaceJOGL implements PSurface {
854
853
  return currentPixelScale[0];
855
854
  }
856
855
 
856
+
857
857
  public Component getComponent() {
858
858
  return canvas;
859
859
  }
860
860
 
861
+
861
862
  public void setSmooth(int level) {
862
863
  pgl.reqNumSamples = level;
863
864
  GLCapabilities caps = new GLCapabilities(profile);
@@ -873,35 +874,37 @@ public class PSurfaceJOGL implements PSurface {
873
874
  config.setChosenCapabilities(caps);
874
875
  }
875
876
 
877
+
876
878
  @Override
877
879
  public void setFrameRate(float fps) {
878
880
  if (fps < 1) {
879
881
  PGraphics.showWarning(
880
- "The OpenGL renderer cannot have a frame rate lower than 1.\n"
881
- + "Your sketch will run at 1 frame per second.");
882
+ "The OpenGL renderer cannot have a frame rate lower than 1.\n" +
883
+ "Your sketch will run at 1 frame per second.");
882
884
  fps = 1;
883
885
  } else if (fps > 1000) {
884
886
  PGraphics.showWarning(
885
- "The OpenGL renderer cannot have a frame rate higher than 1000.\n"
886
- + "Your sketch will run at 1000 frames per second.");
887
+ "The OpenGL renderer cannot have a frame rate higher than 1000.\n" +
888
+ "Your sketch will run at 1000 frames per second.");
887
889
  fps = 1000;
888
890
  }
889
891
  if (animator != null) {
890
892
  animator.stop();
891
- animator.setFPS((int) fps);
893
+ animator.setFPS((int)fps);
892
894
  pgl.setFps(fps);
893
895
  animator.start();
894
896
  }
895
897
  }
896
898
 
899
+
897
900
  public void requestFocus() {
898
901
  display.getEDTUtil().invoke(false, () -> {
899
902
  window.requestFocus();
900
903
  });
901
904
  }
902
905
 
903
- class DrawListener implements GLEventListener {
904
906
 
907
+ class DrawListener implements GLEventListener {
905
908
  @Override
906
909
  public void display(GLAutoDrawable drawable) {
907
910
  if (display.getEDTUtil().isCurrentThreadEDT()) {
@@ -939,12 +942,10 @@ public class PSurfaceJOGL implements PSurface {
939
942
  sketch.exitActual();
940
943
  }
941
944
  }
942
-
943
945
  @Override
944
946
  public void dispose(GLAutoDrawable drawable) {
945
947
  // sketch.dispose();
946
948
  }
947
-
948
949
  @Override
949
950
  public void init(GLAutoDrawable drawable) {
950
951
  pgl.getGL(drawable);
@@ -953,9 +954,9 @@ public class PSurfaceJOGL implements PSurface {
953
954
 
954
955
  int c = graphics.backgroundColor;
955
956
  pgl.clearColor(((c >> 16) & 0xff) / 255f,
956
- ((c >> 8) & 0xff) / 255f,
957
- ((c) & 0xff) / 255f,
958
- ((c >> 24) & 0xff) / 255f);
957
+ ((c >> 8) & 0xff) / 255f,
958
+ ((c) & 0xff) / 255f,
959
+ ((c >> 24) & 0xff) / 255f);
959
960
  pgl.clear(PGL.COLOR_BUFFER_BIT);
960
961
  }
961
962
 
@@ -963,18 +964,17 @@ public class PSurfaceJOGL implements PSurface {
963
964
  public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
964
965
  pgl.resetFBOLayer();
965
966
  pgl.getGL(drawable);
966
- float scale = PApplet.platform == PConstants.MACOS
967
- ? getCurrentPixelScale() : getPixelScale();
967
+ float scale = PApplet.platform == PConstants.MACOS ?
968
+ getCurrentPixelScale() : getPixelScale();
968
969
  setSize((int) (w / scale), (int) (h / scale));
969
970
  }
970
971
  }
971
972
 
972
- protected class NEWTWindowListener implements com.jogamp.newt.event.WindowListener {
973
973
 
974
+ protected class NEWTWindowListener implements com.jogamp.newt.event.WindowListener {
974
975
  public NEWTWindowListener() {
975
976
  super();
976
977
  }
977
-
978
978
  @Override
979
979
  public void windowGainedFocus(com.jogamp.newt.event.WindowEvent arg0) {
980
980
  sketch.focused = true;
@@ -1013,49 +1013,41 @@ public class PSurfaceJOGL implements PSurface {
1013
1013
  }
1014
1014
  }
1015
1015
 
1016
+
1016
1017
  // NEWT mouse listener
1017
1018
  protected class NEWTMouseListener extends com.jogamp.newt.event.MouseAdapter {
1018
-
1019
1019
  public NEWTMouseListener() {
1020
1020
  super();
1021
1021
  }
1022
-
1023
1022
  @Override
1024
1023
  public void mousePressed(com.jogamp.newt.event.MouseEvent e) {
1025
1024
  nativeMouseEvent(e, MouseEvent.PRESS);
1026
1025
  }
1027
-
1028
1026
  @Override
1029
1027
  public void mouseReleased(com.jogamp.newt.event.MouseEvent e) {
1030
1028
  nativeMouseEvent(e, MouseEvent.RELEASE);
1031
1029
  }
1032
-
1033
1030
  @Override
1034
1031
  public void mouseClicked(com.jogamp.newt.event.MouseEvent e) {
1035
1032
  nativeMouseEvent(e, MouseEvent.CLICK);
1036
1033
  }
1037
-
1038
1034
  @Override
1039
1035
  public void mouseDragged(com.jogamp.newt.event.MouseEvent e) {
1040
1036
  nativeMouseEvent(e, MouseEvent.DRAG);
1041
1037
  }
1042
-
1043
1038
  @Override
1044
1039
  public void mouseMoved(com.jogamp.newt.event.MouseEvent e) {
1045
1040
  nativeMouseEvent(e, MouseEvent.MOVE);
1046
1041
  }
1047
-
1048
1042
  @Override
1049
1043
  public void mouseWheelMoved(com.jogamp.newt.event.MouseEvent e) {
1050
1044
  nativeMouseEvent(e, MouseEvent.WHEEL);
1051
1045
  }
1052
-
1053
1046
  @Override
1054
1047
  public void mouseEntered(com.jogamp.newt.event.MouseEvent e) {
1055
1048
  // System.out.println("enter");
1056
1049
  nativeMouseEvent(e, MouseEvent.ENTER);
1057
1050
  }
1058
-
1059
1051
  @Override
1060
1052
  public void mouseExited(com.jogamp.newt.event.MouseEvent e) {
1061
1053
  // System.out.println("exit");
@@ -1063,30 +1055,28 @@ public class PSurfaceJOGL implements PSurface {
1063
1055
  }
1064
1056
  }
1065
1057
 
1058
+
1066
1059
  // NEWT key listener
1067
1060
  protected class NEWTKeyListener extends com.jogamp.newt.event.KeyAdapter {
1068
-
1069
1061
  public NEWTKeyListener() {
1070
1062
  super();
1071
1063
  }
1072
-
1073
1064
  @Override
1074
1065
  public void keyPressed(com.jogamp.newt.event.KeyEvent e) {
1075
1066
  nativeKeyEvent(e, KeyEvent.PRESS);
1076
1067
  }
1077
-
1078
1068
  @Override
1079
1069
  public void keyReleased(com.jogamp.newt.event.KeyEvent e) {
1080
1070
  nativeKeyEvent(e, KeyEvent.RELEASE);
1081
1071
  }
1082
-
1083
- public void keyTyped(com.jogamp.newt.event.KeyEvent e) {
1072
+ public void keyTyped(com.jogamp.newt.event.KeyEvent e) {
1084
1073
  nativeKeyEvent(e, KeyEvent.TYPE);
1085
1074
  }
1086
1075
  }
1087
1076
 
1077
+
1088
1078
  protected void nativeMouseEvent(com.jogamp.newt.event.MouseEvent nativeEvent,
1089
- int peAction) {
1079
+ int peAction) {
1090
1080
  int modifiers = nativeEvent.getModifiers();
1091
1081
  /*
1092
1082
  int peModifiers = modifiers &
@@ -1113,8 +1103,8 @@ public class PSurfaceJOGL implements PSurface {
1113
1103
  if (peAction == MouseEvent.WHEEL) {
1114
1104
  // Invert wheel rotation count so it matches JAVA2D's
1115
1105
  // https://github.com/processing/processing/issues/3840
1116
- peCount = -(nativeEvent.isShiftDown() ? (int) nativeEvent.getRotation()[0]
1117
- : (int) nativeEvent.getRotation()[1]);
1106
+ peCount = -(nativeEvent.isShiftDown() ? (int)nativeEvent.getRotation()[0]:
1107
+ (int)nativeEvent.getRotation()[1]);
1118
1108
  } else {
1119
1109
  peCount = nativeEvent.getClickCount();
1120
1110
  }
@@ -1131,10 +1121,10 @@ public class PSurfaceJOGL implements PSurface {
1131
1121
  int my = sy;
1132
1122
 
1133
1123
  if (pgl.presentMode()) {
1134
- mx -= (int) pgl.presentX;
1135
- my -= (int) pgl.presentY;
1136
- if (peAction == KeyEvent.RELEASE
1137
- && pgl.insideStopButton(sx, sy - screenRect.height / windowScaleFactor)) {
1124
+ mx -= (int)pgl.presentX;
1125
+ my -= (int)pgl.presentY;
1126
+ if (peAction == KeyEvent.RELEASE &&
1127
+ pgl.insideStopButton(sx, sy - screenRect.height / windowScaleFactor)) {
1138
1128
  sketch.exit();
1139
1129
  }
1140
1130
  if (mx < 0 || sketchWidth < mx || my < 0 || sketchHeight < my) {
@@ -1143,16 +1133,17 @@ public class PSurfaceJOGL implements PSurface {
1143
1133
  }
1144
1134
 
1145
1135
  MouseEvent me = new MouseEvent(nativeEvent, nativeEvent.getWhen(),
1146
- peAction, modifiers,
1147
- mx, my,
1148
- peButton,
1149
- peCount);
1136
+ peAction, modifiers,
1137
+ mx, my,
1138
+ peButton,
1139
+ peCount);
1150
1140
 
1151
1141
  sketch.postEvent(me);
1152
1142
  }
1153
1143
 
1144
+
1154
1145
  protected void nativeKeyEvent(com.jogamp.newt.event.KeyEvent nativeEvent,
1155
- int peAction) {
1146
+ int peAction) {
1156
1147
  int modifiers = nativeEvent.getModifiers();
1157
1148
  // int peModifiers = nativeEvent.getModifiers() &
1158
1149
  // (InputEvent.SHIFT_MASK |
@@ -1168,8 +1159,8 @@ public class PSurfaceJOGL implements PSurface {
1168
1159
  keyChar = PConstants.CODED;
1169
1160
  } else if (isHackyKey(code)) {
1170
1161
  // we can return only one char for ENTER, let it be \n everywhere
1171
- keyCode = code == com.jogamp.newt.event.KeyEvent.VK_ENTER
1172
- ? PConstants.ENTER : code;
1162
+ keyCode = code == com.jogamp.newt.event.KeyEvent.VK_ENTER ?
1163
+ PConstants.ENTER : code;
1173
1164
  keyChar = hackToChar(code, nativeEvent.getKeyChar());
1174
1165
  } else {
1175
1166
  keyCode = code;
@@ -1184,10 +1175,10 @@ public class PSurfaceJOGL implements PSurface {
1184
1175
  // In contrast to key symbol, key code uses a fixed US keyboard layout and therefore is keyboard layout independent.
1185
1176
  // E.g. virtual key code VK_Y denotes the same physical key regardless whether keyboard layout QWERTY or QWERTZ is active. The key symbol of the former is VK_Y, where the latter produces VK_Y.
1186
1177
  KeyEvent ke = new KeyEvent(nativeEvent, nativeEvent.getWhen(),
1187
- peAction, modifiers,
1188
- keyChar,
1189
- keyCode,
1190
- nativeEvent.isAutoRepeat());
1178
+ peAction, modifiers,
1179
+ keyChar,
1180
+ keyCode,
1181
+ nativeEvent.isAutoRepeat());
1191
1182
 
1192
1183
  sketch.postEvent(ke);
1193
1184
 
@@ -1196,27 +1187,29 @@ public class PSurfaceJOGL implements PSurface {
1196
1187
  // Create key typed event
1197
1188
  // TODO: combine dead keys with the following key
1198
1189
  KeyEvent tke = new KeyEvent(nativeEvent, nativeEvent.getWhen(),
1199
- KeyEvent.TYPE, modifiers,
1200
- keyChar,
1201
- 0,
1202
- nativeEvent.isAutoRepeat());
1190
+ KeyEvent.TYPE, modifiers,
1191
+ keyChar,
1192
+ 0,
1193
+ nativeEvent.isAutoRepeat());
1203
1194
 
1204
1195
  sketch.postEvent(tke);
1205
1196
  }
1206
1197
  }
1207
1198
  }
1208
1199
 
1200
+
1209
1201
  private static boolean isPCodedKey(short code) {
1210
- return code == com.jogamp.newt.event.KeyEvent.VK_UP
1211
- || code == com.jogamp.newt.event.KeyEvent.VK_DOWN
1212
- || code == com.jogamp.newt.event.KeyEvent.VK_LEFT
1213
- || code == com.jogamp.newt.event.KeyEvent.VK_RIGHT
1214
- || code == com.jogamp.newt.event.KeyEvent.VK_ALT
1215
- || code == com.jogamp.newt.event.KeyEvent.VK_CONTROL
1216
- || code == com.jogamp.newt.event.KeyEvent.VK_SHIFT
1217
- || code == com.jogamp.newt.event.KeyEvent.VK_WINDOWS;
1202
+ return code == com.jogamp.newt.event.KeyEvent.VK_UP ||
1203
+ code == com.jogamp.newt.event.KeyEvent.VK_DOWN ||
1204
+ code == com.jogamp.newt.event.KeyEvent.VK_LEFT ||
1205
+ code == com.jogamp.newt.event.KeyEvent.VK_RIGHT ||
1206
+ code == com.jogamp.newt.event.KeyEvent.VK_ALT ||
1207
+ code == com.jogamp.newt.event.KeyEvent.VK_CONTROL ||
1208
+ code == com.jogamp.newt.event.KeyEvent.VK_SHIFT ||
1209
+ code == com.jogamp.newt.event.KeyEvent.VK_WINDOWS;
1218
1210
  }
1219
1211
 
1212
+
1220
1213
  // Why do we need this mapping?
1221
1214
  // Relevant discussion and links here:
1222
1215
  // http://forum.jogamp.org/Newt-wrong-keycode-for-key-td4033690.html#a4033697
@@ -1244,6 +1237,7 @@ public class PSurfaceJOGL implements PSurface {
1244
1237
  }
1245
1238
  }
1246
1239
 
1240
+
1247
1241
  private static boolean isHackyKey(short code) {
1248
1242
  switch (code) {
1249
1243
  case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE:
@@ -1256,6 +1250,7 @@ public class PSurfaceJOGL implements PSurface {
1256
1250
  return false;
1257
1251
  }
1258
1252
 
1253
+
1259
1254
  private static char hackToChar(short code, char def) {
1260
1255
  switch (code) {
1261
1256
  case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE:
@@ -1272,9 +1267,11 @@ public class PSurfaceJOGL implements PSurface {
1272
1267
  return def;
1273
1268
  }
1274
1269
 
1270
+
1275
1271
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1276
- class CursorInfo {
1277
1272
 
1273
+
1274
+ class CursorInfo {
1278
1275
  PImage image;
1279
1276
  int x, y;
1280
1277
 
@@ -1299,6 +1296,8 @@ public class PSurfaceJOGL implements PSurface {
1299
1296
  PConstants.TEXT, "text"
1300
1297
  );
1301
1298
 
1299
+
1300
+
1302
1301
  @Override
1303
1302
  public void setCursor(int kind) {
1304
1303
  if (!cursorNames.containsKey(kind)) {
@@ -1309,8 +1308,8 @@ public class PSurfaceJOGL implements PSurface {
1309
1308
  if (cursor == null) {
1310
1309
  String name = cursorNames.get(kind);
1311
1310
  if (name != null) {
1312
- ImageIcon icon
1313
- = new ImageIcon(getClass().getResource("cursors/" + name + ".png"));
1311
+ ImageIcon icon =
1312
+ new ImageIcon(getClass().getResource("cursors/" + name + ".png"));
1314
1313
  PImage img = new PImageAWT(icon.getImage());
1315
1314
  // Most cursors just use the center as the hotspot...
1316
1315
  int x = img.width / 2;
@@ -1343,11 +1342,12 @@ public class PSurfaceJOGL implements PSurface {
1343
1342
  }
1344
1343
  }
1345
1344
 
1345
+
1346
1346
  @Override
1347
1347
  public void setCursor(PImage image, int hotspotX, int hotspotY) {
1348
1348
  Display disp = window.getScreen().getDisplay();
1349
- BufferedImage bimg = (BufferedImage) image.getNative();
1350
- DataBufferInt dbuf = (DataBufferInt) bimg.getData().getDataBuffer();
1349
+ BufferedImage bimg = (BufferedImage)image.getNative();
1350
+ DataBufferInt dbuf = (DataBufferInt)bimg.getData().getDataBuffer();
1351
1351
  int[] ipix = dbuf.getData();
1352
1352
  ByteBuffer pixels = ByteBuffer.allocate(ipix.length * 4);
1353
1353
  pixels.asIntBuffer().put(ipix);
@@ -1361,6 +1361,7 @@ public class PSurfaceJOGL implements PSurface {
1361
1361
  });
1362
1362
  }
1363
1363
 
1364
+
1364
1365
  @Override
1365
1366
  public void showCursor() {
1366
1367
  display.getEDTUtil().invoke(false, () -> {
@@ -1368,6 +1369,7 @@ public class PSurfaceJOGL implements PSurface {
1368
1369
  });
1369
1370
  }
1370
1371
 
1372
+
1371
1373
  @Override
1372
1374
  public void hideCursor() {
1373
1375
  display.getEDTUtil().invoke(false, () -> {
@@ -1375,6 +1377,7 @@ public class PSurfaceJOGL implements PSurface {
1375
1377
  });
1376
1378
  }
1377
1379
 
1380
+
1378
1381
  @Override
1379
1382
  public boolean openLink(String url) {
1380
1383
  return ShimAWT.openLink(url);