picrate 1.3.0-java → 2.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  3. data/CHANGELOG.md +10 -1
  4. data/Gemfile +3 -1
  5. data/README.md +9 -6
  6. data/Rakefile +8 -3
  7. data/bin/picrate +3 -1
  8. data/docs/_config.yml +1 -1
  9. data/docs/_editors/geany.md +1 -0
  10. data/docs/_gems/gems/gems.md +1 -1
  11. data/docs/_methods/alternative_methods.md +2 -1
  12. data/docs/_posts/2018-05-06-getting_started.md +4 -4
  13. data/docs/_posts/2018-05-06-install_jruby.md +5 -11
  14. data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
  15. data/docs/_posts/2018-11-18-building-gem.md +2 -2
  16. data/docs/_posts/2018-11-27-getting_started_geany.md +1 -1
  17. data/docs/_posts/2019-11-11-getting_started_buster.md +3 -6
  18. data/docs/_posts/{2018-06-26-auto_install_picrate.md → 2020-03-09-auto_install_picrate.md} +9 -6
  19. data/docs/_posts/2020-05-11-getting_started_manjaro.md +106 -0
  20. data/docs/about.md +1 -1
  21. data/lib/picrate.rb +3 -2
  22. data/lib/picrate/app.rb +11 -3
  23. data/lib/picrate/creators/parameters.rb +8 -8
  24. data/lib/picrate/creators/sketch_factory.rb +5 -3
  25. data/lib/picrate/helper_methods.rb +22 -22
  26. data/lib/picrate/helpers/numeric.rb +2 -0
  27. data/lib/picrate/library.rb +5 -1
  28. data/lib/picrate/library_loader.rb +2 -0
  29. data/lib/picrate/native_folder.rb +2 -1
  30. data/lib/picrate/native_loader.rb +3 -0
  31. data/lib/picrate/runner.rb +5 -4
  32. data/lib/picrate/version.rb +1 -1
  33. data/library/boids/boids.rb +17 -8
  34. data/library/chooser/chooser.rb +10 -9
  35. data/library/color_group/color_group.rb +2 -0
  36. data/library/control_panel/control_panel.rb +7 -4
  37. data/library/dxf/dxf.rb +2 -0
  38. data/library/jcomplex/jcomplex.rb +1 -0
  39. data/library/library_proxy/library_proxy.rb +2 -0
  40. data/library/net/net.rb +2 -0
  41. data/library/slider/slider.rb +24 -23
  42. data/library/vector_utils/vector_utils.rb +4 -0
  43. data/library/video_event/video_event.rb +2 -0
  44. data/mvnw +2 -2
  45. data/mvnw.cmd +2 -2
  46. data/picrate.gemspec +13 -13
  47. data/pom.rb +26 -23
  48. data/pom.xml +19 -7
  49. data/src/main/java/monkstone/ColorUtil.java +1 -1
  50. data/src/main/java/monkstone/MathToolModule.java +1 -1
  51. data/src/main/java/monkstone/PicrateLibrary.java +8 -8
  52. data/src/main/java/monkstone/complex/JComplex.java +252 -0
  53. data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
  54. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  55. data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
  56. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  57. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  58. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
  59. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  60. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  61. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  62. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  63. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  64. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  65. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  66. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  67. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  68. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  69. data/src/main/java/processing/awt/PGraphicsJava2D.java +33 -36
  70. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  71. data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
  72. data/src/main/java/processing/awt/ShimAWT.java +545 -0
  73. data/src/main/java/processing/core/PApplet.java +699 -1523
  74. data/src/main/java/processing/core/PConstants.java +180 -180
  75. data/src/main/java/processing/core/PFont.java +2 -2
  76. data/src/main/java/processing/core/PGraphics.java +190 -176
  77. data/src/main/java/processing/core/PImage.java +1536 -1721
  78. data/src/main/java/processing/core/PMatrix.java +39 -39
  79. data/src/main/java/processing/core/PSurface.java +69 -103
  80. data/src/main/java/processing/core/PSurfaceNone.java +29 -0
  81. data/src/main/java/processing/core/PVector.java +2 -2
  82. data/src/main/java/processing/data/FloatDict.java +251 -284
  83. data/src/main/java/processing/data/TableRow.java +32 -32
  84. data/src/main/java/processing/dxf/RawDXF.java +3 -3
  85. data/src/main/java/processing/net/Client.java +1 -1
  86. data/src/main/java/processing/opengl/PGL.java +1016 -4132
  87. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +232 -176
  88. data/src/main/java/processing/opengl/PJOGL.java +374 -1526
  89. data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
  90. data/src/main/java/processing/opengl/PSurfaceJOGL.java +262 -147
  91. data/test/color_group_test.rb +4 -4
  92. data/test/deglut_spec_test.rb +2 -0
  93. data/test/helper_methods_test.rb +41 -13
  94. data/test/math_tool_test.rb +46 -37
  95. data/test/respond_to_test.rb +5 -3
  96. data/test/sketches/key_event.rb +2 -2
  97. data/test/sketches/library/my_library/my_library.rb +3 -0
  98. data/test/test_helper.rb +2 -0
  99. data/test/vecmath_spec_test.rb +30 -19
  100. data/vendors/Rakefile +33 -21
  101. data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
  102. metadata +27 -46
  103. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  104. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  105. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  106. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -3,7 +3,7 @@
3
3
  /*
4
4
  Part of the Processing project - http://processing.org
5
5
 
6
- Copyright (c) 2012-15 The Processing Foundation
6
+ Copyright (c) 2012-20 The Processing Foundation
7
7
  Copyright (c) 2004-12 Ben Fry and Casey Reas
8
8
  Copyright (c) 2001-04 Massachusetts Institute of Technology
9
9
 
@@ -24,48 +24,6 @@
24
24
 
25
25
  package processing.core;
26
26
 
27
- // dummy object for backwards compatibility, plus the select methods
28
- import java.awt.Frame;
29
-
30
- // before calling settings() to get displayWidth/Height
31
- import java.awt.DisplayMode;
32
- // handleSettings() and displayDensity()
33
- import java.awt.GraphicsDevice;
34
- import java.awt.GraphicsEnvironment;
35
- // used to present the fullScreen() warning about Spaces on OS X
36
- import javax.swing.JOptionPane;
37
-
38
- // inside runSketch() to warn users about headless
39
- import java.awt.HeadlessException;
40
- import java.awt.Toolkit;
41
-
42
- // used by loadImage()
43
- import java.awt.Image;
44
- import java.awt.color.ColorSpace;
45
- import java.awt.image.BufferedImage;
46
- import javax.imageio.ImageIO;
47
- // allows us to remove our own MediaTracker code
48
- import javax.swing.ImageIcon;
49
-
50
- // used by selectInput(), selectOutput(), selectFolder()
51
- import java.awt.EventQueue;
52
- import java.awt.FileDialog;
53
- import javax.swing.JFileChooser;
54
-
55
- // set the look and feel, if specified
56
- import javax.swing.UIManager;
57
-
58
- // used by link()
59
- import java.awt.Desktop;
60
-
61
- // used by desktopFile() method
62
- import javax.swing.filechooser.FileSystemView;
63
-
64
- // loadXML() error handling
65
- import javax.xml.parsers.ParserConfigurationException;
66
-
67
- import org.xml.sax.SAXException;
68
-
69
27
  import java.io.*;
70
28
  import java.lang.reflect.*;
71
29
  import java.net.*;
@@ -80,6 +38,13 @@ import java.util.concurrent.ThreadFactory;
80
38
  import java.util.regex.*;
81
39
  import java.util.zip.*;
82
40
 
41
+ // loadXML() error handling
42
+ import javax.xml.parsers.ParserConfigurationException;
43
+ import org.xml.sax.SAXException;
44
+
45
+ // TODO have this removed by 4.0 final
46
+ import processing.awt.ShimAWT;
47
+
83
48
  import processing.data.*;
84
49
  import processing.event.*;
85
50
  import processing.opengl.*;
@@ -87,34 +52,34 @@ import processing.opengl.*;
87
52
 
88
53
  /**
89
54
  * Base class for all sketches that use processing.core.
90
- * <p/>
55
+ *
91
56
  * The <A HREF="https://github.com/processing/processing/wiki/Window-Size-and-Full-Screen">
92
57
  * Window Size and Full Screen</A> page on the Wiki has useful information
93
58
  * about sizing, multiple displays, full screen, etc.
94
- * <p/>
59
+ *
95
60
  * Processing uses active mode rendering. All animation tasks happen on the
96
61
  * "Processing Animation Thread". The setup() and draw() methods are handled
97
62
  * by that thread, and events (like mouse movement and key presses, which are
98
63
  * fired by the event dispatch thread or EDT) are queued to be safely handled
99
64
  * at the end of draw().
100
- * <p/>
65
+ *
101
66
  * Starting with 3.0a6, blit operations are on the EDT, so as not to cause
102
67
  * GUI problems with Swing and AWT. In the case of the default renderer, the
103
68
  * sketch renders to an offscreen image, then the EDT is asked to bring that
104
69
  * image to the screen.
105
- * <p/>
70
+ *
106
71
  * For code that needs to run on the EDT, use EventQueue.invokeLater(). When
107
72
  * doing so, be careful to synchronize between that code and the Processing
108
73
  * animation thread. That is, you can't call Processing methods from the EDT
109
74
  * or at any random time from another thread. Use of a callback function or
110
75
  * the registerXxx() methods in PApplet can help ensure that your code doesn't
111
76
  * do something naughty.
112
- * <p/>
77
+ *
113
78
  * As of Processing 3.0, we have removed Applet as the base class for PApplet.
114
79
  * This means that we can remove lots of legacy code, however one downside is
115
80
  * that it's no longer possible (without extra code) to embed a PApplet into
116
81
  * another Java application.
117
- * <p/>
82
+ *
118
83
  * As of Processing 3.0, we have discontinued support for versions of Java
119
84
  * prior to 1.8. We don't have enough people to support it, and for a
120
85
  * project of our (tiny) size, we should be focusing on the future, rather
@@ -122,45 +87,38 @@ import processing.opengl.*;
122
87
  */
123
88
  public class PApplet implements PConstants {
124
89
  /** Full name of the Java version (i.e. 1.5.0_11). */
125
- static public final String javaVersionName =
90
+ static public final String JAVA_VERSION_NAME =
126
91
  System.getProperty("java.version");
127
92
 
128
- static public final int javaPlatform;
93
+ static public final int JAVA_PLATFORM;
129
94
  static {
130
- String version = javaVersionName;
131
- if (javaVersionName.startsWith("1.")) {
95
+ String version = JAVA_VERSION_NAME;
96
+ if (JAVA_VERSION_NAME.startsWith("1.")) {
132
97
  version = version.substring(2);
133
- javaPlatform = parseInt(version.substring(0, version.indexOf('.')));
98
+ JAVA_PLATFORM = parseInt(version.substring(0, version.indexOf('.')));
134
99
  } else {
135
100
  // Remove -xxx and .yyy from java.version (@see JEP-223)
136
- javaPlatform = parseInt(version.replaceAll("-.*","").replaceAll("\\..*",""));
101
+ JAVA_PLATFORM = parseInt(version.replaceAll("-.*","").replaceAll("\\..*",""));
137
102
  }
138
103
  }
139
104
 
140
105
  /**
141
- * Do not use; javaPlatform or javaVersionName are better options.
142
- * For instance, javaPlatform is useful when you need a number for
143
- * comparison, i.e. "if (javaPlatform >= 9)".
106
+ * Do not use; JAVA_PLATFORM or JAVA_VERSION_NAME are better options.
107
+ * For instance, JAVA_PLATFORM is useful when you need a number for
108
+ * comparison, i.e. "if (JAVA_PLATFORM >= 9)".
144
109
  */
145
110
  @Deprecated
146
- public static final float javaVersion = 1 + javaPlatform / 10f;
111
+ public static final float JAVA_VERSION = 1 + JAVA_PLATFORM / 10f;
147
112
 
148
113
  /**
149
- * Current platform in use, one of the
150
- * PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.
114
+ * Current platform in use, one of the PConstants WINDOWS, MACOS, LINUX or OTHER.
151
115
  */
152
116
  static public int platform;
153
117
 
154
118
  static {
155
- String osname = System.getProperty("os.name");
156
-
157
- if (osname.indexOf("Mac") != -1) {
158
- platform = MACOSX;
119
+ final String name = System.getProperty("os.name");
159
120
 
160
- } else if (osname.indexOf("Windows") != -1) {
161
- platform = WINDOWS;
162
-
163
- } else if (osname.equals("Linux")) { // true for the ibm vm
121
+ if (name.equals("Linux")) { // true for the ibm vm
164
122
  platform = LINUX;
165
123
 
166
124
  } else {
@@ -185,7 +143,7 @@ public class PApplet implements PConstants {
185
143
  * example, if the current screen resolution is 1024x768,
186
144
  * <b>displayWidth</b> is 1024 and <b>displayHeight</b> is 768. These
187
145
  * dimensions are useful when exporting full-screen applications.
188
- * <br /><br />
146
+ *
189
147
  * To ensure that the sketch takes over the entire screen, use "Present"
190
148
  * instead of "Run". Otherwise the window will still have a frame border
191
149
  * around it and not be placed in the upper corner of the screen. On Mac OS
@@ -202,7 +160,7 @@ public class PApplet implements PConstants {
202
160
  * example, if the current screen resolution is 1024x768,
203
161
  * <b>displayWidth</b> is 1024 and <b>displayHeight</b> is 768. These
204
162
  * dimensions are useful when exporting full-screen applications.
205
- * <br /><br />
163
+ *
206
164
  * To ensure that the sketch takes over the entire screen, use "Present"
207
165
  * instead of "Run". Otherwise the window will still have a frame border
208
166
  * around it and not be placed in the upper corner of the screen. On Mac OS
@@ -237,24 +195,6 @@ public class PApplet implements PConstants {
237
195
  static public final int DEFAULT_WIDTH = 100;
238
196
  static public final int DEFAULT_HEIGHT = 100;
239
197
 
240
- // /**
241
- // * Exception thrown when size() is called the first time.
242
- // * <p>
243
- // * This is used internally so that setup() is forced to run twice
244
- // * when the renderer is changed. This is the only way for us to handle
245
- // * invoking the new renderer while also in the midst of rendering.
246
- // */
247
- // static public class RendererChangeException extends RuntimeException { }
248
-
249
- /**
250
- * true if no size() command has been executed. This is used to wait until
251
- * a size has been set before placing in the window and showing it.
252
- */
253
- // public boolean defaultSize;
254
-
255
- // /** Storage for the current renderer size to avoid re-allocation. */
256
- // Dimension currentSize = new Dimension();
257
-
258
198
  /**
259
199
  * ( begin auto-generated from pixels.xml )
260
200
  *
@@ -265,8 +205,8 @@ public class PApplet implements PConstants {
265
205
  * values. The <b>index</b> value defines the position of a value within
266
206
  * the array. For example, the statement <b>color b = pixels[230]</b> will
267
207
  * set the variable <b>b</b> to be equal to the value at that location in
268
- * the array.<br />
269
- * <br />
208
+ * the array.
209
+ *
270
210
  * Before accessing this array, the data must loaded with the
271
211
  * <b>loadPixels()</b> function. After the array data has been modified,
272
212
  * the <b>updatePixels()</b> function must be run to update the changes.
@@ -281,6 +221,9 @@ public class PApplet implements PConstants {
281
221
  * @see PApplet#get(int, int, int, int)
282
222
  * @see PApplet#set(int, int, int)
283
223
  * @see PImage
224
+ * @see PApplet#pixelDensity(int)
225
+ * @see PApplet#pixelWidth
226
+ * @see PApplet#pixelHeight
284
227
  */
285
228
  public int[] pixels;
286
229
 
@@ -420,8 +363,8 @@ public class PApplet implements PConstants {
420
363
  * ( begin auto-generated from pmouseX.xml )
421
364
  *
422
365
  * The system variable <b>pmouseX</b> always contains the horizontal
423
- * position of the mouse in the frame previous to the current frame.<br />
424
- * <br />
366
+ * position of the mouse in the frame previous to the current frame.
367
+ *
425
368
  * You may find that <b>pmouseX</b> and <b>pmouseY</b> have different
426
369
  * values inside <b>draw()</b> and inside events like <b>mousePressed()</b>
427
370
  * and <b>mouseMoved()</b>. This is because they're used for different
@@ -578,7 +521,7 @@ public class PApplet implements PConstants {
578
521
  *
579
522
  * The system variable <b>key</b> always contains the value of the most
580
523
  * recent key on the keyboard that was used (either pressed or released).
581
- * <br/> <br/>
524
+ *
582
525
  * For non-ASCII keys, use the <b>keyCode</b> variable. The keys included
583
526
  * in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and
584
527
  * DELETE) do not require checking to see if they key is coded, and you
@@ -613,7 +556,7 @@ public class PApplet implements PConstants {
613
556
  * for these keys, it's first necessary to check and see if the key is
614
557
  * coded. This is done with the conditional "if (key == CODED)" as shown in
615
558
  * the example.
616
- * <br/> <br/>
559
+ *
617
560
  * The keys included in the ASCII specification (BACKSPACE, TAB, ENTER,
618
561
  * RETURN, ESC, and DELETE) do not require checking to see if they key is
619
562
  * coded, and you should simply use the <b>key</b> variable instead of
@@ -621,7 +564,7 @@ public class PApplet implements PConstants {
621
564
  * ENTER key is commonly used on PCs and Unix and the RETURN key is used
622
565
  * instead on Macintosh. Check for both ENTER and RETURN to make sure your
623
566
  * program will work for all platforms.
624
- * <br/> <br/>
567
+ *
625
568
  * For users familiar with Java, the values for UP and DOWN are simply
626
569
  * shorter versions of Java's KeyEvent.VK_UP and KeyEvent.VK_DOWN. Other
627
570
  * keyCode values can be found in the Java <a
@@ -751,6 +694,9 @@ public class PApplet implements PConstants {
751
694
  */
752
695
  protected boolean exitCalled;
753
696
 
697
+ // ok to be static because it's not possible to mix enabled/disabled
698
+ static protected boolean disableAWT;
699
+
754
700
  // messages to send if attached as an external vm
755
701
 
756
702
  /**
@@ -773,6 +719,9 @@ public class PApplet implements PConstants {
773
719
  /** Used by the PDE to suggest a display (set in prefs, passed on Run) */
774
720
  static public final String ARGS_DISPLAY = "--display";
775
721
 
722
+ /** Disable AWT so that LWJGL and others can run */
723
+ static public final String ARGS_DISABLE_AWT = "--disable-awt";
724
+
776
725
  // static public final String ARGS_SPAN_DISPLAYS = "--span";
777
726
 
778
727
  static public final String ARGS_BGCOLOR = "--bgcolor";
@@ -830,75 +779,11 @@ public class PApplet implements PConstants {
830
779
  }
831
780
 
832
781
 
833
- /**
834
- * A dummy frame to keep compatibility with 2.x code
835
- * and encourage users to update.
836
- */
837
- public Frame frame;
838
-
839
-
840
- // public Frame getFrame() {
841
- // return frame;
842
- // }
843
- //
844
- //
845
- // public void setFrame(Frame frame) {
846
- // this.frame = frame;
847
- // }
848
-
849
-
850
- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
851
-
852
-
853
782
  // /**
854
- // * Applet initialization. This can do GUI work because the components have
855
- // * not been 'realized' yet: things aren't visible, displayed, etc.
783
+ // * A dummy frame to keep compatibility with 2.x code
784
+ // * and encourage users to update.
856
785
  // */
857
- // public void init() {
858
- //// println("init() called " + Integer.toHexString(hashCode()));
859
- // // using a local version here since the class variable is deprecated
860
- //// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
861
- //// screenWidth = screen.width;
862
- //// screenHeight = screen.height;
863
- //
864
- // defaultSize = true;
865
- // finished = false; // just for clarity
866
- //
867
- // // this will be cleared by draw() if it is not overridden
868
- // looping = true;
869
- // redraw = true; // draw this guy at least once
870
- // firstMouse = true;
871
- //
872
- // // calculated dynamically on first call
873
- //// // Removed in 2.1.2, brought back for 2.1.3. Usually sketchPath is set
874
- //// // inside runSketch(), but if this sketch takes care of calls to init()
875
- //// // when PApplet.main() is not used (i.e. it's in a Java application).
876
- //// // THe path needs to be set here so that loadXxxx() functions work.
877
- //// if (sketchPath == null) {
878
- //// sketchPath = calcSketchPath();
879
- //// }
880
- //
881
- // // set during Surface.initFrame()
882
- //// // Figure out the available display width and height.
883
- //// // No major problem if this fails, we have to try again anyway in
884
- //// // handleDraw() on the first (== 0) frame.
885
- //// checkDisplaySize();
886
- //
887
- //// // Set the default size, until the user specifies otherwise
888
- //// int w = sketchWidth();
889
- //// int h = sketchHeight();
890
- //// defaultSize = (w == DEFAULT_WIDTH) && (h == DEFAULT_HEIGHT);
891
- ////
892
- //// g = makeGraphics(w, h, sketchRenderer(), null, true);
893
- //// // Fire component resize event
894
- //// setSize(w, h);
895
- //// setPreferredSize(new Dimension(w, h));
896
- ////
897
- //// width = g.width;
898
- //// height = g.height;
899
- //
900
- // surface.startThread();
901
- // }
786
+ // public Frame frame;
902
787
 
903
788
 
904
789
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -907,12 +792,11 @@ public class PApplet implements PConstants {
907
792
  boolean insideSettings;
908
793
 
909
794
  String renderer = JAVA2D;
910
- // int quality = 2;
911
795
  int smooth = 1; // default smoothing (whatever that means for the renderer)
912
796
 
913
797
  boolean fullScreen;
914
798
  int display = -1; // use default
915
- GraphicsDevice[] displayDevices;
799
+ // GraphicsDevice[] displayDevices;
916
800
  // Unlike the others above, needs to be public to support
917
801
  // the pixelWidth and pixelHeight fields.
918
802
  public int pixelDensity = 1;
@@ -954,73 +838,17 @@ public class PApplet implements PConstants {
954
838
  void handleSettings() {
955
839
  insideSettings = true;
956
840
 
957
- // Need the list of display devices to be queried already for usage below.
958
- // https://github.com/processing/processing/issues/3295
959
- // https://github.com/processing/processing/issues/3296
960
- // Not doing this from a static initializer because it may cause
961
- // PApplet to cache and the values to stick through subsequent runs.
962
- // Instead make it a runtime thing and a local variable.
963
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
964
- GraphicsDevice device = ge.getDefaultScreenDevice();
965
- displayDevices = ge.getScreenDevices();
966
-
967
- // Default or unparsed will be -1, spanning will be 0, actual displays will
968
- // be numbered from 1 because it's too weird to say "display 0" in prefs.
969
- if (display > 0 && display <= displayDevices.length) {
970
- device = displayDevices[display-1];
841
+ if (!disableAWT) {
842
+ displayWidth = ShimAWT.getDisplayWidth();
843
+ displayHeight = ShimAWT.getDisplayHeight();
844
+ } else {
845
+ // https://github.com/processing/processing4/issues/57
846
+ System.err.println("AWT disabled, displayWidth/displayHeight will be 0");
971
847
  }
972
- // Set displayWidth and displayHeight for people still using those.
973
- DisplayMode displayMode = device.getDisplayMode();
974
- displayWidth = displayMode.getWidth();
975
- displayHeight = displayMode.getHeight();
976
848
 
977
849
  // Here's where size(), fullScreen(), smooth(N) and noSmooth() might
978
850
  // be called, conjuring up the demons of various rendering configurations.
979
851
  settings();
980
-
981
- if (display == SPAN && platform == MACOSX) {
982
- // Make sure "Displays have separate Spaces" is unchecked
983
- // in System Preferences > Mission Control
984
- Process p = exec("defaults", "read", "com.apple.spaces", "spans-displays");
985
- BufferedReader outReader = createReader(p.getInputStream());
986
- BufferedReader errReader = createReader(p.getErrorStream());
987
- StringBuilder stdout = new StringBuilder();
988
- StringBuilder stderr = new StringBuilder();
989
- String line = null;
990
- try {
991
- while ((line = outReader.readLine()) != null) {
992
- stdout.append(line);
993
- }
994
- while ((line = errReader.readLine()) != null) {
995
- stderr.append(line);
996
- }
997
- } catch (IOException e) {
998
- printStackTrace(e);
999
- }
1000
-
1001
- int resultCode = -1;
1002
- try {
1003
- resultCode = p.waitFor();
1004
- } catch (InterruptedException e) { }
1005
-
1006
- String result = trim(stdout.toString());
1007
- if ("0".equals(result)) {
1008
- EventQueue.invokeLater(new Runnable() {
1009
- public void run() {
1010
- checkLookAndFeel();
1011
- final String msg =
1012
- "To use fullScreen(SPAN), first turn off “Displays have separate spaces”\n" +
1013
- "in System Preferences \u2192 Mission Control. Then log out and log back in.";
1014
- JOptionPane.showMessageDialog(null, msg, "Apple's Defaults Stink",
1015
- JOptionPane.WARNING_MESSAGE);
1016
- }
1017
- });
1018
- } else if (!"1".equals(result)) {
1019
- System.err.println("Could not check the status of “Displays have separate spaces.”");
1020
- System.err.format("Received message '%s' and result code %d.%n", trim(stderr.toString()), resultCode);
1021
- }
1022
- }
1023
-
1024
852
  insideSettings = false;
1025
853
  }
1026
854
 
@@ -1061,17 +889,6 @@ public class PApplet implements PConstants {
1061
889
  }
1062
890
 
1063
891
 
1064
- // Named quality instead of smooth to avoid people trying to set (or get)
1065
- // the current smooth level this way. Also that smooth(number) isn't really
1066
- // public or well-known API. It's specific to the capabilities of the
1067
- // rendering surface, and somewhat independent of whether the sketch is
1068
- // smoothing at any given time. It's also a bit like getFill() would return
1069
- // true/false for whether fill was enabled, getFillColor() would return the
1070
- // color itself. Or at least that's what I can recall at the moment. [fry]
1071
- // public int sketchQuality() {
1072
- // //return 2;
1073
- // return quality;
1074
- // }
1075
892
  // smoothing 1 is default.. 0 is none.. 2,4,8 depend on renderer
1076
893
  final public int sketchSmooth() {
1077
894
  return smooth;
@@ -1079,20 +896,10 @@ public class PApplet implements PConstants {
1079
896
 
1080
897
 
1081
898
  final public boolean sketchFullScreen() {
1082
- //return false;
1083
899
  return fullScreen;
1084
900
  }
1085
901
 
1086
902
 
1087
- // // Could be named 'screen' instead of display since it's the people using
1088
- // // full screen who will be looking for it. On the other hand, screenX/Y/Z
1089
- // // makes things confusing, and if 'displayIndex' exists...
1090
- // public boolean sketchSpanDisplays() {
1091
- // //return false;
1092
- // return spanDisplays;
1093
- // }
1094
-
1095
-
1096
903
  // Numbered from 1, SPAN (0) means all displays, -1 means the default display
1097
904
  final public int sketchDisplay() {
1098
905
  return display;
@@ -1100,13 +907,11 @@ public class PApplet implements PConstants {
1100
907
 
1101
908
 
1102
909
  final public String sketchOutputPath() {
1103
- //return null;
1104
910
  return outputPath;
1105
911
  }
1106
912
 
1107
913
 
1108
914
  final public OutputStream sketchOutputStream() {
1109
- //return null;
1110
915
  return outputStream;
1111
916
  }
1112
917
 
@@ -1141,8 +946,16 @@ public class PApplet implements PConstants {
1141
946
  if (display != SPAN && (fullScreen || present)) {
1142
947
  return displayDensity(display);
1143
948
  }
949
+
950
+ int displayCount = 0;
951
+ if (!disableAWT) {
952
+ displayCount = ShimAWT.getDisplayCount();
953
+ } else {
954
+ // https://github.com/processing/processing4/issues/57
955
+ System.err.println("display count needs to be implemented for non-AWT");
956
+ }
1144
957
  // walk through all displays, use 2 if any display is 2
1145
- for (int i = 0; i < displayDevices.length; i++) {
958
+ for (int i = 0; i < displayCount; i++) {
1146
959
  if (displayDensity(i+1) == 2) {
1147
960
  return 2;
1148
961
  }
@@ -1151,70 +964,37 @@ public class PApplet implements PConstants {
1151
964
  return 1;
1152
965
  }
1153
966
 
967
+
1154
968
  /**
1155
969
  * @param display the display number to check
970
+ * (1-indexed to match the Preferences dialog box)
1156
971
  */
1157
972
  public int displayDensity(int display) {
1158
- if (PApplet.platform == PConstants.MACOSX) {
1159
- // This should probably be reset each time there's a display change.
1160
- // A 5-minute search didn't turn up any such event in the Java 7 API.
1161
- // Also, should we use the Toolkit associated with the editor window?
1162
- final String javaVendor = System.getProperty("java.vendor");
1163
- if (javaVendor.contains("Oracle")) {
1164
- GraphicsDevice device;
1165
- GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
1166
-
1167
- if (display == -1) {
1168
- device = env.getDefaultScreenDevice();
1169
-
1170
- } else if (display == SPAN) {
1171
- throw new RuntimeException("displayDensity() only works with specific display numbers");
1172
-
1173
- } else {
1174
- GraphicsDevice[] devices = env.getScreenDevices();
1175
- if (display > 0 && display <= devices.length) {
1176
- device = devices[display - 1];
1177
- } else {
1178
- if (devices.length == 1) {
1179
- System.err.println("Only one display is currently known, use displayDensity(1).");
1180
- } else {
1181
- System.err.format("Your displays are numbered %d through %d, " +
1182
- "pass one of those numbers to displayDensity()%n", 1, devices.length);
1183
- }
1184
- throw new RuntimeException("Display " + display + " does not exist.");
1185
- }
1186
- }
1187
-
1188
- try {
1189
- Field field = device.getClass().getDeclaredField("scale");
1190
- if (field != null) {
1191
- field.setAccessible(true);
1192
- Object scale = field.get(device);
1193
-
1194
- if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
1195
- return 2;
1196
- }
1197
- }
1198
- } catch (Exception ignore) { }
1199
- }
1200
- } else if (PApplet.platform == PConstants.WINDOWS ||
1201
- PApplet.platform == PConstants.LINUX) {
1202
- if (suggestedDensity == -1) {
1203
- // TODO: detect and return DPI scaling using JNA; Windows has
1204
- // a system-wide value, not sure how it works on Linux
1205
- return 1;
1206
- } else if (suggestedDensity == 1 || suggestedDensity == 2) {
1207
- return suggestedDensity;
1208
- }
973
+ if (!disableAWT) {
974
+ return ShimAWT.getDisplayDensity(display);
1209
975
  }
1210
- return 1;
976
+ /*
977
+ if (display > 0 && display <= displayDevices.length) {
978
+ GraphicsConfiguration graphicsConfig =
979
+ displayDevices[display - 1].getDefaultConfiguration();
980
+ AffineTransform tx = graphicsConfig.getDefaultTransform();
981
+ return (int) Math.round(tx.getScaleX());
982
+ }
983
+
984
+ System.err.println("Display " + display + " does not exist, " +
985
+ "returning 1 for displayDensity(" + display + ")");
986
+ */
987
+ // https://github.com/processing/processing4/issues/57
988
+ System.err.println("displayDensity() unavailable because AWT is disabled");
989
+ return 1; // not the end of the world, so don't throw a RuntimeException
1211
990
  }
1212
991
 
1213
992
 
1214
993
  /**
1215
994
  * @webref environment
1216
995
  * @param density 1 or 2
1217
- *
996
+ * @see PApplet#pixelWidth
997
+ * @see PApplet#pixelHeight
1218
998
  */
1219
999
  public void pixelDensity(int density) {
1220
1000
  //println(density + " " + this.pixelDensity);
@@ -1317,7 +1097,7 @@ public class PApplet implements PConstants {
1317
1097
  * Called by the browser or applet viewer to inform this applet that it
1318
1098
  * should start its execution. It is called after the init method and
1319
1099
  * each time the applet is revisited in a Web page.
1320
- * <p/>
1100
+ *
1321
1101
  * Called explicitly via the first call to PApplet.paint(), because
1322
1102
  * PAppletGL needs to have a usable screen before getting things rolling.
1323
1103
  */
@@ -1333,7 +1113,7 @@ public class PApplet implements PConstants {
1333
1113
  /**
1334
1114
  * Called by the browser or applet viewer to inform
1335
1115
  * this applet that it should stop its execution.
1336
- * <p/>
1116
+ *
1337
1117
  * Unfortunately, there are no guarantees from the Java spec
1338
1118
  * when or if stop() will be called (i.e. on browser quit,
1339
1119
  * or when moving between web pages), and it's not always called.
@@ -1392,7 +1172,7 @@ public class PApplet implements PConstants {
1392
1172
  // * Called by the browser or applet viewer to inform this applet
1393
1173
  // * that it is being reclaimed and that it should destroy
1394
1174
  // * any resources that it has allocated.
1395
- // * <p/>
1175
+ // *
1396
1176
  // * destroy() supposedly gets called as the applet viewer
1397
1177
  // * is shutting down the applet. stop() is called
1398
1178
  // * first, and then destroy() to really get rid of things.
@@ -1425,6 +1205,7 @@ public class PApplet implements PConstants {
1425
1205
  Object[] emptyArgs = new Object[] { };
1426
1206
 
1427
1207
 
1208
+ @SuppressWarnings("unused")
1428
1209
  void handle() {
1429
1210
  handle(emptyArgs);
1430
1211
  }
@@ -1434,7 +1215,7 @@ public class PApplet implements PConstants {
1434
1215
  for (int i = 0; i < count; i++) {
1435
1216
  try {
1436
1217
  methods[i].invoke(objects[i], args);
1437
- } catch (Exception e) {
1218
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
1438
1219
  // check for wrapped exception, get root exception
1439
1220
  Throwable t;
1440
1221
  if (e instanceof InvocationTargetException) {
@@ -1571,13 +1352,13 @@ public class PApplet implements PConstants {
1571
1352
  die("There is no public " + name + "() method in the class " +
1572
1353
  o.getClass().getName());
1573
1354
 
1574
- } catch (Exception e) {
1355
+ } catch (SecurityException e) {
1575
1356
  die("Could not register " + name + " + () for " + o, e);
1576
1357
  }
1577
1358
  }
1578
1359
 
1579
1360
 
1580
- private void registerWithArgs(String name, Object o, Class<?> cargs[]) {
1361
+ private void registerWithArgs(String name, Object o, Class<?>[] cargs) {
1581
1362
  Class<?> c = o.getClass();
1582
1363
  try {
1583
1364
  Method method = c.getMethod(name, cargs);
@@ -1593,7 +1374,7 @@ public class PApplet implements PConstants {
1593
1374
  die("There is no public " + name + "() method in the class " +
1594
1375
  o.getClass().getName());
1595
1376
 
1596
- } catch (Exception e) {
1377
+ } catch (SecurityException e) {
1597
1378
  die("Could not register " + name + " + () for " + o, e);
1598
1379
  }
1599
1380
  }
@@ -1611,8 +1392,6 @@ public class PApplet implements PConstants {
1611
1392
  die("No registered methods with the name " + name + "() were found.");
1612
1393
  }
1613
1394
  try {
1614
- // Method method = o.getClass().getMethod(name, new Class[] {});
1615
- // meth.remove(o, method);
1616
1395
  meth.remove(target);
1617
1396
  } catch (Exception e) {
1618
1397
  die("Could not unregister " + name + "() for " + target, e);
@@ -1620,18 +1399,7 @@ public class PApplet implements PConstants {
1620
1399
  }
1621
1400
  }
1622
1401
 
1623
-
1624
- protected void handleMethods(String methodName) {
1625
- synchronized (registerLock) {
1626
- RegisteredMethods meth = registerMap.get(methodName);
1627
- if (meth != null) {
1628
- meth.handle();
1629
- }
1630
- }
1631
- }
1632
-
1633
-
1634
- protected void handleMethods(String methodName, Object[] args) {
1402
+ protected void handleMethods(String methodName, Object...args) {
1635
1403
  synchronized (registerLock) {
1636
1404
  RegisteredMethods meth = registerMap.get(methodName);
1637
1405
  if (meth != null) {
@@ -1939,41 +1707,41 @@ public class PApplet implements PConstants {
1939
1707
  * <b>size()</b> function must be the first line in <b>setup()</b>. If
1940
1708
  * <b>size()</b> is not used, the default size of the window is 100x100
1941
1709
  * pixels. The system variables <b>width</b> and <b>height</b> are set by
1942
- * the parameters passed to this function.<br />
1943
- * <br />
1710
+ * the parameters passed to this function.
1711
+ *
1944
1712
  * Do not use variables as the parameters to <b>size()</b> function,
1945
1713
  * because it will cause problems when exporting your sketch. When
1946
1714
  * variables are used, the dimensions of your sketch cannot be determined
1947
1715
  * during export. Instead, employ numeric values in the <b>size()</b>
1948
1716
  * statement, and then use the built-in <b>width</b> and <b>height</b>
1949
1717
  * variables inside your program when the dimensions of the display window
1950
- * are needed.<br />
1951
- * <br />
1718
+ * are needed.
1719
+ *
1952
1720
  * The <b>size()</b> function can only be used once inside a sketch, and
1953
- * cannot be used for resizing.<br/>
1954
- * <br/> <b>renderer</b> parameter selects which rendering engine to use.
1721
+ * cannot be used for resizing.
1722
+ * <b>renderer</b> parameter selects which rendering engine to use.
1955
1723
  * For example, if you will be drawing 3D shapes, use <b>P3D</b>, if you
1956
1724
  * want to export images from a program as a PDF file use <b>PDF</b>. A
1957
- * brief description of the three primary renderers follows:<br />
1958
- * <br />
1725
+ * brief description of the three primary renderers follows:
1726
+ *
1959
1727
  * <b>P2D</b> (Processing 2D) - The default renderer that supports two
1960
- * dimensional drawing.<br />
1961
- * <br />
1728
+ * dimensional drawing.
1729
+ *
1962
1730
  * <b>P3D</b> (Processing 3D) - 3D graphics renderer that makes use of
1963
- * OpenGL-compatible graphics hardware.<br />
1964
- * <br />
1731
+ * OpenGL-compatible graphics hardware.
1732
+ *
1965
1733
  * <b>PDF</b> - The PDF renderer draws 2D graphics directly to an Acrobat
1966
1734
  * PDF file. This produces excellent results when you need vector shapes
1967
1735
  * for high resolution output or printing. You must first use Import
1968
1736
  * Library &rarr; PDF to make use of the library. More information can be
1969
- * found in the PDF library reference.<br />
1970
- * <br />
1737
+ * found in the PDF library reference.
1738
+ *
1971
1739
  * The P3D renderer doesn't support <b>strokeCap()</b> or
1972
1740
  * <b>strokeJoin()</b>, which can lead to ugly results when using
1973
1741
  * <b>strokeWeight()</b>. (<a
1974
1742
  * href="http://code.google.com/p/processing/issues/detail?id=123">Issue
1975
- * 123</a>) <br />
1976
- * <br />
1743
+ * 123</a>)
1744
+ *
1977
1745
  * The maximum width and height is limited by your operating system, and is
1978
1746
  * usually the width and height of your actual screen. On some machines it
1979
1747
  * may simply be the number of pixels on your current screen, meaning that
@@ -1981,8 +1749,8 @@ public class PApplet implements PConstants {
1981
1749
  * same number of pixels. This varies widely so you'll have to try
1982
1750
  * different rendering modes and sizes until you get what you're looking
1983
1751
  * for. If you need something larger, use <b>createGraphics</b> to create a
1984
- * non-visible drawing surface.<br />
1985
- * <br />
1752
+ * non-visible drawing surface.
1753
+ *
1986
1754
  * Again, the <b>size()</b> function must be the first line of the code (or
1987
1755
  * first item inside setup). Any code that appears before the <b>size()</b>
1988
1756
  * command may run more than once, which can lead to confusing results.
@@ -2004,6 +1772,9 @@ public class PApplet implements PConstants {
2004
1772
  * @param height height of the display window in units of pixels
2005
1773
  * @see PApplet#width
2006
1774
  * @see PApplet#height
1775
+ * @see PApplet#setup()
1776
+ * @see PApplet#settings()
1777
+ * @see PApplet#fullScreen()
2007
1778
  */
2008
1779
  public void size(int width, int height) {
2009
1780
  // Check to make sure the width/height have actually changed. It's ok to
@@ -2133,12 +1904,12 @@ public class PApplet implements PConstants {
2133
1904
  * P3D. Use this class if you need to draw into an off-screen graphics
2134
1905
  * buffer. The PDF renderer requires the filename parameter. The DXF
2135
1906
  * renderer should not be used with <b>createGraphics()</b>, it's only
2136
- * built for use with <b>beginRaw()</b> and <b>endRaw()</b>.<br />
2137
- * <br />
1907
+ * built for use with <b>beginRaw()</b> and <b>endRaw()</b>.
1908
+ *
2138
1909
  * It's important to call any drawing functions between <b>beginDraw()</b>
2139
1910
  * and <b>endDraw()</b> statements. This is also true for any functions
2140
- * that affect drawing, such as <b>smooth()</b> or <b>colorMode()</b>.<br/>
2141
- * <br/> the main drawing surface which is completely opaque, surfaces
1911
+ * that affect drawing, such as <b>smooth()</b> or <b>colorMode()</b>.
1912
+ * the main drawing surface which is completely opaque, surfaces
2142
1913
  * created with <b>createGraphics()</b> can have transparency. This makes
2143
1914
  * it possible to draw into a graphics and maintain the alpha channel. By
2144
1915
  * using <b>save()</b> to write a PNG or TGA file, the transparency of the
@@ -2259,7 +2030,7 @@ public class PApplet implements PConstants {
2259
2030
  Class<?> rendererClass =
2260
2031
  Thread.currentThread().getContextClassLoader().loadClass(renderer);
2261
2032
 
2262
- Constructor<?> constructor = rendererClass.getConstructor(new Class[] { });
2033
+ Constructor<?> constructor = rendererClass.getConstructor();
2263
2034
  PGraphics pg = (PGraphics) constructor.newInstance();
2264
2035
 
2265
2036
  pg.setParent(this);
@@ -2351,10 +2122,10 @@ public class PApplet implements PConstants {
2351
2122
  * fresh buffer of pixels to play with. Set the size of the buffer with the
2352
2123
  * <b>width</b> and <b>height</b> parameters. The <b>format</b> parameter
2353
2124
  * defines how the pixels are stored. See the PImage reference for more information.
2354
- * <br/> <br/>
2125
+ *
2355
2126
  * Be sure to include all three parameters, specifying only the width and
2356
2127
  * height (but no format) will produce a strange error.
2357
- * <br/> <br/>
2128
+ *
2358
2129
  * Advanced users please note that createImage() should be used instead of
2359
2130
  * the syntax <tt>new PImage()</tt>.
2360
2131
  *
@@ -2530,11 +2301,11 @@ public class PApplet implements PConstants {
2530
2301
  * the program to update the display window only when necessary, for
2531
2302
  * example when an event registered by <b>mousePressed()</b> or
2532
2303
  * <b>keyPressed()</b> occurs.
2533
- * <br/><br/> structuring a program, it only makes sense to call redraw()
2304
+ * structuring a program, it only makes sense to call redraw()
2534
2305
  * within events such as <b>mousePressed()</b>. This is because
2535
2306
  * <b>redraw()</b> does not run <b>draw()</b> immediately (it only sets a
2536
2307
  * flag that indicates an update is needed).
2537
- * <br/><br/> <b>redraw()</b> within <b>draw()</b> has no effect because
2308
+ * <b>redraw()</b> within <b>draw()</b> has no effect because
2538
2309
  * <b>draw()</b> is continuously called anyway.
2539
2310
  *
2540
2311
  * ( end auto-generated )
@@ -2588,7 +2359,7 @@ public class PApplet implements PConstants {
2588
2359
  * <b>draw()</b>. If <b>loop()</b> is called, the code in <b>draw()</b>
2589
2360
  * begin to run continuously again. If using <b>noLoop()</b> in
2590
2361
  * <b>setup()</b>, it should be the last line inside the block.
2591
- * <br/> <br/>
2362
+ *
2592
2363
  * When <b>noLoop()</b> is used, it's not possible to manipulate or access
2593
2364
  * the screen inside event handling functions such as <b>mousePressed()</b>
2594
2365
  * or <b>keyPressed()</b>. Instead, use those functions to call
@@ -2596,7 +2367,7 @@ public class PApplet implements PConstants {
2596
2367
  * can update the screen properly. This means that when noLoop() has been
2597
2368
  * called, no drawing can happen, and functions like saveFrame() or
2598
2369
  * loadPixels() may not be used.
2599
- * <br/> <br/>
2370
+ *
2600
2371
  * Note that if the sketch is resized, <b>redraw()</b> will be called to
2601
2372
  * update the sketch, even after <b>noLoop()</b> has been specified.
2602
2373
  * Otherwise, the sketch would enter an odd state until <b>loop()</b> was called.
@@ -2688,23 +2459,6 @@ public class PApplet implements PConstants {
2688
2459
 
2689
2460
  int button = event.getButton();
2690
2461
 
2691
- // If running on Mac OS, allow ctrl-click as right mouse.
2692
- if (PApplet.platform == PConstants.MACOSX && event.getButton() == PConstants.LEFT) {
2693
- if (action == MouseEvent.PRESS && event.isControlDown()) {
2694
- macosxLeftButtonWithCtrlPressed = true;
2695
- }
2696
- if (macosxLeftButtonWithCtrlPressed) {
2697
- button = PConstants.RIGHT;
2698
- event = new MouseEvent(event.getNative(), event.getMillis(),
2699
- event.getAction(), event.getModifiers(),
2700
- event.getX(), event.getY(),
2701
- button, event.getCount());
2702
- }
2703
- if (action == MouseEvent.RELEASE) {
2704
- macosxLeftButtonWithCtrlPressed = false;
2705
- }
2706
- }
2707
-
2708
2462
  // Get the (already processed) button code
2709
2463
  mouseButton = button;
2710
2464
 
@@ -2743,7 +2497,7 @@ public class PApplet implements PConstants {
2743
2497
  break;
2744
2498
  }
2745
2499
 
2746
- handleMethods("mouseEvent", new Object[] { event });
2500
+ handleMethods("mouseEvent", event);
2747
2501
 
2748
2502
  switch (action) {
2749
2503
  case MouseEvent.PRESS:
@@ -3015,7 +2769,7 @@ public class PApplet implements PConstants {
3015
2769
  }
3016
2770
  */
3017
2771
 
3018
- handleMethods("keyEvent", new Object[] { event });
2772
+ handleMethods("keyEvent", event);
3019
2773
 
3020
2774
  // if someone else wants to intercept the key, they should
3021
2775
  // set key to zero (or something besides the ESC).
@@ -3024,21 +2778,6 @@ public class PApplet implements PConstants {
3024
2778
  if (key == ESC) {
3025
2779
  exit();
3026
2780
  }
3027
- // When running tethered to the Processing application, respond to
3028
- // Ctrl-W (or Cmd-W) events by closing the sketch. Not enabled when
3029
- // running independently, because this sketch may be one component
3030
- // embedded inside an application that has its own close behavior.
3031
- if (external &&
3032
- event.getKeyCode() == 'W' &&
3033
- ((event.isMetaDown() && platform == MACOSX) ||
3034
- (event.isControlDown() && platform != MACOSX))) {
3035
- // Can't use this native stuff b/c the native event might be NEWT
3036
- // if (external && event.getNative() instanceof java.awt.event.KeyEvent &&
3037
- // ((java.awt.event.KeyEvent) event.getNative()).getModifiers() ==
3038
- // Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() &&
3039
- // event.getKeyCode() == 'W') {
3040
- exit();
3041
- }
3042
2781
  }
3043
2782
  }
3044
2783
 
@@ -3049,7 +2788,7 @@ public class PApplet implements PConstants {
3049
2788
  *
3050
2789
  * The <b>keyPressed()</b> function is called once every time a key is
3051
2790
  * pressed. The key that was pressed is stored in the <b>key</b> variable.
3052
- * <br/> <br/>
2791
+ *
3053
2792
  * For non-ASCII keys, use the <b>keyCode</b> variable. The keys included
3054
2793
  * in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and
3055
2794
  * DELETE) do not require checking to see if they key is coded, and you
@@ -3058,7 +2797,7 @@ public class PApplet implements PConstants {
3058
2797
  * commonly used on PCs and Unix and the RETURN key is used instead on
3059
2798
  * Macintosh. Check for both ENTER and RETURN to make sure your program
3060
2799
  * will work for all platforms.
3061
- * <br/> <br/>
2800
+ *
3062
2801
  * Because of how operating systems handle key repeats, holding down a key
3063
2802
  * may cause multiple calls to keyPressed() (and keyReleased() as well).
3064
2803
  * The rate of repeat is set by the operating system and how each computer
@@ -3431,17 +3170,9 @@ public class PApplet implements PConstants {
3431
3170
  * @param url the complete URL, as a String in quotes
3432
3171
  */
3433
3172
  public void link(String url) {
3434
- try {
3435
- if (Desktop.isDesktopSupported()) {
3436
- Desktop.getDesktop().browse(new URI(url));
3437
- } else {
3438
- // Just pass it off to open() and hope for the best
3439
- launch(url);
3440
- }
3441
- } catch (IOException e) {
3442
- printStackTrace(e);
3443
- } catch (URISyntaxException e) {
3444
- printStackTrace(e);
3173
+ if (!surface.openLink(url)) {
3174
+ // Just pass it off to launch() and hope for the best
3175
+ launch(url);
3445
3176
  }
3446
3177
  }
3447
3178
 
@@ -3458,25 +3189,25 @@ public class PApplet implements PConstants {
3458
3189
  * of an executable in the system's PATH. In most cases, using a full path
3459
3190
  * is the best option, rather than relying on the system PATH. Be sure to
3460
3191
  * make the file executable before attempting to open it (chmod +x).
3461
- * <br/> <br/>
3192
+ *
3462
3193
  * The <b>args</b> parameter is a String or String array which is passed to
3463
3194
  * the command line. If you have multiple parameters, e.g. an application
3464
3195
  * and a document, or a command with multiple switches, use the version
3465
3196
  * that takes a String array, and place each individual item in a separate
3466
3197
  * element.
3467
- * <br/> <br/>
3198
+ *
3468
3199
  * If args is a String (not an array), then it can only be a single file or
3469
3200
  * application with no parameters. It's not the same as executing that
3470
3201
  * String using a shell. For instance, launch("javac -help") will not work
3471
3202
  * properly.
3472
- * <br/> <br/>
3203
+ *
3473
3204
  * This function behaves differently on each platform. On Windows, the
3474
3205
  * parameters are sent to the Windows shell via "cmd /c". On Mac OS X, the
3475
3206
  * "open" command is used (type "man open" in Terminal.app for
3476
3207
  * documentation). On Linux, it first tries gnome-open, then kde-open, but
3477
3208
  * if neither are available, it sends the command to the shell without any
3478
3209
  * alterations.
3479
- * <br/> <br/>
3210
+ *
3480
3211
  * For users familiar with Java, this is not quite the same as
3481
3212
  * Runtime.exec(), because the launcher command is prepended. Instead, the
3482
3213
  * <b>exec(String[])</b> function is a shortcut for
@@ -3490,17 +3221,7 @@ public class PApplet implements PConstants {
3490
3221
  static public Process launch(String... args) {
3491
3222
  String[] params = null;
3492
3223
 
3493
- if (platform == WINDOWS) {
3494
- // just launching the .html file via the shell works
3495
- // but make sure to chmod +x the .html files first
3496
- // also place quotes around it in case there's a space
3497
- // in the user.dir part of the url
3498
- params = new String[] { "cmd", "/c" };
3499
-
3500
- } else if (platform == MACOSX) {
3501
- params = new String[] { "open" };
3502
-
3503
- } else if (platform == LINUX) {
3224
+ if (platform == LINUX) {
3504
3225
  // xdg-open is in the Free Desktop Specification and really should just
3505
3226
  // work on desktop Linux. Not risking it though.
3506
3227
  final String[] launchers = { "xdg-open", "gnome-open", "kde-open" };
@@ -3511,7 +3232,7 @@ public class PApplet implements PConstants {
3511
3232
  /*int result =*/ p.waitFor();
3512
3233
  // Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3513
3234
  openLauncher = launcher;
3514
- } catch (Exception e) { }
3235
+ } catch (IOException | InterruptedException e) { }
3515
3236
  }
3516
3237
  if (openLauncher == null) {
3517
3238
  System.err.println("Could not find xdg-open, gnome-open, or kde-open: " +
@@ -3755,12 +3476,12 @@ public class PApplet implements PConstants {
3755
3476
  * Quits/stops/exits the program. Programs without a <b>draw()</b> function
3756
3477
  * exit automatically after the last line has run, but programs with
3757
3478
  * <b>draw()</b> run continuously until the program is manually stopped or
3758
- * <b>exit()</b> is run.<br />
3759
- * <br />
3479
+ * <b>exit()</b> is run.
3480
+ *
3760
3481
  * Rather than terminating immediately, <b>exit()</b> will cause the sketch
3761
3482
  * to exit after <b>draw()</b> has completed (or after <b>setup()</b>
3762
- * completes if called during the <b>setup()</b> function).<br />
3763
- * <br />
3483
+ * completes if called during the <b>setup()</b> function).
3484
+ *
3764
3485
  * For Java programmers, this is <em>not</em> the same as System.exit().
3765
3486
  * Further, System.exit() should not be used because closing out an
3766
3487
  * application while <b>draw()</b> is running may cause a crash
@@ -3833,17 +3554,6 @@ public class PApplet implements PConstants {
3833
3554
  // run dispose() methods registered by libraries
3834
3555
  handleMethods("dispose");
3835
3556
  }
3836
-
3837
- if (platform == MACOSX) {
3838
- try {
3839
- final String td = "processing.core.ThinkDifferent";
3840
- final Class<?> thinkDifferent = getClass().getClassLoader().loadClass(td);
3841
- thinkDifferent.getMethod("cleanup").invoke(null);
3842
- } catch (Exception e) {
3843
- e.printStackTrace();
3844
- }
3845
- }
3846
-
3847
3557
  }
3848
3558
 
3849
3559
 
@@ -3853,15 +3563,15 @@ public class PApplet implements PConstants {
3853
3563
 
3854
3564
  /**
3855
3565
  * Call a method in the current class based on its name.
3856
- * <p/>
3566
+ *
3857
3567
  * Note that the function being called must be public. Inside the PDE,
3858
3568
  * 'public' is automatically added, but when used without the preprocessor,
3859
3569
  * (like from Eclipse) you'll have to do it yourself.
3860
3570
  */
3861
3571
  public void method(String name) {
3862
3572
  try {
3863
- Method method = getClass().getMethod(name, new Class[] {});
3864
- method.invoke(this, new Object[] { });
3573
+ Method method = getClass().getMethod(name);
3574
+ method.invoke(this);
3865
3575
 
3866
3576
  } catch (IllegalArgumentException e) {
3867
3577
  e.printStackTrace();
@@ -3882,7 +3592,7 @@ public class PApplet implements PConstants {
3882
3592
  * Launch a new thread and call the specified function from that new thread.
3883
3593
  * This is a very simple way to do a thread without needing to get into
3884
3594
  * classes, runnables, etc.
3885
- * <p/>
3595
+ *
3886
3596
  * Note that the function being called must be public. Inside the PDE,
3887
3597
  * 'public' is automatically added, but when used without the preprocessor,
3888
3598
  * (like from Eclipse) you'll have to do it yourself.
@@ -3896,13 +3606,7 @@ public class PApplet implements PConstants {
3896
3606
  * @see PApplet#noLoop()
3897
3607
  */
3898
3608
  public void thread(final String name) {
3899
- Thread later = new Thread() {
3900
- @Override
3901
- public void run() {
3902
- method(name);
3903
- }
3904
- };
3905
- later.start();
3609
+ new Thread(() -> method(name)).start();
3906
3610
  }
3907
3611
 
3908
3612
 
@@ -3924,7 +3628,7 @@ public class PApplet implements PConstants {
3924
3628
  * which may be opened by selecting "Show sketch folder" from the "Sketch"
3925
3629
  * menu. It is not possible to use <b>save()</b> while running the program
3926
3630
  * in a web browser.
3927
- * <br/> images saved from the main drawing window will be opaque. To save
3631
+ * images saved from the main drawing window will be opaque. To save
3928
3632
  * images without a background, use <b>createGraphics()</b>.
3929
3633
  *
3930
3634
  * ( end auto-generated )
@@ -3964,14 +3668,14 @@ public class PApplet implements PConstants {
3964
3668
  * sequences can be loaded into programs such as Apple's QuickTime software
3965
3669
  * and made into movies. These files are saved to the sketch's folder,
3966
3670
  * which may be opened by selecting "Show sketch folder" from the "Sketch"
3967
- * menu.<br />
3968
- * <br />
3671
+ * menu.
3672
+ *
3969
3673
  * It is not possible to use saveXxxxx() functions inside a web browser
3970
3674
  * unless the sketch is <a
3971
3675
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
3972
3676
  * save a file back to a server, see the <a
3973
3677
  * href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to
3974
- * web</A> code snippet on the Processing Wiki.<br/>
3678
+ * web</A> code snippet on the Processing Wiki.
3975
3679
  * <br/ >
3976
3680
  * All images saved from the main drawing window will be opaque. To save
3977
3681
  * images without a background, use <b>createGraphics()</b>.
@@ -4049,7 +3753,7 @@ public class PApplet implements PConstants {
4049
3753
  * to load an image as the cursor if you are exporting your program for the
4050
3754
  * Web and not all MODES work with all Web browsers. The values for
4051
3755
  * parameters <b>x</b> and <b>y</b> must be less than the dimensions of the image.
4052
- * <br /> <br />
3756
+ *
4053
3757
  * Setting or hiding the cursor generally does not work with "Present" mode
4054
3758
  * (when running full-screen).
4055
3759
  *
@@ -4110,15 +3814,15 @@ public class PApplet implements PConstants {
4110
3814
  * helpful for looking at the data a program is producing. The companion
4111
3815
  * function <b>println()</b> works like <b>print()</b>, but creates a new
4112
3816
  * line of text for each call to the function. Individual elements can be
4113
- * separated with quotes ("") and joined with the addition operator (+).<br />
4114
- * <br />
3817
+ * separated with quotes ("") and joined with the addition operator (+).
3818
+ *
4115
3819
  * Beginning with release 0125, to print the contents of an array, use
4116
3820
  * println(). There's no sensible way to do a <b>print()</b> of an array,
4117
3821
  * because there are too many possibilities for how to separate the data
4118
3822
  * (spaces, commas, etc). If you want to print an array as a single line,
4119
3823
  * use <b>join()</b>. With <b>join()</b>, you can choose any delimiter you
4120
- * like and <b>print()</b> the result.<br />
4121
- * <br />
3824
+ * like and <b>print()</b> the result.
3825
+ *
4122
3826
  * Using <b>print()</b> on an object will output <b>null</b>, a memory
4123
3827
  * location that may look like "@10be08," or the result of the
4124
3828
  * <b>toString()</b> method from the object that's being printed. Advanced
@@ -4213,7 +3917,7 @@ public class PApplet implements PConstants {
4213
3917
  * to this function creates a new line of output. Individual elements can
4214
3918
  * be separated with quotes ("") and joined with the string concatenation
4215
3919
  * operator (+). See <b>print()</b> for more about what to expect in the output.
4216
- * <br/><br/> <b>println()</b> on an array (by itself) will write the
3920
+ * <b>println()</b> on an array (by itself) will write the
4217
3921
  * contents of the array to the console. This is often helpful for looking
4218
3922
  * at the data a program is producing. A new line is put between each
4219
3923
  * element of the array. This function can only print one dimensional
@@ -5023,9 +4727,9 @@ public class PApplet implements PConstants {
5023
4727
  * ( begin auto-generated from norm.xml )
5024
4728
  *
5025
4729
  * Normalizes a number from another range into a value between 0 and 1.
5026
- * <br/> <br/>
4730
+ *
5027
4731
  * Identical to map(value, low, high, 0, 1);
5028
- * <br/> <br/>
4732
+ *
5029
4733
  * Numbers outside the range are not clamped to 0 and 1, because
5030
4734
  * out-of-range values are often intentional and useful.
5031
4735
  *
@@ -5048,7 +4752,7 @@ public class PApplet implements PConstants {
5048
4752
  * the number '25' is converted from a value in the range 0..100 into
5049
4753
  * a value that ranges from the left edge (0) to the right edge (width)
5050
4754
  * of the screen.
5051
- * <br/> <br/>
4755
+ *
5052
4756
  * Numbers outside the range are not clamped to 0 and 1, because
5053
4757
  * out-of-range values are often intentional and useful.
5054
4758
  *
@@ -5258,11 +4962,12 @@ public class PApplet implements PConstants {
5258
4962
  /**
5259
4963
  * ( begin auto-generated from noise.xml )
5260
4964
  *
5261
- * Returns the Perlin noise value at specified coordinates.Perlin noise is
5262
- a random sequence generator producing a more natural ordered, harmonic
5263
- succession of numbers compared to the standard <b>random()</b> function. It was invented by Ken Perlin in the 1980s and been used since in
5264
- graphical applications to produce procedural textures, natural motion,
5265
- shapes, terrains etc.<br /><br /> The main difference to the
4965
+ * Returns the Perlin noise value at specified coordinates. Perlin noise is
4966
+ * a random sequence generator producing a more natural ordered, harmonic
4967
+ * succession of numbers compared to the standard <b>random()</b> function.
4968
+ * It was invented by Ken Perlin in the 1980s and been used since in
4969
+ * graphical applications to produce procedural textures, natural motion,
4970
+ * shapes, terrains etc. The main difference to the
5266
4971
  * <b>random()</b> function is that Perlin noise is defined in an infinite
5267
4972
  * n-dimensional space where each pair of coordinates corresponds to a
5268
4973
  * fixed semi-random value (fixed only for the lifespan of the program).
@@ -5270,11 +4975,11 @@ public class PApplet implements PConstants {
5270
4975
  * compute 1D, 2D and 3D noise, depending on the number of coordinates
5271
4976
  * given. The noise value can be animated by moving through the noise space
5272
4977
  * as demonstrated in the example above. The 2nd and 3rd dimension can also
5273
- * be interpreted as time.<br /><br />The actual noise is structured
4978
+ * be interpreted as time.The actual noise is structured
5274
4979
  * similar to an audio signal, in respect to the function's use of
5275
4980
  * frequencies. Similar to the concept of harmonics in physics, perlin
5276
4981
  * noise is computed over several octaves which are added together for the
5277
- * final result. <br /><br />Another way to adjust the character of the
4982
+ * final result. Another way to adjust the character of the
5278
4983
  * resulting sequence is the scale of the input coordinates. As the
5279
4984
  * function works within an infinite space the value of the coordinates
5280
4985
  * doesn't matter as such, only the distance between successive coordinates
@@ -5285,7 +4990,6 @@ public class PApplet implements PConstants {
5285
4990
  *
5286
4991
  * ( end auto-generated )
5287
4992
  *
5288
- * @return
5289
4993
  * @webref math:random
5290
4994
  * @param x x-coordinate in noise space
5291
4995
  * @param y y-coordinate in noise space
@@ -5306,7 +5010,7 @@ public class PApplet implements PConstants {
5306
5010
  // [toxi 031112]
5307
5011
  // noise broke due to recent change of cos table in PGraphics
5308
5012
  // this will take care of it
5309
- perlin_cosTable = PGraphics.COS_LUT;
5013
+ perlin_cosTable = PGraphics.cosLUT;
5310
5014
  perlin_TWOPI = perlin_PI = PGraphics.SINCOS_LENGTH;
5311
5015
  perlin_PI >>= 1;
5312
5016
  }
@@ -5361,7 +5065,7 @@ public class PApplet implements PConstants {
5361
5065
  }
5362
5066
 
5363
5067
  // [toxi 031112]
5364
- // now adjusts to the size of the COS_LUT used via
5068
+ // now adjusts to the size of the cosLUT used via
5365
5069
  // the new variables, defined above
5366
5070
  private float noise_fsc(float i) {
5367
5071
  // using bagel's cosine table instead
@@ -5387,7 +5091,7 @@ public class PApplet implements PConstants {
5387
5091
  * parameter. Eg. a falloff factor of 0.75 means each octave will now have
5388
5092
  * 75% impact (25% less) of the previous lower octave. Any value between
5389
5093
  * 0.0 and 1.0 is valid, however note that values greater than 0.5 might
5390
- * result in greater than 1.0 values returned by <b>noise()</b>.<br /><br
5094
+ * result in greater than 1.0 values returned by <b>noise()</b>.<br
5391
5095
  * />By changing these parameters, the signal created by the <b>noise()</b>
5392
5096
  * function can be adapted to fit very specific needs and characteristics.
5393
5097
  *
@@ -5437,8 +5141,6 @@ public class PApplet implements PConstants {
5437
5141
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5438
5142
 
5439
5143
 
5440
- protected String[] loadImageFormats;
5441
-
5442
5144
  /**
5443
5145
  * ( begin auto-generated from loadImage.xml )
5444
5146
  *
@@ -5447,23 +5149,23 @@ public class PApplet implements PConstants {
5447
5149
  * be loaded. To load correctly, images must be located in the data
5448
5150
  * directory of the current sketch. In most cases, load all images in
5449
5151
  * <b>setup()</b> to preload them at the start of the program. Loading
5450
- * images inside <b>draw()</b> will reduce the speed of a program.<br/>
5451
- * <br/> <b>filename</b> parameter can also be a URL to a file found
5152
+ * images inside <b>draw()</b> will reduce the speed of a program.
5153
+ * <b>filename</b> parameter can also be a URL to a file found
5452
5154
  * online. For security reasons, a Processing sketch found online can only
5453
5155
  * download files from the same server from which it came. Getting around
5454
5156
  * this restriction requires a <a
5455
5157
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed
5456
- * applet</a>.<br/>
5457
- * <br/> <b>extension</b> parameter is used to determine the image type in
5158
+ * applet</a>.
5159
+ * <b>extension</b> parameter is used to determine the image type in
5458
5160
  * cases where the image filename does not end with a proper extension.
5459
5161
  * Specify the extension as the second parameter to <b>loadImage()</b>, as
5460
- * shown in the third example on this page.<br/>
5461
- * <br/> an image is not loaded successfully, the <b>null</b> value is
5162
+ * shown in the third example on this page.
5163
+ * an image is not loaded successfully, the <b>null</b> value is
5462
5164
  * returned and an error message will be printed to the console. The error
5463
5165
  * message does not halt the program, however the null value may cause a
5464
5166
  * NullPointerException if your code does not check whether the value
5465
- * returned from <b>loadImage()</b> is null.<br/>
5466
- * <br/> on the type of error, a <b>PImage</b> object may still be
5167
+ * returned from <b>loadImage()</b> is null.
5168
+ * on the type of error, a <b>PImage</b> object may still be
5467
5169
  * returned, but the width and height of the image will be set to -1. This
5468
5170
  * happens if bad image data is returned or cannot be decoded properly.
5469
5171
  * Sometimes this happens with image URLs that produce a 403 error or that
@@ -5480,29 +5182,14 @@ public class PApplet implements PConstants {
5480
5182
  * @see PGraphics#background(float, float, float, float)
5481
5183
  */
5482
5184
  public PImage loadImage(String filename) {
5483
- // return loadImage(filename, null, null);
5484
5185
  return loadImage(filename, null);
5485
5186
  }
5486
5187
 
5487
- // /**
5488
- // * @param extension the type of image to load, for example "png", "gif", "jpg"
5489
- // */
5490
- // public PImage loadImage(String filename, String extension) {
5491
- // return loadImage(filename, extension, null);
5492
- // }
5493
-
5494
- // /**
5495
- // * @nowebref
5496
- // */
5497
- // public PImage loadImage(String filename, Object params) {
5498
- // return loadImage(filename, null, params);
5499
- // }
5500
5188
 
5501
5189
  /**
5502
5190
  * @param extension type of image to load, for example "png", "gif", "jpg"
5503
5191
  */
5504
- public PImage loadImage(String filename, String extension) { //, Object params) {
5505
-
5192
+ public PImage loadImage(String filename, String extension) {
5506
5193
  // awaitAsyncSaveCompletion() has to run on the main thread, because P2D
5507
5194
  // and P3D call GL functions. If this runs on background, requestImage()
5508
5195
  // already called awaitAsyncSaveCompletion() on the main thread.
@@ -5510,127 +5197,7 @@ public class PApplet implements PConstants {
5510
5197
  g.awaitAsyncSaveCompletion(filename);
5511
5198
  }
5512
5199
 
5513
- if (extension == null) {
5514
- String lower = filename.toLowerCase();
5515
- int dot = filename.lastIndexOf('.');
5516
- if (dot == -1) {
5517
- extension = "unknown"; // no extension found
5518
-
5519
- } else {
5520
- extension = lower.substring(dot + 1);
5521
-
5522
- // check for, and strip any parameters on the url, i.e.
5523
- // filename.jpg?blah=blah&something=that
5524
- int question = extension.indexOf('?');
5525
- if (question != -1) {
5526
- extension = extension.substring(0, question);
5527
- }
5528
- }
5529
- }
5530
-
5531
- // just in case. them users will try anything!
5532
- extension = extension.toLowerCase();
5533
-
5534
- if (extension.equals("tga")) {
5535
- try {
5536
- PImage image = loadImageTGA(filename);
5537
- // if (params != null) {
5538
- // image.setParams(g, params);
5539
- // }
5540
- return image;
5541
- } catch (IOException e) {
5542
- printStackTrace(e);
5543
- return null;
5544
- }
5545
- }
5546
-
5547
- if (extension.equals("tif") || extension.equals("tiff")) {
5548
- byte bytes[] = loadBytes(filename);
5549
- PImage image = (bytes == null) ? null : PImage.loadTIFF(bytes);
5550
- // if (params != null) {
5551
- // image.setParams(g, params);
5552
- // }
5553
- return image;
5554
- }
5555
-
5556
- // For jpeg, gif, and png, load them using createImage(),
5557
- // because the javax.imageio code was found to be much slower.
5558
- // http://dev.processing.org/bugs/show_bug.cgi?id=392
5559
- try {
5560
- if (extension.equals("jpg") || extension.equals("jpeg") ||
5561
- extension.equals("gif") || extension.equals("png") ||
5562
- extension.equals("unknown")) {
5563
- byte bytes[] = loadBytes(filename);
5564
- if (bytes == null) {
5565
- return null;
5566
- } else {
5567
- //Image awtImage = Toolkit.getDefaultToolkit().createImage(bytes);
5568
- Image awtImage = new ImageIcon(bytes).getImage();
5569
-
5570
- if (awtImage instanceof BufferedImage) {
5571
- BufferedImage buffImage = (BufferedImage) awtImage;
5572
- int space = buffImage.getColorModel().getColorSpace().getType();
5573
- if (space == ColorSpace.TYPE_CMYK) {
5574
- System.err.println(filename + " is a CMYK image, " +
5575
- "only RGB images are supported.");
5576
- return null;
5577
- /*
5578
- // wishful thinking, appears to not be supported
5579
- // https://community.oracle.com/thread/1272045?start=0&tstart=0
5580
- BufferedImage destImage =
5581
- new BufferedImage(buffImage.getWidth(),
5582
- buffImage.getHeight(),
5583
- BufferedImage.TYPE_3BYTE_BGR);
5584
- ColorConvertOp op = new ColorConvertOp(null);
5585
- op.filter(buffImage, destImage);
5586
- image = new PImage(destImage);
5587
- */
5588
- }
5589
- }
5590
-
5591
- PImage image = new PImage(awtImage);
5592
- if (image.width == -1) {
5593
- System.err.println("The file " + filename +
5594
- " contains bad image data, or may not be an image.");
5595
- }
5596
-
5597
- // if it's a .gif image, test to see if it has transparency
5598
- if (extension.equals("gif") || extension.equals("png") ||
5599
- extension.equals("unknown")) {
5600
- image.checkAlpha();
5601
- }
5602
-
5603
- // if (params != null) {
5604
- // image.setParams(g, params);
5605
- // }
5606
- image.parent = this;
5607
- return image;
5608
- }
5609
- }
5610
- } catch (Exception e) {
5611
- // show error, but move on to the stuff below, see if it'll work
5612
- printStackTrace(e);
5613
- }
5614
-
5615
- if (loadImageFormats == null) {
5616
- loadImageFormats = ImageIO.getReaderFormatNames();
5617
- }
5618
- if (loadImageFormats != null) {
5619
- for (int i = 0; i < loadImageFormats.length; i++) {
5620
- if (extension.equals(loadImageFormats[i])) {
5621
- return loadImageIO(filename);
5622
- // PImage image = loadImageIO(filename);
5623
- // if (params != null) {
5624
- // image.setParams(g, params);
5625
- // }
5626
- // return image;
5627
- }
5628
- }
5629
- }
5630
-
5631
- // failed, could not load image after all those attempts
5632
- System.err.println("Could not find a method to load " + filename);
5633
- return null;
5200
+ return surface.loadImage(filename, extension);
5634
5201
  }
5635
5202
 
5636
5203
 
@@ -5653,8 +5220,8 @@ public class PApplet implements PConstants {
5653
5220
  * loading the image, its width and height will be set to -1. You'll know
5654
5221
  * when the image has loaded properly because its width and height will be
5655
5222
  * greater than 0. Asynchronous image loading (particularly when
5656
- * downloading from a server) can dramatically improve performance.<br />
5657
- * <br/> <b>extension</b> parameter is used to determine the image type in
5223
+ * downloading from a server) can dramatically improve performance.
5224
+ * <b>extension</b> parameter is used to determine the image type in
5658
5225
  * cases where the image filename does not end with a proper extension.
5659
5226
  * Specify the extension as the second parameter to <b>requestImage()</b>.
5660
5227
  *
@@ -5676,11 +5243,7 @@ public class PApplet implements PConstants {
5676
5243
 
5677
5244
  // if the image loading thread pool hasn't been created, create it
5678
5245
  if (requestImagePool == null) {
5679
- ThreadFactory factory = new ThreadFactory() {
5680
- public Thread newThread(Runnable r) {
5681
- return new Thread(r, REQUEST_IMAGE_THREAD_PREFIX);
5682
- }
5683
- };
5246
+ ThreadFactory factory = r -> new Thread(r, REQUEST_IMAGE_THREAD_PREFIX);
5684
5247
  requestImagePool = Executors.newFixedThreadPool(4, factory);
5685
5248
  }
5686
5249
  requestImagePool.execute(() -> {
@@ -5706,250 +5269,6 @@ public class PApplet implements PConstants {
5706
5269
  }
5707
5270
 
5708
5271
 
5709
- /**
5710
- * Use Java 1.4 ImageIO methods to load an image.
5711
- */
5712
- protected PImage loadImageIO(String filename) {
5713
- InputStream stream = createInput(filename);
5714
- if (stream == null) {
5715
- System.err.println("The image " + filename + " could not be found.");
5716
- return null;
5717
- }
5718
-
5719
- try {
5720
- BufferedImage bi = ImageIO.read(stream);
5721
- PImage outgoing = new PImage(bi.getWidth(), bi.getHeight());
5722
- outgoing.parent = this;
5723
-
5724
- bi.getRGB(0, 0, outgoing.width, outgoing.height,
5725
- outgoing.pixels, 0, outgoing.width);
5726
-
5727
- // check the alpha for this image
5728
- // was gonna call getType() on the image to see if RGB or ARGB,
5729
- // but it's not actually useful, since gif images will come through
5730
- // as TYPE_BYTE_INDEXED, which means it'll still have to check for
5731
- // the transparency. also, would have to iterate through all the other
5732
- // types and guess whether alpha was in there, so.. just gonna stick
5733
- // with the old method.
5734
- outgoing.checkAlpha();
5735
-
5736
- stream.close();
5737
- // return the image
5738
- return outgoing;
5739
-
5740
- } catch (Exception e) {
5741
- printStackTrace(e);
5742
- return null;
5743
- }
5744
- }
5745
-
5746
-
5747
- /**
5748
- * Targa image loader for RLE-compressed TGA files.
5749
- * <p>
5750
- * Rewritten for 0115 to read/write RLE-encoded targa images.
5751
- * For 0125, non-RLE encoded images are now supported, along with
5752
- * images whose y-order is reversed (which is standard for TGA files).
5753
- * <p>
5754
- * A version of this function is in MovieMaker.java. Any fixes here
5755
- * should be applied over in MovieMaker as well.
5756
- * <p>
5757
- * Known issue with RLE encoding and odd behavior in some apps:
5758
- * https://github.com/processing/processing/issues/2096
5759
- * Please help!
5760
- */
5761
- protected PImage loadImageTGA(String filename) throws IOException {
5762
- InputStream is = createInput(filename);
5763
- if (is == null) return null;
5764
-
5765
- byte header[] = new byte[18];
5766
- int offset = 0;
5767
- do {
5768
- int count = is.read(header, offset, header.length - offset);
5769
- if (count == -1) return null;
5770
- offset += count;
5771
- } while (offset < 18);
5772
-
5773
- /*
5774
- header[2] image type code
5775
- 2 (0x02) - Uncompressed, RGB images.
5776
- 3 (0x03) - Uncompressed, black and white images.
5777
- 10 (0x0A) - Run-length encoded RGB images.
5778
- 11 (0x0B) - Compressed, black and white images. (grayscale?)
5779
-
5780
- header[16] is the bit depth (8, 24, 32)
5781
-
5782
- header[17] image descriptor (packed bits)
5783
- 0x20 is 32 = origin upper-left
5784
- 0x28 is 32 + 8 = origin upper-left + 32 bits
5785
-
5786
- 7 6 5 4 3 2 1 0
5787
- 128 64 32 16 8 4 2 1
5788
- */
5789
-
5790
- int format = 0;
5791
-
5792
- if (((header[2] == 3) || (header[2] == 11)) && // B&W, plus RLE or not
5793
- (header[16] == 8) && // 8 bits
5794
- ((header[17] == 0x8) || (header[17] == 0x28))) { // origin, 32 bit
5795
- format = ALPHA;
5796
-
5797
- } else if (((header[2] == 2) || (header[2] == 10)) && // RGB, RLE or not
5798
- (header[16] == 24) && // 24 bits
5799
- ((header[17] == 0x20) || (header[17] == 0))) { // origin
5800
- format = RGB;
5801
-
5802
- } else if (((header[2] == 2) || (header[2] == 10)) &&
5803
- (header[16] == 32) &&
5804
- ((header[17] == 0x8) || (header[17] == 0x28))) { // origin, 32
5805
- format = ARGB;
5806
- }
5807
-
5808
- if (format == 0) {
5809
- System.err.println("Unknown .tga file format for " + filename);
5810
- //" (" + header[2] + " " +
5811
- //(header[16] & 0xff) + " " +
5812
- //hex(header[17], 2) + ")");
5813
- return null;
5814
- }
5815
-
5816
- int w = ((header[13] & 0xff) << 8) + (header[12] & 0xff);
5817
- int h = ((header[15] & 0xff) << 8) + (header[14] & 0xff);
5818
- PImage outgoing = createImage(w, h, format);
5819
-
5820
- // where "reversed" means upper-left corner (normal for most of
5821
- // the modernized world, but "reversed" for the tga spec)
5822
- //boolean reversed = (header[17] & 0x20) != 0;
5823
- // https://github.com/processing/processing/issues/1682
5824
- boolean reversed = (header[17] & 0x20) == 0;
5825
-
5826
- if ((header[2] == 2) || (header[2] == 3)) { // not RLE encoded
5827
- if (reversed) {
5828
- int index = (h-1) * w;
5829
- switch (format) {
5830
- case ALPHA:
5831
- for (int y = h-1; y >= 0; y--) {
5832
- for (int x = 0; x < w; x++) {
5833
- outgoing.pixels[index + x] = is.read();
5834
- }
5835
- index -= w;
5836
- }
5837
- break;
5838
- case RGB:
5839
- for (int y = h-1; y >= 0; y--) {
5840
- for (int x = 0; x < w; x++) {
5841
- outgoing.pixels[index + x] =
5842
- is.read() | (is.read() << 8) | (is.read() << 16) |
5843
- 0xff000000;
5844
- }
5845
- index -= w;
5846
- }
5847
- break;
5848
- case ARGB:
5849
- for (int y = h-1; y >= 0; y--) {
5850
- for (int x = 0; x < w; x++) {
5851
- outgoing.pixels[index + x] =
5852
- is.read() | (is.read() << 8) | (is.read() << 16) |
5853
- (is.read() << 24);
5854
- }
5855
- index -= w;
5856
- }
5857
- }
5858
- } else { // not reversed
5859
- int count = w * h;
5860
- switch (format) {
5861
- case ALPHA:
5862
- for (int i = 0; i < count; i++) {
5863
- outgoing.pixels[i] = is.read();
5864
- }
5865
- break;
5866
- case RGB:
5867
- for (int i = 0; i < count; i++) {
5868
- outgoing.pixels[i] =
5869
- is.read() | (is.read() << 8) | (is.read() << 16) |
5870
- 0xff000000;
5871
- }
5872
- break;
5873
- case ARGB:
5874
- for (int i = 0; i < count; i++) {
5875
- outgoing.pixels[i] =
5876
- is.read() | (is.read() << 8) | (is.read() << 16) |
5877
- (is.read() << 24);
5878
- }
5879
- break;
5880
- }
5881
- }
5882
-
5883
- } else { // header[2] is 10 or 11
5884
- int index = 0;
5885
- int px[] = outgoing.pixels;
5886
-
5887
- while (index < px.length) {
5888
- int num = is.read();
5889
- boolean isRLE = (num & 0x80) != 0;
5890
- if (isRLE) {
5891
- num -= 127; // (num & 0x7F) + 1
5892
- int pixel = 0;
5893
- switch (format) {
5894
- case ALPHA:
5895
- pixel = is.read();
5896
- break;
5897
- case RGB:
5898
- pixel = 0xFF000000 |
5899
- is.read() | (is.read() << 8) | (is.read() << 16);
5900
- //(is.read() << 16) | (is.read() << 8) | is.read();
5901
- break;
5902
- case ARGB:
5903
- pixel = is.read() |
5904
- (is.read() << 8) | (is.read() << 16) | (is.read() << 24);
5905
- break;
5906
- }
5907
- for (int i = 0; i < num; i++) {
5908
- px[index++] = pixel;
5909
- if (index == px.length) break;
5910
- }
5911
- } else { // write up to 127 bytes as uncompressed
5912
- num += 1;
5913
- switch (format) {
5914
- case ALPHA:
5915
- for (int i = 0; i < num; i++) {
5916
- px[index++] = is.read();
5917
- }
5918
- break;
5919
- case RGB:
5920
- for (int i = 0; i < num; i++) {
5921
- px[index++] = 0xFF000000 |
5922
- is.read() | (is.read() << 8) | (is.read() << 16);
5923
- //(is.read() << 16) | (is.read() << 8) | is.read();
5924
- }
5925
- break;
5926
- case ARGB:
5927
- for (int i = 0; i < num; i++) {
5928
- px[index++] = is.read() | //(is.read() << 24) |
5929
- (is.read() << 8) | (is.read() << 16) | (is.read() << 24);
5930
- //(is.read() << 16) | (is.read() << 8) | is.read();
5931
- }
5932
- break;
5933
- }
5934
- }
5935
- }
5936
-
5937
- if (!reversed) {
5938
- int[] temp = new int[w];
5939
- for (int y = 0; y < h/2; y++) {
5940
- int z = (h-1) - y;
5941
- System.arraycopy(px, y*w, temp, 0, w);
5942
- System.arraycopy(px, z*w, px, y*w, w);
5943
- System.arraycopy(temp, 0, px, z*w, w);
5944
- }
5945
- }
5946
- }
5947
- is.close();
5948
- return outgoing;
5949
- }
5950
-
5951
-
5952
-
5953
5272
  //////////////////////////////////////////////////////////////
5954
5273
 
5955
5274
  // DATA I/O
@@ -6004,13 +5323,7 @@ public class PApplet implements PConstants {
6004
5323
 
6005
5324
  // can't use catch-all exception, since it might catch the
6006
5325
  // RuntimeException about the incorrect case sensitivity
6007
- } catch (IOException e) {
6008
- throw new RuntimeException(e);
6009
-
6010
- } catch (ParserConfigurationException e) {
6011
- throw new RuntimeException(e);
6012
-
6013
- } catch (SAXException e) {
5326
+ } catch (IOException | ParserConfigurationException | SAXException e) {
6014
5327
  throw new RuntimeException(e);
6015
5328
  }
6016
5329
  }
@@ -6241,10 +5554,9 @@ public class PApplet implements PConstants {
6241
5554
  String optionStr = Table.extensionOptions(true, filename, options);
6242
5555
  String[] optionList = trim(split(optionStr, ','));
6243
5556
 
6244
- Table dictionary = null;
6245
5557
  for (String opt : optionList) {
6246
5558
  if (opt.startsWith("dictionary=")) {
6247
- dictionary = loadTable(opt.substring(opt.indexOf('=') + 1), "tsv");
5559
+ Table dictionary = loadTable(opt.substring(opt.indexOf('=') + 1), "tsv");
6248
5560
  return dictionary.typedParse(createInput(filename), optionStr);
6249
5561
  }
6250
5562
  }
@@ -6314,19 +5626,19 @@ public class PApplet implements PConstants {
6314
5626
  * fonts must be located in the data directory of the current sketch. To
6315
5627
  * create a font to use with Processing, select "Create Font..." from the
6316
5628
  * Tools menu. This will create a font in the format Processing requires
6317
- * and also adds it to the current sketch's data directory.<br />
6318
- * <br />
5629
+ * and also adds it to the current sketch's data directory.
5630
+ *
6319
5631
  * Like <b>loadImage()</b> and other functions that load data, the
6320
5632
  * <b>loadFont()</b> function should not be used inside <b>draw()</b>,
6321
5633
  * because it will slow down the sketch considerably, as the font will be
6322
- * re-loaded from the disk (or network) on each frame.<br />
6323
- * <br />
5634
+ * re-loaded from the disk (or network) on each frame.
5635
+ *
6324
5636
  * For most renderers, Processing displays fonts using the .vlw font
6325
5637
  * format, which uses images for each letter, rather than defining them
6326
5638
  * through vector data. When <b>hint(ENABLE_NATIVE_FONTS)</b> is used with
6327
5639
  * the JAVA2D renderer, the native version of a font will be used if it is
6328
- * installed on the user's machine.<br />
6329
- * <br />
5640
+ * installed on the user's machine.
5641
+ *
6330
5642
  * Using <b>createFont()</b> (instead of loadFont) enables vector data to
6331
5643
  * be used with the JAVA2D (default) renderer setting. This can be helpful
6332
5644
  * when many font sizes are needed, or when using any renderer based on
@@ -6374,7 +5686,7 @@ public class PApplet implements PConstants {
6374
5686
  * file inside the sketches "data" folder. This function is an advanced
6375
5687
  * feature for precise control. On most occasions you should create fonts
6376
5688
  * through selecting "Create Font..." from the Tools menu.
6377
- * <br /><br />
5689
+ *
6378
5690
  * Use the <b>PFont.list()</b> method to first determine the names for the
6379
5691
  * fonts recognized by the computer and are compatible with this function.
6380
5692
  * Because of limitations in Java, not all fonts can be used and some might
@@ -6384,12 +5696,12 @@ public class PApplet implements PConstants {
6384
5696
  * because other people might not have the font installed on their
6385
5697
  * computer. Only fonts that can legally be distributed should be included
6386
5698
  * with a sketch.
6387
- * <br /><br />
5699
+ *
6388
5700
  * The <b>size</b> parameter states the font size you want to generate. The
6389
5701
  * <b>smooth</b> parameter specifies if the font should be antialiased or
6390
5702
  * not, and the <b>charset</b> parameter is an array of chars that
6391
5703
  * specifies the characters to generate.
6392
- * <br /><br />
5704
+ *
6393
5705
  * This function creates a bitmapped version of a font in the same manner
6394
5706
  * as the Create Font tool. It loads a font by name, and converts it to a
6395
5707
  * series of images based on the size of the font. When possible, the
@@ -6454,25 +5766,6 @@ public class PApplet implements PConstants {
6454
5766
  */
6455
5767
 
6456
5768
 
6457
- static private boolean lookAndFeelCheck;
6458
-
6459
- /**
6460
- * Initialize the Look & Feel if it hasn't been already.
6461
- * Call this before using any Swing-related code in PApplet methods.
6462
- */
6463
- static private void checkLookAndFeel() {
6464
- if (!lookAndFeelCheck) {
6465
- if (platform == WINDOWS) {
6466
- // Windows is defaulting to Metal or something else awful.
6467
- // Which also is not scaled properly with HiDPI interfaces.
6468
- try {
6469
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
6470
- } catch (Exception e) { }
6471
- }
6472
- lookAndFeelCheck = true;
6473
- }
6474
- }
6475
-
6476
5769
  /**
6477
5770
  * Open a platform-specific file chooser dialog to select a file for input.
6478
5771
  * After the selection is made, the selected File will be passed to the
@@ -6514,10 +5807,12 @@ public class PApplet implements PConstants {
6514
5807
 
6515
5808
  public void selectInput(String prompt, String callback,
6516
5809
  File file, Object callbackObject) {
6517
- selectInput(prompt, callback, file, callbackObject, null, this); //selectFrame());
5810
+ //selectInput(prompt, callback, file, callbackObject, null, this);
5811
+ surface.selectInput(prompt, callback, file, callbackObject);
6518
5812
  }
6519
5813
 
6520
5814
 
5815
+ /*
6521
5816
  static public void selectInput(String prompt, String callbackMethod,
6522
5817
  File file, Object callbackObject, Frame parent,
6523
5818
  PApplet sketch) {
@@ -6529,6 +5824,7 @@ public class PApplet implements PConstants {
6529
5824
  File file, Object callbackObject, Frame parent) {
6530
5825
  selectImpl(prompt, callbackMethod, file, callbackObject, parent, FileDialog.LOAD, null);
6531
5826
  }
5827
+ */
6532
5828
 
6533
5829
 
6534
5830
  /**
@@ -6550,10 +5846,12 @@ public class PApplet implements PConstants {
6550
5846
 
6551
5847
  public void selectOutput(String prompt, String callback,
6552
5848
  File file, Object callbackObject) {
6553
- selectOutput(prompt, callback, file, callbackObject, null, this); //selectFrame());
5849
+ //selectOutput(prompt, callback, file, callbackObject, null, this);
5850
+ surface.selectOutput(prompt, callback, file, callbackObject);
6554
5851
  }
6555
5852
 
6556
5853
 
5854
+ /*
6557
5855
  static public void selectOutput(String prompt, String callbackMethod,
6558
5856
  File file, Object callbackObject, Frame parent) {
6559
5857
  selectImpl(prompt, callbackMethod, file, callbackObject, parent, FileDialog.SAVE, null);
@@ -6621,6 +5919,7 @@ public class PApplet implements PConstants {
6621
5919
  }
6622
5920
  });
6623
5921
  }
5922
+ */
6624
5923
 
6625
5924
 
6626
5925
  /**
@@ -6642,10 +5941,12 @@ public class PApplet implements PConstants {
6642
5941
 
6643
5942
  public void selectFolder(String prompt, String callback,
6644
5943
  File file, Object callbackObject) {
6645
- selectFolder(prompt, callback, file, callbackObject, null, this); //selectFrame());
5944
+ //selectFolder(prompt, callback, file, callbackObject, null, this);
5945
+ surface.selectFolder(prompt, callback, file, callbackObject);
6646
5946
  }
6647
5947
 
6648
5948
 
5949
+ /*
6649
5950
  static public void selectFolder(final String prompt,
6650
5951
  final String callbackMethod,
6651
5952
  final File defaultSelection,
@@ -6671,7 +5972,7 @@ public class PApplet implements PConstants {
6671
5972
  (sketch.g instanceof PGraphicsOpenGL) && (platform == WINDOWS);
6672
5973
  if (hide) sketch.surface.setVisible(false);
6673
5974
 
6674
- if (platform == MACOSX && useNativeSelect != false) {
5975
+ if (platform == MACOS && useNativeSelect != false) {
6675
5976
  FileDialog fileDialog =
6676
5977
  new FileDialog(parentFrame, prompt, FileDialog.LOAD);
6677
5978
  if (defaultSelection != null) {
@@ -6704,16 +6005,17 @@ public class PApplet implements PConstants {
6704
6005
  }
6705
6006
  });
6706
6007
  }
6008
+ */
6707
6009
 
6708
6010
 
6709
- static private void selectCallback(File selectedFile,
6710
- String callbackMethod,
6711
- Object callbackObject) {
6011
+ static public void selectCallback(File selectedFile,
6012
+ String callbackMethod,
6013
+ Object callbackObject) {
6712
6014
  try {
6713
6015
  Class<?> callbackClass = callbackObject.getClass();
6714
6016
  Method selectMethod =
6715
- callbackClass.getMethod(callbackMethod, new Class[] { File.class });
6716
- selectMethod.invoke(callbackObject, new Object[] { selectedFile });
6017
+ callbackClass.getMethod(callbackMethod, File.class);
6018
+ selectMethod.invoke(callbackObject, selectedFile);
6717
6019
 
6718
6020
  } catch (IllegalAccessException iae) {
6719
6021
  System.err.println(callbackMethod + "() must be public");
@@ -6727,7 +6029,6 @@ public class PApplet implements PConstants {
6727
6029
  }
6728
6030
 
6729
6031
 
6730
-
6731
6032
  //////////////////////////////////////////////////////////////
6732
6033
 
6733
6034
  // LISTING DIRECTORIES
@@ -6891,7 +6192,7 @@ public class PApplet implements PConstants {
6891
6192
  * Creates a <b>BufferedReader</b> object that can be used to read files
6892
6193
  * line-by-line as individual <b>String</b> objects. This is the complement
6893
6194
  * to the <b>createWriter()</b> function.
6894
- * <br/> <br/>
6195
+ *
6895
6196
  * Starting with Processing release 0134, all files loaded and saved by the
6896
6197
  * Processing API use UTF-8 encoding. In previous releases, the default
6897
6198
  * encoding for your platform was used, which causes problems when files
@@ -6967,7 +6268,7 @@ public class PApplet implements PConstants {
6967
6268
  * to write to it. For the file to be made correctly, it should be flushed
6968
6269
  * and must be closed with its <b>flush()</b> and <b>close()</b> methods
6969
6270
  * (see above example).
6970
- * <br/> <br/>
6271
+ *
6971
6272
  * Starting with Processing release 0134, all files loaded and saved by the
6972
6273
  * Processing API use UTF-8 encoding. In previous releases, the default
6973
6274
  * encoding for your platform was used, which causes problems when files
@@ -7035,28 +6336,28 @@ public class PApplet implements PConstants {
7035
6336
  * It's useful if you want to use the facilities provided by PApplet to
7036
6337
  * easily open files from the data folder or from a URL, but want an
7037
6338
  * InputStream object so that you can use other parts of Java to take more
7038
- * control of how the stream is read.<br />
7039
- * <br />
7040
- * The filename passed in can be:<br />
7041
- * - A URL, for instance <b>openStream("http://processing.org/")</b><br />
7042
- * - A file in the sketch's <b>data</b> folder<br />
6339
+ * control of how the stream is read.
6340
+ *
6341
+ * The filename passed in can be:
6342
+ * - A URL, for instance <b>openStream("http://processing.org/")</b>
6343
+ * - A file in the sketch's <b>data</b> folder
7043
6344
  * - The full path to a file to be opened locally (when running as an
7044
- * application)<br />
7045
- * <br />
6345
+ * application)
6346
+ *
7046
6347
  * If the requested item doesn't exist, null is returned. If not online,
7047
6348
  * this will also check to see if the user is asking for a file whose name
7048
6349
  * isn't properly capitalized. If capitalization is different, an error
7049
6350
  * will be printed to the console. This helps prevent issues that appear
7050
6351
  * when a sketch is exported to the web, where case sensitivity matters, as
7051
6352
  * opposed to running from inside the Processing Development Environment on
7052
- * Windows or Mac OS, where case sensitivity is preserved but ignored.<br />
7053
- * <br />
6353
+ * Windows or Mac OS, where case sensitivity is preserved but ignored.
6354
+ *
7054
6355
  * If the file ends with <b>.gz</b>, the stream will automatically be gzip
7055
6356
  * decompressed. If you don't want the automatic decompression, use the
7056
6357
  * related function <b>createInputRaw()</b>.
7057
- * <br />
7058
- * In earlier releases, this function was called <b>openStream()</b>.<br />
7059
- * <br />
6358
+ *
6359
+ * In earlier releases, this function was called <b>openStream()</b>.
6360
+ *
7060
6361
  *
7061
6362
  * ( end auto-generated )
7062
6363
  *
@@ -7173,7 +6474,7 @@ public class PApplet implements PConstants {
7173
6474
  }
7174
6475
  }
7175
6476
 
7176
- InputStream stream = null;
6477
+ InputStream stream;
7177
6478
 
7178
6479
  // Moved this earlier than the getResourceAsStream() checks, because
7179
6480
  // calling getResourceAsStream() on a directory lists its contents.
@@ -7207,17 +6508,15 @@ public class PApplet implements PConstants {
7207
6508
  filename + ". Rename the file " +
7208
6509
  "or change your code.");
7209
6510
  }
7210
- } catch (IOException e) { }
6511
+ } catch (IOException ignored) { }
7211
6512
  }
7212
6513
 
7213
6514
  // if this file is ok, may as well just load it
7214
- stream = new FileInputStream(file);
7215
- if (stream != null) return stream;
6515
+ return new FileInputStream(file);
7216
6516
 
7217
6517
  // have to break these out because a general Exception might
7218
6518
  // catch the RuntimeException being thrown above
7219
- } catch (IOException ioe) {
7220
- } catch (SecurityException se) { }
6519
+ } catch (IOException | SecurityException ignored) { }
7221
6520
 
7222
6521
  // Using getClassLoader() prevents java from converting dots
7223
6522
  // to slashes or requiring a slash at the beginning.
@@ -7255,21 +6554,18 @@ public class PApplet implements PConstants {
7255
6554
  // an application, or as a signed applet
7256
6555
  try { // first try to catch any security exceptions
7257
6556
  try {
7258
- stream = new FileInputStream(dataPath(filename));
7259
- if (stream != null) return stream;
7260
- } catch (IOException e2) { }
6557
+ return new FileInputStream(dataPath(filename));
6558
+ } catch (IOException ignored) { }
7261
6559
 
7262
6560
  try {
7263
- stream = new FileInputStream(sketchPath(filename));
7264
- if (stream != null) return stream;
7265
- } catch (Exception e) { } // ignored
6561
+ return new FileInputStream(sketchPath(filename));
6562
+ } catch (Exception ignored) { }
7266
6563
 
7267
6564
  try {
7268
- stream = new FileInputStream(filename);
7269
- if (stream != null) return stream;
7270
- } catch (IOException e1) { }
6565
+ return new FileInputStream(filename);
6566
+ } catch (IOException ignored) { }
7271
6567
 
7272
- } catch (SecurityException se) { } // online, whups
6568
+ } catch (SecurityException ignored) { } // online, whups
7273
6569
 
7274
6570
  } catch (Exception e) {
7275
6571
  printStackTrace(e);
@@ -7311,8 +6607,8 @@ public class PApplet implements PConstants {
7311
6607
  *
7312
6608
  * Reads the contents of a file or url and places it in a byte array. If a
7313
6609
  * file is specified, it must be located in the sketch's "data"
7314
- * directory/folder.<br />
7315
- * <br />
6610
+ * directory/folder.
6611
+ *
7316
6612
  * The filename parameter can also be a URL to a file found online. For
7317
6613
  * security reasons, a Processing sketch found online can only download
7318
6614
  * files from the same server from which it came. Getting around this
@@ -7361,7 +6657,7 @@ public class PApplet implements PConstants {
7361
6657
  }
7362
6658
 
7363
6659
  if (input != null) {
7364
- byte[] buffer = null;
6660
+ byte[] buffer;
7365
6661
  if (length != -1) {
7366
6662
  buffer = new byte[length];
7367
6663
  int count;
@@ -7522,20 +6818,20 @@ public class PApplet implements PConstants {
7522
6818
  *
7523
6819
  * Reads the contents of a file or url and creates a String array of its
7524
6820
  * individual lines. If a file is specified, it must be located in the
7525
- * sketch's "data" directory/folder.<br />
7526
- * <br />
6821
+ * sketch's "data" directory/folder.
6822
+ *
7527
6823
  * The filename parameter can also be a URL to a file found online. For
7528
6824
  * security reasons, a Processing sketch found online can only download
7529
6825
  * files from the same server from which it came. Getting around this
7530
6826
  * restriction requires a <a
7531
6827
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</a>.
7532
- * <br />
6828
+ *
7533
6829
  * If the file is not available or an error occurs, <b>null</b> will be
7534
6830
  * returned and an error message will be printed to the console. The error
7535
6831
  * message does not halt the program, however the null value may cause a
7536
6832
  * NullPointerException if your code does not check whether the value
7537
6833
  * returned is null.
7538
- * <br/> <br/>
6834
+ *
7539
6835
  * Starting with Processing release 0134, all files loaded and saved by the
7540
6836
  * Processing API use UTF-8 encoding. In previous releases, the default
7541
6837
  * encoding for your platform was used, which causes problems when files
@@ -7584,25 +6880,20 @@ public class PApplet implements PConstants {
7584
6880
  * @nowebref
7585
6881
  */
7586
6882
  static public String[] loadStrings(InputStream input) {
7587
- try {
7588
- BufferedReader reader =
7589
- new BufferedReader(new InputStreamReader(input, "UTF-8"));
7590
- return loadStrings(reader);
7591
- } catch (IOException e) {
7592
- e.printStackTrace();
7593
- }
7594
- return null;
6883
+ BufferedReader reader =
6884
+ new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
6885
+ return loadStrings(reader);
7595
6886
  }
7596
6887
 
7597
6888
 
7598
6889
  static public String[] loadStrings(BufferedReader reader) {
7599
6890
  try {
7600
- String lines[] = new String[100];
6891
+ String[] lines = new String[100];
7601
6892
  int lineCount = 0;
7602
- String line = null;
6893
+ String line;
7603
6894
  while ((line = reader.readLine()) != null) {
7604
6895
  if (lineCount == lines.length) {
7605
- String temp[] = new String[lineCount << 1];
6896
+ String[] temp = new String[lineCount << 1];
7606
6897
  System.arraycopy(lines, 0, temp, 0, lineCount);
7607
6898
  lines = temp;
7608
6899
  }
@@ -7615,7 +6906,7 @@ public class PApplet implements PConstants {
7615
6906
  }
7616
6907
 
7617
6908
  // resize array to appropriate amount for these lines
7618
- String output[] = new String[lineCount];
6909
+ String[] output = new String[lineCount];
7619
6910
  System.arraycopy(lines, 0, output, 0, lineCount);
7620
6911
  return output;
7621
6912
 
@@ -7639,16 +6930,16 @@ public class PApplet implements PConstants {
7639
6930
  * Similar to <b>createInput()</b>, this creates a Java <b>OutputStream</b>
7640
6931
  * for a given filename or path. The file will be created in the sketch
7641
6932
  * folder, or in the same folder as an exported application.
7642
- * <br /><br />
6933
+ *
7643
6934
  * If the path does not exist, intermediate folders will be created. If an
7644
6935
  * exception occurs, it will be printed to the console, and <b>null</b>
7645
6936
  * will be returned.
7646
- * <br /><br />
6937
+ *
7647
6938
  * This function is a convenience over the Java approach that requires you
7648
6939
  * to 1) create a FileOutputStream object, 2) determine the exact file
7649
6940
  * location, and 3) handle exceptions. Exceptions are handled internally by
7650
6941
  * the function, which is more appropriate for "sketch" projects.
7651
- * <br /><br />
6942
+ *
7652
6943
  * If the output filename ends with <b>.gz</b>, the output will be
7653
6944
  * automatically GZIP compressed as it is written.
7654
6945
  *
@@ -7686,8 +6977,8 @@ public class PApplet implements PConstants {
7686
6977
  *
7687
6978
  * Save the contents of a stream to a file in the sketch folder. This is
7688
6979
  * basically <b>saveBytes(blah, loadBytes())</b>, but done more efficiently
7689
- * (and with less confusing syntax).<br />
7690
- * <br />
6980
+ * (and with less confusing syntax).
6981
+ *
7691
6982
  * When using the <b>targetFile</b> parameter, it writes to a <b>File</b>
7692
6983
  * object for greater control over the file location. (Note that unlike
7693
6984
  * some other functions, this will not automatically compress or uncompress
@@ -7707,7 +6998,7 @@ public class PApplet implements PConstants {
7707
6998
  /**
7708
6999
  * Identical to the other saveStream(), but writes to a File
7709
7000
  * object, for greater control over the file location.
7710
- * <p/>
7001
+ *
7711
7002
  * Note that unlike other api methods, this will not automatically
7712
7003
  * compress or uncompress gzip files.
7713
7004
  */
@@ -7735,24 +7026,23 @@ public class PApplet implements PConstants {
7735
7026
 
7736
7027
  saveStream(targetStream, source);
7737
7028
  targetStream.close();
7738
- targetStream = null;
7739
7029
 
7740
7030
  if (target.exists()) {
7741
7031
  if (!target.delete()) {
7742
- System.err.println("Could not replace " +
7743
- target.getAbsolutePath() + ".");
7032
+ System.err.println("Could not replace " + target);
7744
7033
  }
7745
7034
  }
7746
7035
  if (!tempFile.renameTo(target)) {
7747
- System.err.println("Could not rename temporary file " +
7748
- tempFile.getAbsolutePath());
7036
+ System.err.println("Could not rename temporary file " + tempFile);
7749
7037
  return false;
7750
7038
  }
7751
7039
  return true;
7752
7040
 
7753
7041
  } catch (IOException e) {
7754
7042
  if (tempFile != null) {
7755
- tempFile.delete();
7043
+ if (!tempFile.delete()) {
7044
+ System.err.println("Could not rename temporary file " + tempFile);
7045
+ }
7756
7046
  }
7757
7047
  e.printStackTrace();
7758
7048
  return false;
@@ -7783,8 +7073,8 @@ public class PApplet implements PConstants {
7783
7073
  * Opposite of <b>loadBytes()</b>, will write an entire array of bytes to a
7784
7074
  * file. The data is saved in binary format. This file is saved to the
7785
7075
  * sketch's folder, which is opened by selecting "Show sketch folder" from
7786
- * the "Sketch" menu.<br />
7787
- * <br />
7076
+ * the "Sketch" menu.
7077
+ *
7788
7078
  * It is not possible to use saveXxxxx() functions inside a web browser
7789
7079
  * unless the sketch is <a
7790
7080
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
@@ -7816,7 +7106,9 @@ public class PApplet implements PConstants {
7816
7106
  static private File createTempFile(File file) throws IOException {
7817
7107
  File parentDir = file.getParentFile();
7818
7108
  if (!parentDir.exists()) {
7819
- parentDir.mkdirs();
7109
+ if (!parentDir.mkdirs()) {
7110
+ throw new IOException("Could not make directories for " + parentDir);
7111
+ }
7820
7112
  }
7821
7113
  String name = file.getName();
7822
7114
  String prefix;
@@ -7847,25 +7139,29 @@ public class PApplet implements PConstants {
7847
7139
  tempFile = createTempFile(file);
7848
7140
 
7849
7141
  OutputStream output = createOutput(tempFile);
7850
- saveBytes(output, data);
7851
- output.close();
7852
- output = null;
7142
+ if (output != null) {
7143
+ saveBytes(output, data);
7144
+ output.close();
7145
+ } else {
7146
+ System.err.println("Could not write to " + tempFile);
7147
+ }
7853
7148
 
7854
7149
  if (file.exists()) {
7855
7150
  if (!file.delete()) {
7856
- System.err.println("Could not replace " + file.getAbsolutePath());
7151
+ System.err.println("Could not replace " + file);
7857
7152
  }
7858
7153
  }
7859
7154
 
7860
7155
  if (!tempFile.renameTo(file)) {
7861
- System.err.println("Could not rename temporary file " +
7862
- tempFile.getAbsolutePath());
7156
+ System.err.println("Could not rename temporary file " + tempFile);
7863
7157
  }
7864
7158
 
7865
7159
  } catch (IOException e) {
7866
7160
  System.err.println("error saving bytes to " + file);
7867
7161
  if (tempFile != null) {
7868
- tempFile.delete();
7162
+ if (!tempFile.delete()) {
7163
+ System.err.println("Could not delete temporary file " + tempFile);
7164
+ }
7869
7165
  }
7870
7166
  e.printStackTrace();
7871
7167
  }
@@ -7894,14 +7190,14 @@ public class PApplet implements PConstants {
7894
7190
  *
7895
7191
  * Writes an array of strings to a file, one line per string. This file is
7896
7192
  * saved to the sketch's folder, which is opened by selecting "Show sketch
7897
- * folder" from the "Sketch" menu.<br />
7898
- * <br />
7193
+ * folder" from the "Sketch" menu.
7194
+ *
7899
7195
  * It is not possible to use saveXxxxx() functions inside a web browser
7900
7196
  * unless the sketch is <a
7901
7197
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
7902
7198
  * save a file back to a server, see the <a
7903
7199
  * href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to
7904
- * web</A> code snippet on the Processing Wiki.<br/>
7200
+ * web</A> code snippet on the Processing Wiki.
7905
7201
  * <br/ >
7906
7202
  * Starting with Processing 1.0, all files loaded and saved by the
7907
7203
  * Processing API use UTF-8 encoding. In previous releases, the default
@@ -7916,7 +7212,7 @@ public class PApplet implements PConstants {
7916
7212
  * @see PApplet#loadBytes(String)
7917
7213
  * @see PApplet#saveBytes(String, byte[])
7918
7214
  */
7919
- public void saveStrings(String filename, String data[]) {
7215
+ public void saveStrings(String filename, String[] data) {
7920
7216
  saveStrings(saveFile(filename), data);
7921
7217
  }
7922
7218
 
@@ -7924,7 +7220,7 @@ public class PApplet implements PConstants {
7924
7220
  /**
7925
7221
  * @nowebref
7926
7222
  */
7927
- static public void saveStrings(File file, String data[]) {
7223
+ static public void saveStrings(File file, String[] data) {
7928
7224
  saveStrings(createOutput(file), data);
7929
7225
  }
7930
7226
 
@@ -7960,13 +7256,7 @@ public class PApplet implements PConstants {
7960
7256
 
7961
7257
  // Workaround for bug in Java for OS X from Oracle (7u51)
7962
7258
  // https://github.com/processing/processing/issues/2181
7963
- if (platform == MACOSX) {
7964
- if (jarPath.contains("Contents/Java/")) {
7965
- String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4);
7966
- File containingFolder = new File(appPath).getParentFile();
7967
- folder = containingFolder.getAbsolutePath();
7968
- }
7969
- } else {
7259
+
7970
7260
  // Working directory may not be set properly, try some options
7971
7261
  // https://github.com/processing/processing/issues/2195
7972
7262
  if (jarPath.contains("/lib/")) {
@@ -7974,8 +7264,7 @@ public class PApplet implements PConstants {
7974
7264
  folder = new File(jarPath, "../..").getCanonicalPath();
7975
7265
  }
7976
7266
  }
7977
- } catch (Exception e) {
7978
- e.printStackTrace();
7267
+ catch (IOException | URISyntaxException e) {
7979
7268
  }
7980
7269
  return folder;
7981
7270
  }
@@ -7993,11 +7282,11 @@ public class PApplet implements PConstants {
7993
7282
  * Prepend the sketch folder path to the filename (or path) that is
7994
7283
  * passed in. External libraries should use this function to save to
7995
7284
  * the sketch folder.
7996
- * <p/>
7285
+ *
7997
7286
  * Note that when running as an applet inside a web browser,
7998
7287
  * the sketchPath will be set to null, because security restrictions
7999
7288
  * prevent applets from accessing that information.
8000
- * <p/>
7289
+ *
8001
7290
  * This will also cause an error if the sketch is not inited properly,
8002
7291
  * meaning that init() was never called on the PApplet when hosted
8003
7292
  * my some other main() or by other code. For proper use of init(),
@@ -8026,7 +7315,7 @@ public class PApplet implements PConstants {
8026
7315
  /**
8027
7316
  * Returns a path inside the applet folder to save to. Like sketchPath(),
8028
7317
  * but creates any in-between folders so that things save properly.
8029
- * <p/>
7318
+ *
8030
7319
  * All saveXxxx() functions use the path to the sketch folder, rather than
8031
7320
  * its data folder. Once exported, the data folder will be found inside the
8032
7321
  * jar file of the exported application or applet. In this case, it's not
@@ -8054,17 +7343,15 @@ public class PApplet implements PConstants {
8054
7343
 
8055
7344
  static File desktopFolder;
8056
7345
 
8057
- /** Not a supported function. For testing use only. */
8058
7346
  static public File desktopFile(String what) {
8059
7347
  if (desktopFolder == null) {
8060
7348
  // Should work on Linux and OS X (on OS X, even with the localized version).
8061
7349
  desktopFolder = new File(System.getProperty("user.home"), "Desktop");
8062
7350
  if (!desktopFolder.exists()) {
8063
- if (platform == WINDOWS) {
8064
- FileSystemView filesys = FileSystemView.getFileSystemView();
8065
- desktopFolder = filesys.getHomeDirectory();
7351
+ if (platform == WINDOWS && !disableAWT) {
7352
+ desktopFolder = ShimAWT.getWindowsDesktop();
8066
7353
  } else {
8067
- throw new UnsupportedOperationException("Could not find a suitable desktop foldder");
7354
+ throw new UnsupportedOperationException("Could not find a suitable Desktop foldder");
8068
7355
  }
8069
7356
  }
8070
7357
  }
@@ -8072,7 +7359,6 @@ public class PApplet implements PConstants {
8072
7359
  }
8073
7360
 
8074
7361
 
8075
- /** Not a supported function. For testing use only. */
8076
7362
  static public String desktopPath(String what) {
8077
7363
  return desktopFile(what).getAbsolutePath();
8078
7364
  }
@@ -8208,11 +7494,7 @@ public class PApplet implements PConstants {
8208
7494
  // using toURI() and URI.toURL()."
8209
7495
  // https://docs.oracle.com/javase/8/docs/api/java/net/URL.html
8210
7496
  static public String urlDecode(String str) {
8211
- try {
8212
- return URLDecoder.decode(str, "UTF-8");
8213
- } catch (UnsupportedEncodingException e) { // safe per the JDK source
8214
- return null;
8215
- }
7497
+ return URLDecoder.decode(str, StandardCharsets.UTF_8);
8216
7498
  }
8217
7499
 
8218
7500
 
@@ -8238,7 +7520,7 @@ public class PApplet implements PConstants {
8238
7520
  * @param list array to sort
8239
7521
  * @see PApplet#reverse(boolean[])
8240
7522
  */
8241
- static public byte[] sort(byte list[]) {
7523
+ static public byte[] sort(byte[] list) {
8242
7524
  return sort(list, list.length);
8243
7525
  }
8244
7526
 
@@ -8252,7 +7534,7 @@ public class PApplet implements PConstants {
8252
7534
  return outgoing;
8253
7535
  }
8254
7536
 
8255
- static public char[] sort(char list[]) {
7537
+ static public char[] sort(char[] list) {
8256
7538
  return sort(list, list.length);
8257
7539
  }
8258
7540
 
@@ -8263,7 +7545,7 @@ public class PApplet implements PConstants {
8263
7545
  return outgoing;
8264
7546
  }
8265
7547
 
8266
- static public int[] sort(int list[]) {
7548
+ static public int[] sort(int[] list) {
8267
7549
  return sort(list, list.length);
8268
7550
  }
8269
7551
 
@@ -8274,7 +7556,7 @@ public class PApplet implements PConstants {
8274
7556
  return outgoing;
8275
7557
  }
8276
7558
 
8277
- static public float[] sort(float list[]) {
7559
+ static public float[] sort(float[] list) {
8278
7560
  return sort(list, list.length);
8279
7561
  }
8280
7562
 
@@ -8285,7 +7567,7 @@ public class PApplet implements PConstants {
8285
7567
  return outgoing;
8286
7568
  }
8287
7569
 
8288
- static public String[] sort(String list[]) {
7570
+ static public String[] sort(String[] list) {
8289
7571
  return sort(list, list.length);
8290
7572
  }
8291
7573
 
@@ -8381,7 +7663,7 @@ public class PApplet implements PConstants {
8381
7663
  * Increases the size of an array. By default, this function doubles the
8382
7664
  * size of the array, but the optional <b>newSize</b> parameter provides
8383
7665
  * precise control over the increase in size.
8384
- * <br/> <br/>
7666
+ *
8385
7667
  * When using an array of objects, the data returned from the function must
8386
7668
  * be cast to the object array's data type. For example: <em>SomeClass[]
8387
7669
  * items = (SomeClass[]) expand(originalArray)</em>.
@@ -8392,85 +7674,85 @@ public class PApplet implements PConstants {
8392
7674
  * @param list the array to expand
8393
7675
  * @see PApplet#shorten(boolean[])
8394
7676
  */
8395
- static public boolean[] expand(boolean list[]) {
7677
+ static public boolean[] expand(boolean[] list) {
8396
7678
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8397
7679
  }
8398
7680
 
8399
7681
  /**
8400
7682
  * @param newSize new size for the array
8401
7683
  */
8402
- static public boolean[] expand(boolean list[], int newSize) {
8403
- boolean temp[] = new boolean[newSize];
7684
+ static public boolean[] expand(boolean[] list, int newSize) {
7685
+ boolean[] temp = new boolean[newSize];
8404
7686
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8405
7687
  return temp;
8406
7688
  }
8407
7689
 
8408
- static public byte[] expand(byte list[]) {
7690
+ static public byte[] expand(byte[] list) {
8409
7691
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8410
7692
  }
8411
7693
 
8412
- static public byte[] expand(byte list[], int newSize) {
8413
- byte temp[] = new byte[newSize];
7694
+ static public byte[] expand(byte[] list, int newSize) {
7695
+ byte[] temp = new byte[newSize];
8414
7696
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8415
7697
  return temp;
8416
7698
  }
8417
7699
 
8418
- static public char[] expand(char list[]) {
7700
+ static public char[] expand(char[] list) {
8419
7701
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8420
7702
  }
8421
7703
 
8422
- static public char[] expand(char list[], int newSize) {
8423
- char temp[] = new char[newSize];
7704
+ static public char[] expand(char[] list, int newSize) {
7705
+ char[] temp = new char[newSize];
8424
7706
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8425
7707
  return temp;
8426
7708
  }
8427
7709
 
8428
- static public int[] expand(int list[]) {
7710
+ static public int[] expand(int[] list) {
8429
7711
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8430
7712
  }
8431
7713
 
8432
- static public int[] expand(int list[], int newSize) {
8433
- int temp[] = new int[newSize];
7714
+ static public int[] expand(int[] list, int newSize) {
7715
+ int[] temp = new int[newSize];
8434
7716
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8435
7717
  return temp;
8436
7718
  }
8437
7719
 
8438
- static public long[] expand(long list[]) {
7720
+ static public long[] expand(long[] list) {
8439
7721
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8440
7722
  }
8441
7723
 
8442
- static public long[] expand(long list[], int newSize) {
8443
- long temp[] = new long[newSize];
7724
+ static public long[] expand(long[] list, int newSize) {
7725
+ long[] temp = new long[newSize];
8444
7726
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8445
7727
  return temp;
8446
7728
  }
8447
7729
 
8448
- static public float[] expand(float list[]) {
7730
+ static public float[] expand(float[] list) {
8449
7731
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8450
7732
  }
8451
7733
 
8452
- static public float[] expand(float list[], int newSize) {
8453
- float temp[] = new float[newSize];
7734
+ static public float[] expand(float[] list, int newSize) {
7735
+ float[] temp = new float[newSize];
8454
7736
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8455
7737
  return temp;
8456
7738
  }
8457
7739
 
8458
- static public double[] expand(double list[]) {
7740
+ static public double[] expand(double[] list) {
8459
7741
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8460
7742
  }
8461
7743
 
8462
- static public double[] expand(double list[], int newSize) {
8463
- double temp[] = new double[newSize];
7744
+ static public double[] expand(double[] list, int newSize) {
7745
+ double[] temp = new double[newSize];
8464
7746
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8465
7747
  return temp;
8466
7748
  }
8467
7749
 
8468
- static public String[] expand(String list[]) {
7750
+ static public String[] expand(String[] list) {
8469
7751
  return expand(list, list.length > 0 ? list.length << 1 : 1);
8470
7752
  }
8471
7753
 
8472
- static public String[] expand(String list[], int newSize) {
8473
- String temp[] = new String[newSize];
7754
+ static public String[] expand(String[] list, int newSize) {
7755
+ String[] temp = new String[newSize];
8474
7756
  // in case the new size is smaller than list.length
8475
7757
  System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
8476
7758
  return temp;
@@ -8501,7 +7783,7 @@ public class PApplet implements PConstants {
8501
7783
  * Expands an array by one element and adds data to the new position. The
8502
7784
  * datatype of the <b>element</b> parameter must be the same as the
8503
7785
  * datatype of the array.
8504
- * <br/> <br/>
7786
+ *
8505
7787
  * When using an array of objects, the data returned from the function must
8506
7788
  * be cast to the object array's data type. For example: <em>SomeClass[]
8507
7789
  * items = (SomeClass[]) append(originalArray, element)</em>.
@@ -8514,31 +7796,31 @@ public class PApplet implements PConstants {
8514
7796
  * @see PApplet#shorten(boolean[])
8515
7797
  * @see PApplet#expand(boolean[])
8516
7798
  */
8517
- static public byte[] append(byte array[], byte value) {
7799
+ static public byte[] append(byte[] array, byte value) {
8518
7800
  array = expand(array, array.length + 1);
8519
7801
  array[array.length-1] = value;
8520
7802
  return array;
8521
7803
  }
8522
7804
 
8523
- static public char[] append(char array[], char value) {
7805
+ static public char[] append(char[] array, char value) {
8524
7806
  array = expand(array, array.length + 1);
8525
7807
  array[array.length-1] = value;
8526
7808
  return array;
8527
7809
  }
8528
7810
 
8529
- static public int[] append(int array[], int value) {
7811
+ static public int[] append(int[] array, int value) {
8530
7812
  array = expand(array, array.length + 1);
8531
7813
  array[array.length-1] = value;
8532
7814
  return array;
8533
7815
  }
8534
7816
 
8535
- static public float[] append(float array[], float value) {
7817
+ static public float[] append(float[] array, float value) {
8536
7818
  array = expand(array, array.length + 1);
8537
7819
  array[array.length-1] = value;
8538
7820
  return array;
8539
7821
  }
8540
7822
 
8541
- static public String[] append(String array[], String value) {
7823
+ static public String[] append(String[] array, String value) {
8542
7824
  array = expand(array, array.length + 1);
8543
7825
  array[array.length-1] = value;
8544
7826
  return array;
@@ -8556,7 +7838,7 @@ public class PApplet implements PConstants {
8556
7838
  * ( begin auto-generated from shorten.xml )
8557
7839
  *
8558
7840
  * Decreases an array by one element and returns the shortened array.
8559
- * <br/> <br/>
7841
+ *
8560
7842
  * When using an array of objects, the data returned from the function must
8561
7843
  * be cast to the object array's data type. For example: <em>SomeClass[]
8562
7844
  * items = (SomeClass[]) shorten(originalArray)</em>.
@@ -8568,27 +7850,27 @@ public class PApplet implements PConstants {
8568
7850
  * @see PApplet#append(byte[], byte)
8569
7851
  * @see PApplet#expand(boolean[])
8570
7852
  */
8571
- static public boolean[] shorten(boolean list[]) {
7853
+ static public boolean[] shorten(boolean[] list) {
8572
7854
  return subset(list, 0, list.length-1);
8573
7855
  }
8574
7856
 
8575
- static public byte[] shorten(byte list[]) {
7857
+ static public byte[] shorten(byte[] list) {
8576
7858
  return subset(list, 0, list.length-1);
8577
7859
  }
8578
7860
 
8579
- static public char[] shorten(char list[]) {
7861
+ static public char[] shorten(char[] list) {
8580
7862
  return subset(list, 0, list.length-1);
8581
7863
  }
8582
7864
 
8583
- static public int[] shorten(int list[]) {
7865
+ static public int[] shorten(int[] list) {
8584
7866
  return subset(list, 0, list.length-1);
8585
7867
  }
8586
7868
 
8587
- static public float[] shorten(float list[]) {
7869
+ static public float[] shorten(float[] list) {
8588
7870
  return subset(list, 0, list.length-1);
8589
7871
  }
8590
7872
 
8591
- static public String[] shorten(String list[]) {
7873
+ static public String[] shorten(String[] list) {
8592
7874
  return subset(list, 0, list.length-1);
8593
7875
  }
8594
7876
 
@@ -8605,7 +7887,7 @@ public class PApplet implements PConstants {
8605
7887
  * parameters must be of the same datatype. The <b>array</b> parameter
8606
7888
  * defines the array which will be modified and the second parameter
8607
7889
  * defines the data which will be inserted.
8608
- * <br/> <br/>
7890
+ *
8609
7891
  * When using an array of objects, the data returned from the function must
8610
7892
  * be cast to the object array's data type. For example: <em>SomeClass[]
8611
7893
  * items = (SomeClass[]) splice(array1, array2, index)</em>.
@@ -8618,9 +7900,9 @@ public class PApplet implements PConstants {
8618
7900
  * @see PApplet#concat(boolean[], boolean[])
8619
7901
  * @see PApplet#subset(boolean[], int, int)
8620
7902
  */
8621
- static final public boolean[] splice(boolean list[],
7903
+ static final public boolean[] splice(boolean[] list,
8622
7904
  boolean value, int index) {
8623
- boolean outgoing[] = new boolean[list.length + 1];
7905
+ boolean[] outgoing = new boolean[list.length + 1];
8624
7906
  System.arraycopy(list, 0, outgoing, 0, index);
8625
7907
  outgoing[index] = value;
8626
7908
  System.arraycopy(list, index, outgoing, index + 1,
@@ -8628,9 +7910,9 @@ public class PApplet implements PConstants {
8628
7910
  return outgoing;
8629
7911
  }
8630
7912
 
8631
- static final public boolean[] splice(boolean list[],
8632
- boolean value[], int index) {
8633
- boolean outgoing[] = new boolean[list.length + value.length];
7913
+ static final public boolean[] splice(boolean[] list,
7914
+ boolean[] value, int index) {
7915
+ boolean[] outgoing = new boolean[list.length + value.length];
8634
7916
  System.arraycopy(list, 0, outgoing, 0, index);
8635
7917
  System.arraycopy(value, 0, outgoing, index, value.length);
8636
7918
  System.arraycopy(list, index, outgoing, index + value.length,
@@ -8638,9 +7920,9 @@ public class PApplet implements PConstants {
8638
7920
  return outgoing;
8639
7921
  }
8640
7922
 
8641
- static final public byte[] splice(byte list[],
7923
+ static final public byte[] splice(byte[] list,
8642
7924
  byte value, int index) {
8643
- byte outgoing[] = new byte[list.length + 1];
7925
+ byte[] outgoing = new byte[list.length + 1];
8644
7926
  System.arraycopy(list, 0, outgoing, 0, index);
8645
7927
  outgoing[index] = value;
8646
7928
  System.arraycopy(list, index, outgoing, index + 1,
@@ -8648,9 +7930,9 @@ public class PApplet implements PConstants {
8648
7930
  return outgoing;
8649
7931
  }
8650
7932
 
8651
- static final public byte[] splice(byte list[],
8652
- byte value[], int index) {
8653
- byte outgoing[] = new byte[list.length + value.length];
7933
+ static final public byte[] splice(byte[] list,
7934
+ byte[] value, int index) {
7935
+ byte[] outgoing = new byte[list.length + value.length];
8654
7936
  System.arraycopy(list, 0, outgoing, 0, index);
8655
7937
  System.arraycopy(value, 0, outgoing, index, value.length);
8656
7938
  System.arraycopy(list, index, outgoing, index + value.length,
@@ -8659,9 +7941,9 @@ public class PApplet implements PConstants {
8659
7941
  }
8660
7942
 
8661
7943
 
8662
- static final public char[] splice(char list[],
7944
+ static final public char[] splice(char[] list,
8663
7945
  char value, int index) {
8664
- char outgoing[] = new char[list.length + 1];
7946
+ char[] outgoing = new char[list.length + 1];
8665
7947
  System.arraycopy(list, 0, outgoing, 0, index);
8666
7948
  outgoing[index] = value;
8667
7949
  System.arraycopy(list, index, outgoing, index + 1,
@@ -8669,9 +7951,9 @@ public class PApplet implements PConstants {
8669
7951
  return outgoing;
8670
7952
  }
8671
7953
 
8672
- static final public char[] splice(char list[],
8673
- char value[], int index) {
8674
- char outgoing[] = new char[list.length + value.length];
7954
+ static final public char[] splice(char[] list,
7955
+ char[] value, int index) {
7956
+ char[] outgoing = new char[list.length + value.length];
8675
7957
  System.arraycopy(list, 0, outgoing, 0, index);
8676
7958
  System.arraycopy(value, 0, outgoing, index, value.length);
8677
7959
  System.arraycopy(list, index, outgoing, index + value.length,
@@ -8679,9 +7961,9 @@ public class PApplet implements PConstants {
8679
7961
  return outgoing;
8680
7962
  }
8681
7963
 
8682
- static final public int[] splice(int list[],
7964
+ static final public int[] splice(int[] list,
8683
7965
  int value, int index) {
8684
- int outgoing[] = new int[list.length + 1];
7966
+ int[] outgoing = new int[list.length + 1];
8685
7967
  System.arraycopy(list, 0, outgoing, 0, index);
8686
7968
  outgoing[index] = value;
8687
7969
  System.arraycopy(list, index, outgoing, index + 1,
@@ -8689,9 +7971,9 @@ public class PApplet implements PConstants {
8689
7971
  return outgoing;
8690
7972
  }
8691
7973
 
8692
- static final public int[] splice(int list[],
8693
- int value[], int index) {
8694
- int outgoing[] = new int[list.length + value.length];
7974
+ static final public int[] splice(int[] list,
7975
+ int[] value, int index) {
7976
+ int[] outgoing = new int[list.length + value.length];
8695
7977
  System.arraycopy(list, 0, outgoing, 0, index);
8696
7978
  System.arraycopy(value, 0, outgoing, index, value.length);
8697
7979
  System.arraycopy(list, index, outgoing, index + value.length,
@@ -8699,9 +7981,9 @@ public class PApplet implements PConstants {
8699
7981
  return outgoing;
8700
7982
  }
8701
7983
 
8702
- static final public float[] splice(float list[],
7984
+ static final public float[] splice(float[] list,
8703
7985
  float value, int index) {
8704
- float outgoing[] = new float[list.length + 1];
7986
+ float[] outgoing = new float[list.length + 1];
8705
7987
  System.arraycopy(list, 0, outgoing, 0, index);
8706
7988
  outgoing[index] = value;
8707
7989
  System.arraycopy(list, index, outgoing, index + 1,
@@ -8709,9 +7991,9 @@ public class PApplet implements PConstants {
8709
7991
  return outgoing;
8710
7992
  }
8711
7993
 
8712
- static final public float[] splice(float list[],
8713
- float value[], int index) {
8714
- float outgoing[] = new float[list.length + value.length];
7994
+ static final public float[] splice(float[] list,
7995
+ float[] value, int index) {
7996
+ float[] outgoing = new float[list.length + value.length];
8715
7997
  System.arraycopy(list, 0, outgoing, 0, index);
8716
7998
  System.arraycopy(value, 0, outgoing, index, value.length);
8717
7999
  System.arraycopy(list, index, outgoing, index + value.length,
@@ -8719,9 +8001,9 @@ public class PApplet implements PConstants {
8719
8001
  return outgoing;
8720
8002
  }
8721
8003
 
8722
- static final public String[] splice(String list[],
8004
+ static final public String[] splice(String[] list,
8723
8005
  String value, int index) {
8724
- String outgoing[] = new String[list.length + 1];
8006
+ String[] outgoing = new String[list.length + 1];
8725
8007
  System.arraycopy(list, 0, outgoing, 0, index);
8726
8008
  outgoing[index] = value;
8727
8009
  System.arraycopy(list, index, outgoing, index + 1,
@@ -8729,9 +8011,9 @@ public class PApplet implements PConstants {
8729
8011
  return outgoing;
8730
8012
  }
8731
8013
 
8732
- static final public String[] splice(String list[],
8733
- String value[], int index) {
8734
- String outgoing[] = new String[list.length + value.length];
8014
+ static final public String[] splice(String[] list,
8015
+ String[] value, int index) {
8016
+ String[] outgoing = new String[list.length + value.length];
8735
8017
  System.arraycopy(list, 0, outgoing, 0, index);
8736
8018
  System.arraycopy(value, 0, outgoing, index, value.length);
8737
8019
  System.arraycopy(list, index, outgoing, index + value.length,
@@ -8777,7 +8059,7 @@ public class PApplet implements PConstants {
8777
8059
  * from the <b>offset</b> to the end of the array. When specifying the
8778
8060
  * <b>offset</b> remember the first array element is 0. This function does
8779
8061
  * not change the source array.
8780
- * <br/> <br/>
8062
+ *
8781
8063
  * When using an array of objects, the data returned from the function must
8782
8064
  * be cast to the object array's data type. For example: <em>SomeClass[]
8783
8065
  * items = (SomeClass[]) subset(originalArray, 0, 4)</em>.
@@ -8900,7 +8182,7 @@ public class PApplet implements PConstants {
8900
8182
  * Concatenates two arrays. For example, concatenating the array { 1, 2, 3
8901
8183
  * } and the array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters
8902
8184
  * must be arrays of the same datatype.
8903
- * <br/> <br/>
8185
+ *
8904
8186
  * When using an array of objects, the data returned from the function must
8905
8187
  * be cast to the object array's data type. For example: <em>SomeClass[]
8906
8188
  * items = (SomeClass[]) concat(array1, array2)</em>.
@@ -8912,43 +8194,43 @@ public class PApplet implements PConstants {
8912
8194
  * @see PApplet#splice(boolean[], boolean, int)
8913
8195
  * @see PApplet#arrayCopy(Object, int, Object, int, int)
8914
8196
  */
8915
- static public boolean[] concat(boolean a[], boolean b[]) {
8916
- boolean c[] = new boolean[a.length + b.length];
8197
+ static public boolean[] concat(boolean[] a, boolean[] b) {
8198
+ boolean[] c = new boolean[a.length + b.length];
8917
8199
  System.arraycopy(a, 0, c, 0, a.length);
8918
8200
  System.arraycopy(b, 0, c, a.length, b.length);
8919
8201
  return c;
8920
8202
  }
8921
8203
 
8922
- static public byte[] concat(byte a[], byte b[]) {
8923
- byte c[] = new byte[a.length + b.length];
8204
+ static public byte[] concat(byte[] a, byte[] b) {
8205
+ byte[] c = new byte[a.length + b.length];
8924
8206
  System.arraycopy(a, 0, c, 0, a.length);
8925
8207
  System.arraycopy(b, 0, c, a.length, b.length);
8926
8208
  return c;
8927
8209
  }
8928
8210
 
8929
- static public char[] concat(char a[], char b[]) {
8930
- char c[] = new char[a.length + b.length];
8211
+ static public char[] concat(char[] a, char[] b) {
8212
+ char[] c = new char[a.length + b.length];
8931
8213
  System.arraycopy(a, 0, c, 0, a.length);
8932
8214
  System.arraycopy(b, 0, c, a.length, b.length);
8933
8215
  return c;
8934
8216
  }
8935
8217
 
8936
- static public int[] concat(int a[], int b[]) {
8937
- int c[] = new int[a.length + b.length];
8218
+ static public int[] concat(int[] a, int[] b) {
8219
+ int[] c = new int[a.length + b.length];
8938
8220
  System.arraycopy(a, 0, c, 0, a.length);
8939
8221
  System.arraycopy(b, 0, c, a.length, b.length);
8940
8222
  return c;
8941
8223
  }
8942
8224
 
8943
- static public float[] concat(float a[], float b[]) {
8944
- float c[] = new float[a.length + b.length];
8225
+ static public float[] concat(float[] a, float[] b) {
8226
+ float[] c = new float[a.length + b.length];
8945
8227
  System.arraycopy(a, 0, c, 0, a.length);
8946
8228
  System.arraycopy(b, 0, c, a.length, b.length);
8947
8229
  return c;
8948
8230
  }
8949
8231
 
8950
- static public String[] concat(String a[], String b[]) {
8951
- String c[] = new String[a.length + b.length];
8232
+ static public String[] concat(String[] a, String[] b) {
8233
+ String[] c = new String[a.length + b.length];
8952
8234
  System.arraycopy(a, 0, c, 0, a.length);
8953
8235
  System.arraycopy(b, 0, c, a.length, b.length);
8954
8236
  return c;
@@ -8977,8 +8259,8 @@ public class PApplet implements PConstants {
8977
8259
  * @param list booleans[], bytes[], chars[], ints[], floats[], or Strings[]
8978
8260
  * @see PApplet#sort(String[], int)
8979
8261
  */
8980
- static public boolean[] reverse(boolean list[]) {
8981
- boolean outgoing[] = new boolean[list.length];
8262
+ static public boolean[] reverse(boolean[] list) {
8263
+ boolean[] outgoing = new boolean[list.length];
8982
8264
  int length1 = list.length - 1;
8983
8265
  for (int i = 0; i < list.length; i++) {
8984
8266
  outgoing[i] = list[length1 - i];
@@ -8986,8 +8268,8 @@ public class PApplet implements PConstants {
8986
8268
  return outgoing;
8987
8269
  }
8988
8270
 
8989
- static public byte[] reverse(byte list[]) {
8990
- byte outgoing[] = new byte[list.length];
8271
+ static public byte[] reverse(byte[] list) {
8272
+ byte[] outgoing = new byte[list.length];
8991
8273
  int length1 = list.length - 1;
8992
8274
  for (int i = 0; i < list.length; i++) {
8993
8275
  outgoing[i] = list[length1 - i];
@@ -8995,8 +8277,8 @@ public class PApplet implements PConstants {
8995
8277
  return outgoing;
8996
8278
  }
8997
8279
 
8998
- static public char[] reverse(char list[]) {
8999
- char outgoing[] = new char[list.length];
8280
+ static public char[] reverse(char[] list) {
8281
+ char[] outgoing = new char[list.length];
9000
8282
  int length1 = list.length - 1;
9001
8283
  for (int i = 0; i < list.length; i++) {
9002
8284
  outgoing[i] = list[length1 - i];
@@ -9004,8 +8286,8 @@ public class PApplet implements PConstants {
9004
8286
  return outgoing;
9005
8287
  }
9006
8288
 
9007
- static public int[] reverse(int list[]) {
9008
- int outgoing[] = new int[list.length];
8289
+ static public int[] reverse(int[] list) {
8290
+ int[] outgoing = new int[list.length];
9009
8291
  int length1 = list.length - 1;
9010
8292
  for (int i = 0; i < list.length; i++) {
9011
8293
  outgoing[i] = list[length1 - i];
@@ -9013,8 +8295,8 @@ public class PApplet implements PConstants {
9013
8295
  return outgoing;
9014
8296
  }
9015
8297
 
9016
- static public float[] reverse(float list[]) {
9017
- float outgoing[] = new float[list.length];
8298
+ static public float[] reverse(float[] list) {
8299
+ float[] outgoing = new float[list.length];
9018
8300
  int length1 = list.length - 1;
9019
8301
  for (int i = 0; i < list.length; i++) {
9020
8302
  outgoing[i] = list[length1 - i];
@@ -9022,8 +8304,8 @@ public class PApplet implements PConstants {
9022
8304
  return outgoing;
9023
8305
  }
9024
8306
 
9025
- static public String[] reverse(String list[]) {
9026
- String outgoing[] = new String[list.length];
8307
+ static public String[] reverse(String[] list) {
8308
+ String[] outgoing = new String[list.length];
9027
8309
  int length1 = list.length - 1;
9028
8310
  for (int i = 0; i < list.length; i++) {
9029
8311
  outgoing[i] = list[length1 - i];
@@ -9129,7 +8411,7 @@ public class PApplet implements PConstants {
9129
8411
  * The splitTokens() function splits a String at one or many character
9130
8412
  * "tokens." The <b>tokens</b> parameter specifies the character or
9131
8413
  * characters to be used as a boundary.
9132
- * <br/> <br/>
8414
+ *
9133
8415
  * If no <b>tokens</b> character is specified, any whitespace character is
9134
8416
  * used to split. Whitespace characters include tab (\\t), line feed (\\n),
9135
8417
  * carriage return (\\r), form feed (\\f), and space. To convert a String
@@ -9146,7 +8428,7 @@ public class PApplet implements PConstants {
9146
8428
  */
9147
8429
  static public String[] splitTokens(String value, String delim) {
9148
8430
  StringTokenizer toker = new StringTokenizer(value, delim);
9149
- String pieces[] = new String[toker.countTokens()];
8431
+ String[] pieces = new String[toker.countTokens()];
9150
8432
 
9151
8433
  int index = 0;
9152
8434
  while (toker.hasMoreTokens()) {
@@ -9163,15 +8445,15 @@ public class PApplet implements PConstants {
9163
8445
  * string as the divider. The <b>delim</b> parameter specifies the
9164
8446
  * character or characters that mark the boundaries between each piece. A
9165
8447
  * String[] array is returned that contains each of the pieces.
9166
- * <br/> <br/>
8448
+ *
9167
8449
  * If the result is a set of numbers, you can convert the String[] array to
9168
8450
  * to a float[] or int[] array using the datatype conversion functions
9169
8451
  * <b>int()</b> and <b>float()</b> (see example above).
9170
- * <br/> <br/>
8452
+ *
9171
8453
  * The <b>splitTokens()</b> function works in a similar fashion, except
9172
8454
  * that it splits using a range of characters instead of a specific
9173
8455
  * character or sequence.
9174
- * <!-- /><br />
8456
+ * <!-- />
9175
8457
  * This function uses regular expressions to determine how the <b>delim</b>
9176
8458
  * parameter divides the <b>str</b> parameter. Therefore, if you use
9177
8459
  * characters such parentheses and brackets that are used with regular
@@ -9196,10 +8478,10 @@ public class PApplet implements PConstants {
9196
8478
  if (value == null) return null;
9197
8479
  //return split(what, String.valueOf(delim)); // huh
9198
8480
 
9199
- char chars[] = value.toCharArray();
8481
+ char[] chars = value.toCharArray();
9200
8482
  int splitCount = 0; //1;
9201
- for (int i = 0; i < chars.length; i++) {
9202
- if (chars[i] == delim) splitCount++;
8483
+ for (char ch : chars) {
8484
+ if (ch == delim) splitCount++;
9203
8485
  }
9204
8486
  // make sure that there is something in the input string
9205
8487
  //if (chars.length > 0) {
@@ -9208,12 +8490,12 @@ public class PApplet implements PConstants {
9208
8490
  // on second thought, i don't agree with this, will disable
9209
8491
  //}
9210
8492
  if (splitCount == 0) {
9211
- String splits[] = new String[1];
8493
+ String[] splits = new String[1];
9212
8494
  splits[0] = value;
9213
8495
  return splits;
9214
8496
  }
9215
8497
  //int pieceCount = splitCount + 1;
9216
- String splits[] = new String[splitCount + 1];
8498
+ String[] splits = new String[splitCount + 1];
9217
8499
  int splitIndex = 0;
9218
8500
  int startIndex = 0;
9219
8501
  for (int i = 0; i < chars.length; i++) {
@@ -9251,7 +8533,7 @@ public class PApplet implements PConstants {
9251
8533
  static Pattern matchPattern(String regexp) {
9252
8534
  Pattern p = null;
9253
8535
  if (matchPatterns == null) {
9254
- matchPatterns = new LinkedHashMap<String, Pattern>(16, 0.75f, true) {
8536
+ matchPatterns = new LinkedHashMap<>(16, 0.75f, true) {
9255
8537
  @Override
9256
8538
  protected boolean removeEldestEntry(Map.Entry<String, Pattern> eldest) {
9257
8539
  // Limit the number of match patterns at 10 most recently used
@@ -9276,8 +8558,8 @@ public class PApplet implements PConstants {
9276
8558
  * text, and return matching groups (elements found inside parentheses) as
9277
8559
  * a String array. No match will return null. If no groups are specified in
9278
8560
  * the regexp, but the sequence matches, an array of length one (with the
9279
- * matched text as the first element of the array) will be returned.<br />
9280
- * <br />
8561
+ * matched text as the first element of the array) will be returned.
8562
+ *
9281
8563
  * To use the function, first check to see if the result is null. If the
9282
8564
  * result is null, then the sequence did not match. If the sequence did
9283
8565
  * match, an array is returned.
@@ -9285,8 +8567,8 @@ public class PApplet implements PConstants {
9285
8567
  * then the contents of each will be returned in the array.
9286
8568
  * Element [0] of a regexp match returns the entire matching string, and
9287
8569
  * the match groups start at element [1] (the first group is [1], the
9288
- * second [2], and so on).<br />
9289
- * <br />
8570
+ * second [2], and so on).
8571
+ *
9290
8572
  * The syntax can be found in the reference for Java's <a
9291
8573
  * href="http://download.oracle.com/javase/6/docs/api/">Pattern</a> class.
9292
8574
  * For regular expression syntax, read the <a
@@ -9326,8 +8608,8 @@ public class PApplet implements PConstants {
9326
8608
  * as a two-dimensional String array. No matches will return null. If no
9327
8609
  * groups are specified in the regexp, but the sequence matches, a two
9328
8610
  * dimensional array is still returned, but the second dimension is only of
9329
- * length one.<br />
9330
- * <br />
8611
+ * length one.
8612
+ *
9331
8613
  * To use the function, first check to see if the result is null. If the
9332
8614
  * result is null, then the sequence did not match at all. If the sequence
9333
8615
  * did match, a 2D array is returned. If there are groups (specified by
@@ -9336,8 +8618,8 @@ public class PApplet implements PConstants {
9336
8618
  * Assuming, a loop with counter variable i, element [i][0] of a regexp
9337
8619
  * match returns the entire matching string, and the match groups start at
9338
8620
  * element [i][1] (the first group is [i][1], the second [i][2], and so
9339
- * on).<br />
9340
- * <br />
8621
+ * on).
8622
+ *
9341
8623
  * The syntax can be found in the reference for Java's <a
9342
8624
  * href="http://download.oracle.com/javase/6/docs/api/">Pattern</a> class.
9343
8625
  * For regular expression syntax, read the <a
@@ -9454,8 +8736,8 @@ public class PApplet implements PConstants {
9454
8736
  * to zero will return false, and any other value will return true.
9455
8737
  * @return array of boolean elements
9456
8738
  */
9457
- static final public boolean[] parseBoolean(int what[]) {
9458
- boolean outgoing[] = new boolean[what.length];
8739
+ static final public boolean[] parseBoolean(int[] what) {
8740
+ boolean[] outgoing = new boolean[what.length];
9459
8741
  for (int i = 0; i < what.length; i++) {
9460
8742
  outgoing[i] = (what[i] != 0);
9461
8743
  }
@@ -9473,8 +8755,8 @@ public class PApplet implements PConstants {
9473
8755
  }
9474
8756
  */
9475
8757
 
9476
- static final public boolean[] parseBoolean(String what[]) {
9477
- boolean outgoing[] = new boolean[what.length];
8758
+ static final public boolean[] parseBoolean(String[] what) {
8759
+ boolean[] outgoing = new boolean[what.length];
9478
8760
  for (int i = 0; i < what.length; i++) {
9479
8761
  outgoing[i] = Boolean.parseBoolean(what[i]);
9480
8762
  }
@@ -9508,32 +8790,32 @@ public class PApplet implements PConstants {
9508
8790
 
9509
8791
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9510
8792
 
9511
- static final public byte[] parseByte(boolean what[]) {
9512
- byte outgoing[] = new byte[what.length];
8793
+ static final public byte[] parseByte(boolean[] what) {
8794
+ byte[] outgoing = new byte[what.length];
9513
8795
  for (int i = 0; i < what.length; i++) {
9514
8796
  outgoing[i] = what[i] ? (byte)1 : 0;
9515
8797
  }
9516
8798
  return outgoing;
9517
8799
  }
9518
8800
 
9519
- static final public byte[] parseByte(char what[]) {
9520
- byte outgoing[] = new byte[what.length];
8801
+ static final public byte[] parseByte(char[] what) {
8802
+ byte[] outgoing = new byte[what.length];
9521
8803
  for (int i = 0; i < what.length; i++) {
9522
8804
  outgoing[i] = (byte) what[i];
9523
8805
  }
9524
8806
  return outgoing;
9525
8807
  }
9526
8808
 
9527
- static final public byte[] parseByte(int what[]) {
9528
- byte outgoing[] = new byte[what.length];
8809
+ static final public byte[] parseByte(int[] what) {
8810
+ byte[] outgoing = new byte[what.length];
9529
8811
  for (int i = 0; i < what.length; i++) {
9530
8812
  outgoing[i] = (byte) what[i];
9531
8813
  }
9532
8814
  return outgoing;
9533
8815
  }
9534
8816
 
9535
- static final public byte[] parseByte(float what[]) {
9536
- byte outgoing[] = new byte[what.length];
8817
+ static final public byte[] parseByte(float[] what) {
8818
+ byte[] outgoing = new byte[what.length];
9537
8819
  for (int i = 0; i < what.length; i++) {
9538
8820
  outgoing[i] = (byte) what[i];
9539
8821
  }
@@ -9588,8 +8870,8 @@ public class PApplet implements PConstants {
9588
8870
  }
9589
8871
  */
9590
8872
 
9591
- static final public char[] parseChar(byte what[]) {
9592
- char outgoing[] = new char[what.length];
8873
+ static final public char[] parseChar(byte[] what) {
8874
+ char[] outgoing = new char[what.length];
9593
8875
  for (int i = 0; i < what.length; i++) {
9594
8876
  outgoing[i] = (char) (what[i] & 0xff);
9595
8877
  }
@@ -9605,8 +8887,8 @@ public class PApplet implements PConstants {
9605
8887
  }
9606
8888
 
9607
8889
  /*
9608
- static final public char[] parseChar(float what[]) { // nonsensical
9609
- char outgoing[] = new char[what.length];
8890
+ static final public char[] parseChar(int[] what) {
8891
+ char[] outgoing = new char[what.length];
9610
8892
  for (int i = 0; i < what.length; i++) {
9611
8893
  outgoing[i] = (char) what[i];
9612
8894
  }
@@ -9676,32 +8958,32 @@ public class PApplet implements PConstants {
9676
8958
 
9677
8959
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9678
8960
 
9679
- static final public int[] parseInt(boolean what[]) {
9680
- int list[] = new int[what.length];
8961
+ static final public int[] parseInt(boolean[] what) {
8962
+ int[] list = new int[what.length];
9681
8963
  for (int i = 0; i < what.length; i++) {
9682
8964
  list[i] = what[i] ? 1 : 0;
9683
8965
  }
9684
8966
  return list;
9685
8967
  }
9686
8968
 
9687
- static final public int[] parseInt(byte what[]) { // note this unsigns
9688
- int list[] = new int[what.length];
8969
+ static final public int[] parseInt(byte[] what) { // note this unsigns
8970
+ int[] list = new int[what.length];
9689
8971
  for (int i = 0; i < what.length; i++) {
9690
8972
  list[i] = (what[i] & 0xff);
9691
8973
  }
9692
8974
  return list;
9693
8975
  }
9694
8976
 
9695
- static final public int[] parseInt(char what[]) {
9696
- int list[] = new int[what.length];
8977
+ static final public int[] parseInt(char[] what) {
8978
+ int[] list = new int[what.length];
9697
8979
  for (int i = 0; i < what.length; i++) {
9698
8980
  list[i] = what[i];
9699
8981
  }
9700
8982
  return list;
9701
8983
  }
9702
8984
 
9703
- static public int[] parseInt(float what[]) {
9704
- int inties[] = new int[what.length];
8985
+ static public int[] parseInt(float[] what) {
8986
+ int[] inties = new int[what.length];
9705
8987
  for (int i = 0; i < what.length; i++) {
9706
8988
  inties[i] = (int)what[i];
9707
8989
  }
@@ -9717,7 +8999,7 @@ public class PApplet implements PConstants {
9717
8999
  *
9718
9000
  * numbers will contain { 1, 300, 44 }
9719
9001
  */
9720
- static public int[] parseInt(String what[]) {
9002
+ static public int[] parseInt(String[] what) {
9721
9003
  return parseInt(what, 0);
9722
9004
  }
9723
9005
 
@@ -9731,8 +9013,8 @@ public class PApplet implements PConstants {
9731
9013
  *
9732
9014
  * numbers will contain { 1, 300, 9999, 44 }
9733
9015
  */
9734
- static public int[] parseInt(String what[], int missing) {
9735
- int output[] = new int[what.length];
9016
+ static public int[] parseInt(String[] what, int missing) {
9017
+ int[] output = new int[what.length];
9736
9018
  for (int i = 0; i < what.length; i++) {
9737
9019
  try {
9738
9020
  output[i] = Integer.parseInt(what[i]);
@@ -9773,46 +9055,28 @@ public class PApplet implements PConstants {
9773
9055
 
9774
9056
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9775
9057
 
9776
- /*
9777
- static final public float[] parseFloat(boolean what[]) {
9778
- float floaties[] = new float[what.length];
9779
- for (int i = 0; i < what.length; i++) {
9780
- floaties[i] = what[i] ? 1 : 0;
9781
- }
9782
- return floaties;
9783
- }
9784
-
9785
- static final public float[] parseFloat(char what[]) {
9786
- float floaties[] = new float[what.length];
9787
- for (int i = 0; i < what.length; i++) {
9788
- floaties[i] = (char) what[i];
9789
- }
9790
- return floaties;
9791
- }
9792
- */
9793
-
9794
- static final public float[] parseFloat(byte what[]) {
9795
- float floaties[] = new float[what.length];
9058
+ static final public float[] parseFloat(byte[] what) {
9059
+ float[] floaties = new float[what.length];
9796
9060
  for (int i = 0; i < what.length; i++) {
9797
9061
  floaties[i] = what[i];
9798
9062
  }
9799
9063
  return floaties;
9800
9064
  }
9801
9065
 
9802
- static final public float[] parseFloat(int what[]) {
9803
- float floaties[] = new float[what.length];
9066
+ static final public float[] parseFloat(int[] what) {
9067
+ float[] floaties = new float[what.length];
9804
9068
  for (int i = 0; i < what.length; i++) {
9805
9069
  floaties[i] = what[i];
9806
9070
  }
9807
9071
  return floaties;
9808
9072
  }
9809
9073
 
9810
- static final public float[] parseFloat(String what[]) {
9074
+ static final public float[] parseFloat(String[] what) {
9811
9075
  return parseFloat(what, Float.NaN);
9812
9076
  }
9813
9077
 
9814
- static final public float[] parseFloat(String what[], float missing) {
9815
- float output[] = new float[what.length];
9078
+ static final public float[] parseFloat(String[] what, float missing) {
9079
+ float[] output = new float[what.length];
9816
9080
  for (int i = 0; i < what.length; i++) {
9817
9081
  try {
9818
9082
  output[i] = Float.parseFloat(what[i]);
@@ -9847,32 +9111,32 @@ public class PApplet implements PConstants {
9847
9111
 
9848
9112
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9849
9113
 
9850
- static final public String[] str(boolean x[]) {
9851
- String s[] = new String[x.length];
9114
+ static final public String[] str(boolean[] x) {
9115
+ String[] s = new String[x.length];
9852
9116
  for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
9853
9117
  return s;
9854
9118
  }
9855
9119
 
9856
- static final public String[] str(byte x[]) {
9857
- String s[] = new String[x.length];
9120
+ static final public String[] str(byte[] x) {
9121
+ String[] s = new String[x.length];
9858
9122
  for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
9859
9123
  return s;
9860
9124
  }
9861
9125
 
9862
- static final public String[] str(char x[]) {
9863
- String s[] = new String[x.length];
9126
+ static final public String[] str(char[] x) {
9127
+ String[] s = new String[x.length];
9864
9128
  for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
9865
9129
  return s;
9866
9130
  }
9867
9131
 
9868
- static final public String[] str(int x[]) {
9869
- String s[] = new String[x.length];
9132
+ static final public String[] str(int[] x) {
9133
+ String[] s = new String[x.length];
9870
9134
  for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
9871
9135
  return s;
9872
9136
  }
9873
9137
 
9874
- static final public String[] str(float x[]) {
9875
- String s[] = new String[x.length];
9138
+ static final public String[] str(float[] x) {
9139
+ String[] s = new String[x.length];
9876
9140
  for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
9877
9141
  return s;
9878
9142
  }
@@ -9912,7 +9176,7 @@ public class PApplet implements PConstants {
9912
9176
  * Utility function for formatting numbers into strings. There are two
9913
9177
  * versions, one for formatting floats and one for formatting ints. The
9914
9178
  * values for the <b>digits</b>, <b>left</b>, and <b>right</b> parameters
9915
- * should always be positive integers.<br /><br />As shown in the above
9179
+ * should always be positive integers.As shown in the above
9916
9180
  * example, <b>nf()</b> is used to add zeros to the left and/or right of a
9917
9181
  * number. This is typically for aligning a list of numbers. To
9918
9182
  * <em>remove</em> digits from a floating-point number, use the
@@ -9929,8 +9193,8 @@ public class PApplet implements PConstants {
9929
9193
  * @see <a href="https://processing.org/reference/intconvert_.html">int(float)</a>
9930
9194
  */
9931
9195
 
9932
- static public String[] nf(int nums[], int digits) {
9933
- String formatted[] = new String[nums.length];
9196
+ static public String[] nf(int[] nums, int digits) {
9197
+ String[] formatted = new String[nums.length];
9934
9198
  for (int i = 0; i < formatted.length; i++) {
9935
9199
  formatted[i] = nf(nums[i], digits);
9936
9200
  }
@@ -9962,7 +9226,7 @@ public class PApplet implements PConstants {
9962
9226
  * appropriate commas to mark units of 1000. There are two versions, one
9963
9227
  * for formatting ints and one for formatting an array of ints. The value
9964
9228
  * for the <b>digits</b> parameter should always be a positive integer.
9965
- * <br/><br/>
9229
+ *
9966
9230
  * For a non-US locale, this will insert periods instead of commas, or
9967
9231
  * whatever is apprioriate for that region.
9968
9232
  *
@@ -9973,8 +9237,8 @@ public class PApplet implements PConstants {
9973
9237
  * @see PApplet#nfp(float, int, int)
9974
9238
  * @see PApplet#nfs(float, int, int)
9975
9239
  */
9976
- static public String[] nfc(int nums[]) {
9977
- String formatted[] = new String[nums.length];
9240
+ static public String[] nfc(int[] nums) {
9241
+ String[] formatted = new String[nums.length];
9978
9242
  for (int i = 0; i < formatted.length; i++) {
9979
9243
  formatted[i] = nfc(nums[i]);
9980
9244
  }
@@ -10033,8 +9297,8 @@ public class PApplet implements PConstants {
10033
9297
  /**
10034
9298
  * @param nums the numbers to format
10035
9299
  */
10036
- static public String[] nfs(int nums[], int digits) {
10037
- String formatted[] = new String[nums.length];
9300
+ static public String[] nfs(int[] nums, int digits) {
9301
+ String[] formatted = new String[nums.length];
10038
9302
  for (int i = 0; i < formatted.length; i++) {
10039
9303
  formatted[i] = nfs(nums[i], digits);
10040
9304
  }
@@ -10071,8 +9335,8 @@ public class PApplet implements PConstants {
10071
9335
  /**
10072
9336
  * @param nums the numbers to format
10073
9337
  */
10074
- static public String[] nfp(int nums[], int digits) {
10075
- String formatted[] = new String[nums.length];
9338
+ static public String[] nfp(int[] nums, int digits) {
9339
+ String[] formatted = new String[nums.length];
10076
9340
  for (int i = 0; i < formatted.length; i++) {
10077
9341
  formatted[i] = nfp(nums[i], digits);
10078
9342
  }
@@ -10093,8 +9357,8 @@ public class PApplet implements PConstants {
10093
9357
  * @param left number of digits to the left of the decimal point
10094
9358
  * @param right number of digits to the right of the decimal point
10095
9359
  */
10096
- static public String[] nf(float nums[], int left, int right) {
10097
- String formatted[] = new String[nums.length];
9360
+ static public String[] nf(float[] nums, int left, int right) {
9361
+ String[] formatted = new String[nums.length];
10098
9362
  for (int i = 0; i < formatted.length; i++) {
10099
9363
  formatted[i] = nf(nums[i], left, right);
10100
9364
  }
@@ -10126,8 +9390,8 @@ public class PApplet implements PConstants {
10126
9390
  /**
10127
9391
  * @param right number of digits to the right of the decimal point
10128
9392
  */
10129
- static public String[] nfc(float nums[], int right) {
10130
- String formatted[] = new String[nums.length];
9393
+ static public String[] nfc(float[] nums, int right) {
9394
+ String[] formatted = new String[nums.length];
10131
9395
  for (int i = 0; i < formatted.length; i++) {
10132
9396
  formatted[i] = nfc(nums[i], right);
10133
9397
  }
@@ -10160,8 +9424,8 @@ public class PApplet implements PConstants {
10160
9424
  * @param left the number of digits to the left of the decimal point
10161
9425
  * @param right the number of digits to the right of the decimal point
10162
9426
  */
10163
- static public String[] nfs(float nums[], int left, int right) {
10164
- String formatted[] = new String[nums.length];
9427
+ static public String[] nfs(float[] nums, int left, int right) {
9428
+ String[] formatted = new String[nums.length];
10165
9429
  for (int i = 0; i < formatted.length; i++) {
10166
9430
  formatted[i] = nfs(nums[i], left, right);
10167
9431
  }
@@ -10176,8 +9440,8 @@ public class PApplet implements PConstants {
10176
9440
  * @param left the number of digits to the left of the decimal point
10177
9441
  * @param right the number of digits to the right of the decimal point
10178
9442
  */
10179
- static public String[] nfp(float nums[], int left, int right) {
10180
- String formatted[] = new String[nums.length];
9443
+ static public String[] nfp(float[] nums, int left, int right) {
9444
+ String[] formatted = new String[nums.length];
10181
9445
  for (int i = 0; i < formatted.length; i++) {
10182
9446
  formatted[i] = nfp(nums[i], left, right);
10183
9447
  }
@@ -10202,7 +9466,7 @@ public class PApplet implements PConstants {
10202
9466
  * equivalent hexadecimal notation. For example color(0, 102, 153) will
10203
9467
  * convert to the String "FF006699". This function can help make your geeky
10204
9468
  * debugging sessions much happier.
10205
- * <br/> <br/>
9469
+ *
10206
9470
  * Note that the maximum number of digits is 8, because an int value can
10207
9471
  * only represent up to 32 bits. Specifying more than eight digits will
10208
9472
  * simply shorten the string to eight anyway.
@@ -10303,7 +9567,7 @@ public class PApplet implements PConstants {
10303
9567
  * equivalent binary notation. For example color(0, 102, 153, 255) will
10304
9568
  * convert to the String "11111111000000000110011010011001". This function
10305
9569
  * can help make your geeky debugging sessions much happier.
10306
- * <br/> <br/>
9570
+ *
10307
9571
  * Note that the maximum number of digits is 32, because an int value can
10308
9572
  * only represent up to 32 bits. Specifying more than 32 digits will simply
10309
9573
  * shorten the string to 32 anyway.
@@ -10655,36 +9919,12 @@ public class PApplet implements PConstants {
10655
9919
  }
10656
9920
 
10657
9921
 
10658
- // Moving this back off the EDT for alpha 10. Not sure if we're helping or
10659
- // hurting, but unless we do, errors inside settings() are never passed
9922
+ // Moving this back off the EDT for 3.0 alpha 10. Not sure if we're helping
9923
+ // or hurting, but unless we do, errors inside settings() are never passed
10660
9924
  // through to the PDE. There are other ways around that, no doubt, but I'm
10661
9925
  // also suspecting that these "not showing up" bugs might be EDT issues.
10662
9926
  static public void runSketch(final String[] args,
10663
9927
  final PApplet constructedSketch) {
10664
- // EventQueue.invokeLater(new Runnable() {
10665
- // public void run() {
10666
- // runSketchEDT(args, constructedSketch);
10667
- // }
10668
- // });
10669
- // }
10670
- //
10671
- //
10672
- // /**
10673
- // * Moving this to the EDT for 3.0a6 because that's the proper thing to do
10674
- // * when messing with Swing components. But mostly we're AWT, so who knows.
10675
- // */
10676
- // static protected void runSketchEDT(final String[] args,
10677
- // final PApplet constructedSketch) {
10678
- // Supposed to help with flicker, but no effect on OS X.
10679
- // TODO IIRC this helped on Windows, but need to double check.
10680
- System.setProperty("sun.awt.noerasebackground", "true");
10681
-
10682
- // Remove 60fps limit on the JavaFX "pulse" timer
10683
- System.setProperty("javafx.animation.fullspeed", "true");
10684
-
10685
- // Doesn't seem to do anything helpful here (that can't be done via Runner)
10686
- //System.setProperty("com.apple.mrj.application.apple.menu.about.name", "potato");
10687
-
10688
9928
  Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
10689
9929
  public void uncaughtException(Thread t, Throwable e) {
10690
9930
  e.printStackTrace();
@@ -10713,16 +9953,6 @@ public class PApplet implements PConstants {
10713
9953
  }
10714
9954
  */
10715
9955
 
10716
- // Catch any HeadlessException to provide more useful feedback
10717
- try {
10718
- // Call validate() while resize events are in progress
10719
- Toolkit.getDefaultToolkit().setDynamicLayout(true);
10720
- } catch (HeadlessException e) {
10721
- System.err.println("Cannot run sketch without a display. Read this for possible solutions:");
10722
- System.err.println("https://github.com/processing/processing/wiki/Running-without-a-Display");
10723
- System.exit(1);
10724
- }
10725
-
10726
9956
  // So that the system proxy setting are used by default
10727
9957
  System.setProperty("java.net.useSystemProxies", "true");
10728
9958
 
@@ -10769,6 +9999,9 @@ public class PApplet implements PConstants {
10769
9999
  displayNum = -1; // use the default
10770
10000
  }
10771
10001
 
10002
+ } else if (param.equals(ARGS_DISABLE_AWT)) {
10003
+ disableAWT = true;
10004
+
10772
10005
  } else if (param.equals(ARGS_WINDOW_COLOR)) {
10773
10006
  if (value.charAt(0) == '#' && value.length() == 7) {
10774
10007
  value = value.substring(1);
@@ -10822,16 +10055,9 @@ public class PApplet implements PConstants {
10822
10055
  argIndex++;
10823
10056
  }
10824
10057
 
10825
- // // Now that sketch path is passed in args after the sketch name
10826
- // // it's not set in the above loop(the above loop breaks after
10827
- // // finding sketch name). So setting sketch path here.
10828
- // // https://github.com/processing/processing/commit/0a14835e6f5f4766b022e73a8fe562318636727c
10829
- // // TODO this is a hack added for PDE X and needs to be removed [fry 141104]
10830
- // for (int i = 0; i < args.length; i++) {
10831
- // if (args[i].startsWith(ARGS_SKETCH_FOLDER)){
10832
- // folder = args[i].substring(args[i].indexOf('=') + 1);
10833
- // }
10834
- // }
10058
+ if (!disableAWT) {
10059
+ ShimAWT.initRun();
10060
+ }
10835
10061
 
10836
10062
  final PApplet sketch;
10837
10063
  if (constructedSketch != null) {
@@ -10844,25 +10070,12 @@ public class PApplet implements PConstants {
10844
10070
  } catch (RuntimeException re) {
10845
10071
  // Don't re-package runtime exceptions
10846
10072
  throw re;
10847
- } catch (Exception e) {
10073
+ } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
10848
10074
  // Package non-runtime exceptions so we can throw them freely
10849
10075
  throw new RuntimeException(e);
10850
10076
  }
10851
10077
  }
10852
10078
 
10853
- if (platform == MACOSX) {
10854
- try {
10855
- final String td = "processing.core.ThinkDifferent";
10856
- Class<?> thinkDifferent =
10857
- Thread.currentThread().getContextClassLoader().loadClass(td);
10858
- Method method =
10859
- thinkDifferent.getMethod("init", new Class[] { PApplet.class });
10860
- method.invoke(null, new Object[] { sketch });
10861
- } catch (Exception e) {
10862
- e.printStackTrace(); // That's unfortunate
10863
- }
10864
- }
10865
-
10866
10079
  // Set the suggested display that's coming from the command line
10867
10080
  // (and most likely, from the PDE's preference setting).
10868
10081
  sketch.display = displayNum;
@@ -10890,25 +10103,7 @@ public class PApplet implements PConstants {
10890
10103
  }
10891
10104
 
10892
10105
  // Call the settings() method which will give us our size() call
10893
- // try {
10894
10106
  sketch.handleSettings();
10895
- // } catch (Throwable t) {
10896
- // System.err.println("I think I'm gonna hurl");
10897
- // }
10898
-
10899
- //// sketch.spanDisplays = spanDisplays;
10900
- // // If spanning screens, that means we're also full screen.
10901
- //// fullScreen |= spanDisplays;
10902
- // if (spanDisplays) {
10903
- // displayIndex = SPAN;
10904
- //// fullScreen = true;
10905
- // }
10906
-
10907
- // // If the applet doesn't call for full screen, but the command line does,
10908
- // // enable it. Conversely, if the command line does not, don't disable it.
10909
- // // Query the applet to see if it wants to be full screen all the time.
10910
- // //fullScreen |= sketch.sketchFullScreen();
10911
- // sketch.fullScreen |= fullScreen;
10912
10107
 
10913
10108
  sketch.external = external;
10914
10109
 
@@ -10917,22 +10112,6 @@ public class PApplet implements PConstants {
10917
10112
  }
10918
10113
 
10919
10114
  final PSurface surface = sketch.initSurface();
10920
- // sketch.initSurface(windowColor, displayIndex, fullScreen, spanDisplays);
10921
-
10922
- /*
10923
- // Wait until the applet has figured out its width. In a static mode app,
10924
- // everything happens inside setup(), so this will be after setup() has
10925
- // completed, and the empty draw() has set "finished" to true.
10926
- while (sketch.defaultSize && !sketch.finished) {
10927
- //System.out.println("default size");
10928
- try {
10929
- Thread.sleep(5);
10930
-
10931
- } catch (InterruptedException e) {
10932
- //System.out.println("interrupt");
10933
- }
10934
- }
10935
- */
10936
10115
 
10937
10116
  if (present) {
10938
10117
  if (hideStop) {
@@ -10951,14 +10130,6 @@ public class PApplet implements PConstants {
10951
10130
 
10952
10131
  sketch.showSurface();
10953
10132
  sketch.startSurface();
10954
- /*
10955
- if (sketch.getGraphics().displayable()) {
10956
- surface.setVisible(true);
10957
- }
10958
-
10959
- //sketch.init();
10960
- surface.startThread();
10961
- */
10962
10133
  }
10963
10134
 
10964
10135
 
@@ -10982,61 +10153,63 @@ public class PApplet implements PConstants {
10982
10153
 
10983
10154
  // Create fake Frame object to warn user about the changes
10984
10155
  if (g.displayable()) {
10985
- frame = new Frame() {
10986
- @Override
10987
- public void setResizable(boolean resizable) {
10988
- deprecationWarning("setResizable");
10989
- surface.setResizable(resizable);
10990
- }
10991
-
10992
- @Override
10993
- public void setVisible(boolean visible) {
10994
- deprecationWarning("setVisible");
10995
- surface.setVisible(visible);
10996
- }
10997
-
10998
- @Override
10999
- public void setTitle(String title) {
11000
- deprecationWarning("setTitle");
11001
- surface.setTitle(title);
11002
- }
11003
-
11004
- @Override
11005
- public void setUndecorated(boolean ignored) {
11006
- throw new RuntimeException("'frame' has been removed from Processing 3, " +
11007
- "use fullScreen() to get an undecorated full screen frame");
11008
- }
10156
+ /*
10157
+ if (!disableAWT) {
10158
+ frame = new Frame() {
10159
+ @Override
10160
+ public void setResizable(boolean resizable) {
10161
+ deprecationWarning("setResizable");
10162
+ surface.setResizable(resizable);
10163
+ }
11009
10164
 
11010
- // Can't override this one because it's called by Window's constructor
11011
- /*
11012
- @Override
11013
- public void setLocation(int x, int y) {
11014
- deprecationWarning("setLocation");
11015
- surface.setLocation(x, y);
11016
- }
11017
- */
10165
+ @Override
10166
+ public void setVisible(boolean visible) {
10167
+ deprecationWarning("setVisible");
10168
+ surface.setVisible(visible);
10169
+ }
11018
10170
 
11019
- @Override
11020
- public void setSize(int w, int h) {
11021
- deprecationWarning("setSize");
11022
- surface.setSize(w, h);
11023
- }
10171
+ @Override
10172
+ public void setTitle(String title) {
10173
+ deprecationWarning("setTitle");
10174
+ surface.setTitle(title);
10175
+ }
11024
10176
 
11025
- private void deprecationWarning(String method) {
11026
- PGraphics.showWarning("Use surface." + method + "() instead of " +
11027
- "frame." + method + " in Processing 3");
11028
- //new Exception(method).printStackTrace(System.out);
11029
- }
11030
- };
10177
+ @Override
10178
+ public void setUndecorated(boolean ignored) {
10179
+ throw new RuntimeException("'frame' has been removed from Processing 3, " +
10180
+ "use fullScreen() to get an undecorated full screen frame");
10181
+ }
10182
+ */
10183
+ /*
10184
+ // Can't override this one because it's called by Window's constructor
10185
+ @Override
10186
+ public void setLocation(int x, int y) {
10187
+ deprecationWarning("setLocation");
10188
+ surface.setLocation(x, y);
10189
+ }
10190
+ */
10191
+ /*
10192
+ @Override
10193
+ public void setSize(int w, int h) {
10194
+ deprecationWarning("setSize");
10195
+ surface.setSize(w, h);
10196
+ }
11031
10197
 
11032
- surface.initFrame(this); //, backgroundColor, displayNum, fullScreen, spanDisplays);
11033
- surface.setTitle("Picrate 1.2 Sketch");
10198
+ private void deprecationWarning(String method) {
10199
+ PGraphics.showWarning("Use surface." + method + "() instead of " +
10200
+ "frame." + method + " in Processing 3");
10201
+ //new Exception(method).printStackTrace(System.out);
10202
+ }
10203
+ };
10204
+ }
10205
+ */
10206
+ surface.initFrame(this);
10207
+ surface.setTitle("Picrate 2.0 Sketch");
11034
10208
 
11035
10209
  } else {
11036
10210
  surface.initOffscreen(this); // for PDF/PSurfaceNone and friends
11037
10211
  }
11038
10212
 
11039
- // init();
11040
10213
  return surface;
11041
10214
  }
11042
10215
 
@@ -11068,16 +10241,6 @@ public class PApplet implements PConstants {
11068
10241
  // }
11069
10242
 
11070
10243
 
11071
- /** Convenience method, should only be called by PSurface subclasses. */
11072
- static public void hideMenuBar() {
11073
- if (PApplet.platform == PConstants.MACOSX) {
11074
- // Call some native code to remove the menu bar on OS X. Not necessary
11075
- // on Linux and Windows, who are happy to make full screen windows.
11076
- japplemenubar.JAppleMenuBar.hide();
11077
- }
11078
- }
11079
-
11080
-
11081
10244
  /**
11082
10245
  * Convenience method for Python Mode to run an already-constructed sketch.
11083
10246
  * This makes it makes it easy to launch a sketch in Jython:
@@ -11098,7 +10261,7 @@ public class PApplet implements PConstants {
11098
10261
  }
11099
10262
 
11100
10263
 
11101
- /** Convenience method for PiCrate */
10264
+ /** Run the PiCrate sketch */
11102
10265
  public void runPicrate() {
11103
10266
  runSketch(new String[0]);
11104
10267
  }
@@ -11115,7 +10278,7 @@ public class PApplet implements PConstants {
11115
10278
  * requires two parameters, the first is the renderer and the second is the
11116
10279
  * file name. This function is always used with <b>endRecord()</b> to stop
11117
10280
  * the recording process and close the file.
11118
- * <br /> <br />
10281
+ *
11119
10282
  * Note that beginRecord() will only pick up any settings that happen after
11120
10283
  * it has been called. For instance, if you call textFont() before
11121
10284
  * beginRecord(), then that font will not be set for the file that you're
@@ -11176,21 +10339,21 @@ public class PApplet implements PConstants {
11176
10339
  * hundreds of triangles, rather than a single object. Or that a
11177
10340
  * multi-segment line shape (such as a curve) will be rendered as
11178
10341
  * individual segments.
11179
- * <br /><br />
10342
+ *
11180
10343
  * When using <b>beginRaw()</b> and <b>endRaw()</b>, it's possible to write
11181
10344
  * to either a 2D or 3D renderer. For instance, <b>beginRaw()</b> with the
11182
10345
  * PDF library will write the geometry as flattened triangles and lines,
11183
10346
  * even if recording from the <b>P3D</b> renderer.
11184
- * <br /><br />
10347
+ *
11185
10348
  * If you want a background to show up in your files, use <b>rect(0, 0,
11186
10349
  * width, height)</b> after setting the <b>fill()</b> to the background
11187
10350
  * color. Otherwise the background will not be rendered to the file because
11188
10351
  * the background is not shape.
11189
- * <br /><br />
10352
+ *
11190
10353
  * Using <b>hint(ENABLE_DEPTH_SORT)</b> can improve the appearance of 3D
11191
10354
  * geometry drawn to 2D file formats. See the <b>hint()</b> reference for
11192
10355
  * more details.
11193
- * <br /><br />
10356
+ *
11194
10357
  * See examples in the reference for the <b>PDF</b> and <b>DXF</b>
11195
10358
  * libraries for more information.
11196
10359
  *
@@ -11261,7 +10424,7 @@ public class PApplet implements PConstants {
11261
10424
  * Loads the pixel data for the display window into the <b>pixels[]</b>
11262
10425
  * array. This function must always be called before reading from or
11263
10426
  * writing to <b>pixels[]</b>.
11264
- * <br/><br/> renderers may or may not seem to require <b>loadPixels()</b>
10427
+ * renderers may or may not seem to require <b>loadPixels()</b>
11265
10428
  * or <b>updatePixels()</b>. However, the rule is that any time you want to
11266
10429
  * manipulate the <b>pixels[]</b> array, you must first call
11267
10430
  * <b>loadPixels()</b>, and after changes have been made, call
@@ -11291,14 +10454,14 @@ public class PApplet implements PConstants {
11291
10454
  * Use in conjunction with <b>loadPixels()</b>. If you're only reading
11292
10455
  * pixels from the array, there's no need to call <b>updatePixels()</b>
11293
10456
  * unless there are changes.
11294
- * <br/><br/> renderers may or may not seem to require <b>loadPixels()</b>
10457
+ * renderers may or may not seem to require <b>loadPixels()</b>
11295
10458
  * or <b>updatePixels()</b>. However, the rule is that any time you want to
11296
10459
  * manipulate the <b>pixels[]</b> array, you must first call
11297
10460
  * <b>loadPixels()</b>, and after changes have been made, call
11298
10461
  * <b>updatePixels()</b>. Even if the renderer may not seem to use this
11299
10462
  * function in the current Processing release, this will always be subject
11300
10463
  * to change.
11301
- * <br/> <br/>
10464
+ *
11302
10465
  * Currently, none of the renderers use the additional parameters to
11303
10466
  * <b>updatePixels()</b>, however this may be implemented in the future.
11304
10467
  *
@@ -11380,12 +10543,12 @@ public class PApplet implements PConstants {
11380
10543
  * specifies a position in 2D and the <b>vertex()</b> function with three
11381
10544
  * parameters specifies a position in 3D. Each shape will be outlined with
11382
10545
  * the current stroke color and filled with the fill color.
11383
- * <br/> <br/>
10546
+ *
11384
10547
  * Transformations such as <b>translate()</b>, <b>rotate()</b>, and
11385
10548
  * <b>scale()</b> do not work within <b>beginShape()</b>. It is also not
11386
10549
  * possible to use other shapes, such as <b>ellipse()</b> or <b>rect()</b>
11387
10550
  * within <b>beginShape()</b>.
11388
- * <br/> <br/>
10551
+ *
11389
10552
  * The P3D renderer settings allow <b>stroke()</b> and <b>fill()</b>
11390
10553
  * settings to be altered per-vertex, however the default P2D renderer does
11391
10554
  * not. Settings such as <b>strokeWeight()</b>, <b>strokeCap()</b>, and
@@ -11525,7 +10688,7 @@ public class PApplet implements PConstants {
11525
10688
  * Sets a texture to be applied to vertex points. The <b>texture()</b>
11526
10689
  * function must be called between <b>beginShape()</b> and
11527
10690
  * <b>endShape()</b> and before any calls to <b>vertex()</b>.
11528
- * <br/> <br/>
10691
+ *
11529
10692
  * When textures are in use, the fill color is ignored. Instead, use tint()
11530
10693
  * to specify the color of the texture as it is applied to the shape.
11531
10694
  *
@@ -11590,11 +10753,11 @@ public class PApplet implements PConstants {
11590
10753
  * All shapes are constructed by connecting a series of vertices.
11591
10754
  * <b>vertex()</b> is used to specify the vertex coordinates for points,
11592
10755
  * lines, triangles, quads, and polygons and is used exclusively within the
11593
- * <b>beginShape()</b> and <b>endShape()</b> function.<br />
11594
- * <br />
10756
+ * <b>beginShape()</b> and <b>endShape()</b> function.
10757
+ *
11595
10758
  * Drawing a vertex in 3D using the <b>z</b> parameter requires the P3D
11596
- * parameter in combination with size as shown in the above example.<br />
11597
- * <br />
10759
+ * parameter in combination with size as shown in the above example.
10760
+ *
11598
10761
  * This function is also used to map a texture onto the geometry. The
11599
10762
  * <b>texture()</b> function declares the texture to apply to the geometry
11600
10763
  * and the <b>u</b> and <b>v</b> coordinates set define the mapping of this
@@ -12577,17 +11740,17 @@ public class PApplet implements PConstants {
12577
11740
  * ( begin auto-generated from curvePoint.xml )
12578
11741
  *
12579
11742
  * Evalutes the curve at point t for points a, b, c, d. The parameter t
12580
- * varies between 0 and 1, a and d are points on the curve, and b and c are
12581
- * the control points. This can be done once with the x coordinates and a
11743
+ * varies between 0 and 1, a and d are the control points, and b and c are
11744
+ * the points on the curve. This can be done once with the x coordinates and a
12582
11745
  * second time with the y coordinates to get the location of a curve at t.
12583
11746
  *
12584
11747
  * ( end auto-generated )
12585
11748
  *
12586
11749
  * @webref shape:curves
12587
- * @param a coordinate of first point on the curve
12588
- * @param b coordinate of second point on the curve
12589
- * @param c coordinate of third point on the curve
12590
- * @param d coordinate of fourth point on the curve
11750
+ * @param a coordinate of first control point
11751
+ * @param b coordinate of first point on the curve
11752
+ * @param c coordinate of second point on the curve
11753
+ * @param d coordinate of second control point
12591
11754
  * @param t value between 0 and 1
12592
11755
  * @see PGraphics#curve(float, float, float, float, float, float, float, float, float, float, float, float)
12593
11756
  * @see PGraphics#curveVertex(float, float)
@@ -12748,8 +11911,8 @@ public class PApplet implements PConstants {
12748
11911
  * <b>image()</b> to set the location of one corner of the image and uses
12749
11912
  * the fourth and fifth parameters to set the opposite corner. Use
12750
11913
  * <b>imageMode(CENTER)</b> to draw images centered at the given x and y
12751
- * position.<br />
12752
- * <br />
11914
+ * position.
11915
+ *
12753
11916
  * The parameter to <b>imageMode()</b> must be written in ALL CAPS because
12754
11917
  * Processing is a case-sensitive language.
12755
11918
  *
@@ -12778,13 +11941,13 @@ public class PApplet implements PConstants {
12778
11941
  * <b>x</b> and <b>y</b> parameters define the location of the image from
12779
11942
  * its upper-left corner. The image is displayed at its original size
12780
11943
  * unless the <b>width</b> and <b>height</b> parameters specify a different
12781
- * size.<br />
12782
- * <br />
11944
+ * size.
11945
+ *
12783
11946
  * The <b>imageMode()</b> function changes the way the parameters work. For
12784
11947
  * example, a call to <b>imageMode(CORNERS)</b> will change the
12785
11948
  * <b>width</b> and <b>height</b> parameters to define the x and y values
12786
- * of the opposite corner of the image.<br />
12787
- * <br />
11949
+ * of the opposite corner of the image.
11950
+ *
12788
11951
  * The color of an image may be modified with the <b>tint()</b> function.
12789
11952
  * This function will maintain transparency for GIF and PNG images.
12790
11953
  *
@@ -12885,7 +12048,7 @@ public class PApplet implements PConstants {
12885
12048
  * to <b>shapeMode(CORNERS)</b>, for example, will change the width and
12886
12049
  * height parameters to define the x and y values of the opposite corner of
12887
12050
  * the shape.
12888
- * <br /><br />
12051
+ *
12889
12052
  * Note complex shapes may draw awkwardly with P3D. This renderer does not
12890
12053
  * yet support shapes that have holes or complicated breaks.
12891
12054
  *
@@ -12932,7 +12095,7 @@ public class PApplet implements PConstants {
12932
12095
  * CENTER, and RIGHT set the display characteristics of the letters in
12933
12096
  * relation to the values for the <b>x</b> and <b>y</b> parameters of the
12934
12097
  * <b>text()</b> function.
12935
- * <br/> <br/>
12098
+ *
12936
12099
  * In Processing 0125 and later, an optional second parameter can be used
12937
12100
  * to vertically align the text. BASELINE is the default, and the vertical
12938
12101
  * alignment will be reset to BASELINE if the second parameter is not used.
@@ -12940,12 +12103,12 @@ public class PApplet implements PConstants {
12940
12103
  * offsets the line based on the current <b>textDescent()</b>. For multiple
12941
12104
  * lines, the final line will be aligned to the bottom, with the previous
12942
12105
  * lines appearing above it.
12943
- * <br/> <br/>
12106
+ *
12944
12107
  * When using <b>text()</b> with width and height parameters, BASELINE is
12945
12108
  * ignored, and treated as TOP. (Otherwise, text would by default draw
12946
12109
  * outside the box, since BASELINE is the default setting. BASELINE is not
12947
12110
  * a useful drawing mode for text drawn in a rectangle.)
12948
- * <br/> <br/>
12111
+ *
12949
12112
  * The vertical alignment is based on the value of <b>textAscent()</b>,
12950
12113
  * which many fonts do not specify correctly. It may be necessary to use a
12951
12114
  * hack and offset by a few pixels by hand so that the offset looks
@@ -13016,10 +12179,10 @@ public class PApplet implements PConstants {
13016
12179
  * <b>text()</b> function. If no <b>size</b> parameter is input, the font
13017
12180
  * will appear at its original size (the size it was created at with the
13018
12181
  * "Create Font..." tool) until it is changed with <b>textSize()</b>. <br
13019
- * /> <br /> Because fonts are usually bitmaped, you should create fonts at
12182
+ * /> Because fonts are usually bitmaped, you should create fonts at
13020
12183
  * the sizes that will be used most commonly. Using <b>textFont()</b>
13021
12184
  * without the size parameter will result in the cleanest-looking text. <br
13022
- * /><br /> With the default (JAVA2D) and PDF renderers, it's also possible
12185
+ * /> With the default (JAVA2D) and PDF renderers, it's also possible
13023
12186
  * to enable the use of native fonts via the command
13024
12187
  * <b>hint(ENABLE_NATIVE_FONTS)</b>. This will produce vector text in
13025
12188
  * JAVA2D sketches and PDF output in cases where the vector data is
@@ -13078,16 +12241,16 @@ public class PApplet implements PConstants {
13078
12241
  *
13079
12242
  * Sets the way text draws to the screen. In the default configuration, the
13080
12243
  * <b>MODEL</b> mode, it's possible to rotate, scale, and place letters in
13081
- * two and three dimensional space.<br />
13082
- * <br />
12244
+ * two and three dimensional space.
12245
+ *
13083
12246
  * The <b>SHAPE</b> mode draws text using the the glyph outlines of
13084
12247
  * individual characters rather than as textures. This mode is only
13085
12248
  * supported with the <b>PDF</b> and <b>P3D</b> renderer settings. With the
13086
12249
  * <b>PDF</b> renderer, you must call <b>textMode(SHAPE)</b> before any
13087
12250
  * other drawing occurs. If the outlines are not available, then
13088
12251
  * <b>textMode(SHAPE)</b> will be ignored and <b>textMode(MODEL)</b> will
13089
- * be used instead.<br />
13090
- * <br />
12252
+ * be used instead.
12253
+ *
13091
12254
  * The <b>textMode(SHAPE)</b> option in <b>P3D</b> can be combined with
13092
12255
  * <b>beginRaw()</b> to write vector-accurate text to 2D and 3D output
13093
12256
  * files, for instance <b>DXF</b> or <b>PDF</b>. The <b>SHAPE</b> mode is
@@ -13179,7 +12342,7 @@ public class PApplet implements PConstants {
13179
12342
  * with the <b>fill()</b> function. The text displays in relation to the
13180
12343
  * <b>textAlign()</b> function, which gives the option to draw to the left,
13181
12344
  * right, and center of the coordinates.
13182
- * <br /><br />
12345
+ *
13183
12346
  * The <b>x2</b> and <b>y2</b> parameters define a rectangular area to
13184
12347
  * display within and may only be used with string data. For text drawn
13185
12348
  * inside a rectangle, the coordinates are interpreted based on the current
@@ -13267,11 +12430,11 @@ public class PApplet implements PConstants {
13267
12430
  * Draw text in a box that is constrained to a particular size.
13268
12431
  * The current rectMode() determines what the coordinates mean
13269
12432
  * (whether x1/y1/x2/y2 or x/y/w/h).
13270
- * <P/>
12433
+ *
13271
12434
  * Note that the x,y coords of the start of the box
13272
12435
  * will align with the *ascent* of the text, not the baseline,
13273
12436
  * as is the case for the other text() functions.
13274
- * <P/>
12437
+ *
13275
12438
  * Newlines that are \n (Unix newline or linefeed char, ascii 10)
13276
12439
  * are honored, and \r (carriage return, Windows and Mac OS) are
13277
12440
  * ignored.
@@ -13329,8 +12492,8 @@ public class PApplet implements PConstants {
13329
12492
  * They allow you to change the style and transformation settings
13330
12493
  * and later return to what you had. When a new state is started
13331
12494
  * with push(), it builds on the current style and transform
13332
- * information.<br />
13333
- * <br />
12495
+ * information.
12496
+ *
13334
12497
  * <b>push()</b> stores information related to the current
13335
12498
  * transformation state and style settings controlled by the
13336
12499
  * following functions: <b>rotate()</b>, <b>translate()</b>,
@@ -13338,8 +12501,8 @@ public class PApplet implements PConstants {
13338
12501
  * <b>strokeWeight()</b>, <b>strokeCap()</b>, <b>strokeJoin()</b>,
13339
12502
  * <b>imageMode()</b>, <b>rectMode()</b>, <b>ellipseMode()</b>,
13340
12503
  * <b>colorMode()</b>, <b>textAlign()</b>, <b>textFont()</b>,
13341
- * <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.<br />
13342
- * <br />
12504
+ * <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.
12505
+ *
13343
12506
  * The <b>push()</b> and <b>pop()</b> functions were added with
13344
12507
  * Processing 3.5. They can be used in place of <b>pushMatrix()</b>,
13345
12508
  * <b>popMatrix()</b>, <b>pushStyles()</b>, and <b>popStyles()</b>.
@@ -13366,9 +12529,9 @@ public class PApplet implements PConstants {
13366
12529
  * Note that these functions are always used together. They allow
13367
12530
  * you to change the style and transformation settings and later
13368
12531
  * return to what you had. When a new state is started with push(),
13369
- * it builds on the current style and transform information.<br />
13370
- * <br />
13371
- * <br />
12532
+ * it builds on the current style and transform information.
12533
+ *
12534
+ *
13372
12535
  * <b>push()</b> stores information related to the current
13373
12536
  * transformation state and style settings controlled by the
13374
12537
  * following functions: <b>rotate()</b>, <b>translate()</b>,
@@ -13376,8 +12539,8 @@ public class PApplet implements PConstants {
13376
12539
  * <b>strokeWeight()</b>, <b>strokeCap()</b>, <b>strokeJoin()</b>,
13377
12540
  * <b>imageMode()</b>, <b>rectMode()</b>, <b>ellipseMode()</b>,
13378
12541
  * <b>colorMode()</b>, <b>textAlign()</b>, <b>textFont()</b>,
13379
- * <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.<br />
13380
- * <br />
12542
+ * <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.
12543
+ *
13381
12544
  * The <b>push()</b> and <b>pop()</b> functions were added with
13382
12545
  * Processing 3.5. They can be used in place of <b>pushMatrix()</b>,
13383
12546
  * <b>popMatrix()</b>, <b>pushStyles()</b>, and <b>popStyles()</b>.
@@ -13497,7 +12660,7 @@ public class PApplet implements PConstants {
13497
12660
  * Rotates a shape the amount specified by the <b>angle</b> parameter.
13498
12661
  * Angles should be specified in radians (values from 0 to TWO_PI) or
13499
12662
  * converted to radians with the <b>radians()</b> function.
13500
- * <br/> <br/>
12663
+ *
13501
12664
  * Objects are always rotated around their relative position to the origin
13502
12665
  * and positive numbers rotate objects in a clockwise direction.
13503
12666
  * Transformations apply to everything that happens after and subsequent
@@ -13505,7 +12668,7 @@ public class PApplet implements PConstants {
13505
12668
  * <b>rotate(HALF_PI)</b> and then <b>rotate(HALF_PI)</b> is the same as
13506
12669
  * <b>rotate(PI)</b>. All tranformations are reset when <b>draw()</b>
13507
12670
  * begins again.
13508
- * <br/> <br/>
12671
+ *
13509
12672
  * Technically, <b>rotate()</b> multiplies the current transformation
13510
12673
  * matrix by a rotation matrix. This function can be further controlled by
13511
12674
  * the <b>pushMatrix()</b> and <b>popMatrix()</b>.
@@ -13716,7 +12879,7 @@ public class PApplet implements PConstants {
13716
12879
  * <b>shearX(PI/2)</b> and then <b>shearX(PI/2)</b> is the same as
13717
12880
  * <b>shearX(PI)</b>. If <b>shearX()</b> is called within the
13718
12881
  * <b>draw()</b>, the transformation is reset when the loop begins again.
13719
- * <br/> <br/>
12882
+ *
13720
12883
  * Technically, <b>shearX()</b> multiplies the current transformation
13721
12884
  * matrix by a rotation matrix. This function can be further controlled by
13722
12885
  * the <b>pushMatrix()</b> and <b>popMatrix()</b> functions.
@@ -13751,7 +12914,7 @@ public class PApplet implements PConstants {
13751
12914
  * <b>shearY(PI/2)</b> and then <b>shearY(PI/2)</b> is the same as
13752
12915
  * <b>shearY(PI)</b>. If <b>shearY()</b> is called within the
13753
12916
  * <b>draw()</b>, the transformation is reset when the loop begins again.
13754
- * <br/> <br/>
12917
+ *
13755
12918
  * Technically, <b>shearY()</b> multiplies the current transformation
13756
12919
  * matrix by a rotation matrix. This function can be further controlled by
13757
12920
  * the <b>pushMatrix()</b> and <b>popMatrix()</b> functions.
@@ -13940,14 +13103,14 @@ public class PApplet implements PConstants {
13940
13103
  * The <b>beginCamera()</b> and <b>endCamera()</b> functions enable
13941
13104
  * advanced customization of the camera space. The functions are useful if
13942
13105
  * you want to more control over camera movement, however for most users,
13943
- * the <b>camera()</b> function will be sufficient.<br /><br />The camera
13106
+ * the <b>camera()</b> function will be sufficient.The camera
13944
13107
  * functions will replace any transformations (such as <b>rotate()</b> or
13945
13108
  * <b>translate()</b>) that occur before them in <b>draw()</b>, but they
13946
13109
  * will not automatically replace the camera transform itself. For this
13947
13110
  * reason, camera functions should be placed at the beginning of
13948
13111
  * <b>draw()</b> (so that transformations happen afterwards), and the
13949
13112
  * <b>camera()</b> function can be used after <b>beginCamera()</b> if you
13950
- * want to reset the camera before applying transformations.<br /><br
13113
+ * want to reset the camera before applying transformations.<br
13951
13114
  * />This function sets the matrix mode to the camera matrix so calls such
13952
13115
  * as <b>translate()</b>, <b>rotate()</b>, applyMatrix() and resetMatrix()
13953
13116
  * affect the camera. <b>beginCamera()</b> should always be used with a
@@ -14261,7 +13424,7 @@ public class PApplet implements PConstants {
14261
13424
  * transformations (scale, rotate, translate, etc.) The X value can be used
14262
13425
  * to place an object in space relative to the location of the original
14263
13426
  * point once the transformations are no longer in use.
14264
- * <br/> <br/>
13427
+ *
14265
13428
  * In the example, the <b>modelX()</b>, <b>modelY()</b>, and
14266
13429
  * <b>modelZ()</b> functions record the location of a box in space after
14267
13430
  * being placed using a series of translate and rotate commands. After
@@ -14290,8 +13453,8 @@ public class PApplet implements PConstants {
14290
13453
  * returns the Y value for a given coordinate based on the current set of
14291
13454
  * transformations (scale, rotate, translate, etc.) The Y value can be used
14292
13455
  * to place an object in space relative to the location of the original
14293
- * point once the transformations are no longer in use.<br />
14294
- * <br />
13456
+ * point once the transformations are no longer in use.
13457
+ *
14295
13458
  * In the example, the <b>modelX()</b>, <b>modelY()</b>, and
14296
13459
  * <b>modelZ()</b> functions record the location of a box in space after
14297
13460
  * being placed using a series of translate and rotate commands. After
@@ -14320,8 +13483,8 @@ public class PApplet implements PConstants {
14320
13483
  * returns the Z value for a given coordinate based on the current set of
14321
13484
  * transformations (scale, rotate, translate, etc.) The Z value can be used
14322
13485
  * to place an object in space relative to the location of the original
14323
- * point once the transformations are no longer in use.<br />
14324
- * <br />
13486
+ * point once the transformations are no longer in use.
13487
+ *
14325
13488
  * In the example, the <b>modelX()</b>, <b>modelY()</b>, and
14326
13489
  * <b>modelZ()</b> functions record the location of a box in space after
14327
13490
  * being placed using a series of translate and rotate commands. After
@@ -14353,7 +13516,7 @@ public class PApplet implements PConstants {
14353
13516
  * <b>pushStyle()</b>, it builds on the current style information. The
14354
13517
  * <b>pushStyle()</b> and <b>popStyle()</b> functions can be embedded to
14355
13518
  * provide more control (see the second example above for a demonstration.)
14356
- * <br /><br />
13519
+ *
14357
13520
  * The style information controlled by the following functions are included
14358
13521
  * in the style:
14359
13522
  * fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(),
@@ -14405,7 +13568,7 @@ public class PApplet implements PConstants {
14405
13568
  *
14406
13569
  * Sets the width of the stroke used for lines, points, and the border
14407
13570
  * around shapes. All widths are set in units of pixels.
14408
- * <br/> <br/>
13571
+ *
14409
13572
  * When drawing with P3D, series of connected lines (such as the stroke
14410
13573
  * around a polygon, triangle, or ellipse) produce unattractive results
14411
13574
  * when a thick stroke weight is set (<a
@@ -14436,7 +13599,7 @@ public class PApplet implements PConstants {
14436
13599
  * are either mitered, beveled, or rounded and specified with the
14437
13600
  * corresponding parameters MITER, BEVEL, and ROUND. The default joint is
14438
13601
  * MITER.
14439
- * <br/> <br/>
13602
+ *
14440
13603
  * This function is not available with the P3D renderer, (<a
14441
13604
  * href="http://code.google.com/p/processing/issues/detail?id=123">see
14442
13605
  * Issue 123</a>). More information about the renderers can be found in the
@@ -14462,7 +13625,7 @@ public class PApplet implements PConstants {
14462
13625
  * Sets the style for rendering line endings. These ends are either
14463
13626
  * squared, extended, or rounded and specified with the corresponding
14464
13627
  * parameters SQUARE, PROJECT, and ROUND. The default cap is ROUND.
14465
- * <br/> <br/>
13628
+ *
14466
13629
  * This function is not available with the P3D renderer (<a
14467
13630
  * href="http://code.google.com/p/processing/issues/detail?id=123">see
14468
13631
  * Issue 123</a>). More information about the renderers can be found in the
@@ -14509,7 +13672,7 @@ public class PApplet implements PConstants {
14509
13672
  * is either specified in terms of the RGB or HSB color depending on the
14510
13673
  * current <b>colorMode()</b> (the default color space is RGB, with each
14511
13674
  * value in the range from 0 to 255).
14512
- * <br/> <br/>
13675
+ *
14513
13676
  * When using hexadecimal notation to specify a color, use "#" or "0x"
14514
13677
  * before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six
14515
13678
  * digits to specify a color (the way colors are specified in HTML and
@@ -14517,7 +13680,7 @@ public class PApplet implements PConstants {
14517
13680
  * hexadecimal value must be specified with eight characters; the first two
14518
13681
  * characters define the alpha component and the remainder the red, green,
14519
13682
  * and blue components.
14520
- * <br/> <br/>
13683
+ *
14521
13684
  * The value for the parameter "gray" must be less than or equal to the
14522
13685
  * current maximum value as specified by <b>colorMode()</b>. The default
14523
13686
  * maximum value is 255.
@@ -14606,25 +13769,25 @@ public class PApplet implements PConstants {
14606
13769
  * ( begin auto-generated from tint.xml )
14607
13770
  *
14608
13771
  * Sets the fill value for displaying images. Images can be tinted to
14609
- * specified colors or made transparent by setting the alpha.<br />
14610
- * <br />
13772
+ * specified colors or made transparent by setting the alpha.
13773
+ *
14611
13774
  * To make an image transparent, but not change it's color, use white as
14612
13775
  * the tint color and specify an alpha value. For instance, tint(255, 128)
14613
13776
  * will make an image 50% transparent (unless <b>colorMode()</b> has been
14614
- * used).<br />
14615
- * <br />
13777
+ * used).
13778
+ *
14616
13779
  * When using hexadecimal notation to specify a color, use "#" or "0x"
14617
13780
  * before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six
14618
13781
  * digits to specify a color (the way colors are specified in HTML and
14619
13782
  * CSS). When using the hexadecimal notation starting with "0x", the
14620
13783
  * hexadecimal value must be specified with eight characters; the first two
14621
13784
  * characters define the alpha component and the remainder the red, green,
14622
- * and blue components.<br />
14623
- * <br />
13785
+ * and blue components.
13786
+ *
14624
13787
  * The value for the parameter "gray" must be less than or equal to the
14625
13788
  * current maximum value as specified by <b>colorMode()</b>. The default
14626
- * maximum value is 255.<br />
14627
- * <br />
13789
+ * maximum value is 255.
13790
+ *
14628
13791
  * The <b>tint()</b> function is also used to control the coloring of
14629
13792
  * textures in 3D.
14630
13793
  *
@@ -14711,7 +13874,7 @@ public class PApplet implements PConstants {
14711
13874
  * color is either specified in terms of the RGB or HSB color depending on
14712
13875
  * the current <b>colorMode()</b> (the default color space is RGB, with
14713
13876
  * each value in the range from 0 to 255).
14714
- * <br/> <br/>
13877
+ *
14715
13878
  * When using hexadecimal notation to specify a color, use "#" or "0x"
14716
13879
  * before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six
14717
13880
  * digits to specify a color (the way colors are specified in HTML and
@@ -14719,11 +13882,11 @@ public class PApplet implements PConstants {
14719
13882
  * hexadecimal value must be specified with eight characters; the first two
14720
13883
  * characters define the alpha component and the remainder the red, green,
14721
13884
  * and blue components.
14722
- * <br/> <br/>
13885
+ *
14723
13886
  * The value for the parameter "gray" must be less than or equal to the
14724
13887
  * current maximum value as specified by <b>colorMode()</b>. The default
14725
13888
  * maximum value is 255.
14726
- * <br/> <br/>
13889
+ *
14727
13890
  * To change the color of an image (or a texture), use tint().
14728
13891
  *
14729
13892
  * ( end auto-generated )
@@ -14859,6 +14022,8 @@ public class PApplet implements PConstants {
14859
14022
 
14860
14023
  /**
14861
14024
  * gray number specifying value between white and black
14025
+ *
14026
+ * @param gray value between black and white, by default 0 to 255
14862
14027
  */
14863
14028
  public void specular(float gray) {
14864
14029
  if (recorder != null) recorder.specular(gray);
@@ -14924,6 +14089,8 @@ public class PApplet implements PConstants {
14924
14089
 
14925
14090
  /**
14926
14091
  * gray number specifying value between white and black
14092
+ *
14093
+ * @param gray value between black and white, by default 0 to 255
14927
14094
  */
14928
14095
  public void emissive(float gray) {
14929
14096
  if (recorder != null) recorder.emissive(gray);
@@ -15148,9 +14315,9 @@ public class PApplet implements PConstants {
15148
14315
  *
15149
14316
  * Sets the falloff rates for point lights, spot lights, and ambient
15150
14317
  * lights. The parameters are used to determine the falloff with the
15151
- * following equation:<br /><br />d = distance from light position to
15152
- * vertex position<br />falloff = 1 / (CONSTANT + d * LINEAR + (d*d) *
15153
- * QUADRATIC)<br /><br />Like <b>fill()</b>, it affects only the elements
14318
+ * following equation:d = distance from light position to
14319
+ * vertex positionfalloff = 1 / (CONSTANT + d * LINEAR + (d*d) *
14320
+ * QUADRATIC)Like <b>fill()</b>, it affects only the elements
15154
14321
  * which are created after it in the code. The default value if
15155
14322
  * <b>LightFalloff(1.0, 0.0, 0.0)</b>. Thinking about an ambient light with
15156
14323
  * a falloff can be tricky. It is used, for example, if you wanted a region
@@ -15215,13 +14382,13 @@ public class PApplet implements PConstants {
15215
14382
  * of the Processing window. The default background is light gray. In the
15216
14383
  * <b>draw()</b> function, the background color is used to clear the
15217
14384
  * display window at the beginning of each frame.
15218
- * <br/> <br/>
14385
+ *
15219
14386
  * An image can also be used as the background for a sketch, however its
15220
14387
  * width and height must be the same size as the sketch window. To resize
15221
14388
  * an image 'b' to the size of the sketch window, use b.resize(width, height).
15222
- * <br/> <br/>
14389
+ *
15223
14390
  * Images used as background will ignore the current <b>tint()</b> setting.
15224
- * <br/> <br/>
14391
+ *
15225
14392
  * It is not possible to use transparency (alpha) in background colors with
15226
14393
  * the main drawing surface, however they will work properly with <b>createGraphics()</b>.
15227
14394
  *
@@ -15304,13 +14471,13 @@ public class PApplet implements PConstants {
15304
14471
  /**
15305
14472
  * Takes an RGB or ARGB image and sets it as the background.
15306
14473
  * The width and height of the image must be the same size as the sketch.
15307
- * Use image.resize(width, height) to make short work of such a task.<br/>
15308
- * <br/>
14474
+ * Use image.resize(width, height) to make short work of such a task.
14475
+ *
15309
14476
  * Note that even if the image is set as RGB, the high 8 bits of each pixel
15310
14477
  * should be set opaque (0xFF000000) because the image data will be copied
15311
14478
  * directly to the screen, and non-opaque background images may have strange
15312
- * behavior. Use image.filter(OPAQUE) to handle this easily.<br/>
15313
- * <br/>
14479
+ * behavior. Use image.filter(OPAQUE) to handle this easily.
14480
+ *
15314
14481
  * When using 3D, this will also clear the zbuffer (if it exists).
15315
14482
  *
15316
14483
  * @param image PImage to set as background (must be same size as the sketch window)
@@ -15404,12 +14571,12 @@ public class PApplet implements PConstants {
15404
14571
  *
15405
14572
  * Extracts the red value from a color, scaled to match current
15406
14573
  * <b>colorMode()</b>. This value is always returned as a float so be
15407
- * careful not to assign it to an int value.<br /><br />The red() function
14574
+ * careful not to assign it to an int value.The red() function
15408
14575
  * is easy to use and undestand, but is slower than another technique. To
15409
14576
  * achieve the same results when working in <b>colorMode(RGB, 255)</b>, but
15410
14577
  * with greater speed, use the &gt;&gt; (right shift) operator with a bit
15411
14578
  * mask. For example, the following two lines of code are equivalent:<br
15412
- * /><pre>float r1 = red(myColor);<br />float r2 = myColor &gt;&gt; 16
14579
+ * /><pre>float r1 = red(myColor);float r2 = myColor &gt;&gt; 16
15413
14580
  * &amp; 0xFF;</pre>
15414
14581
  *
15415
14582
  * ( end auto-generated )
@@ -15435,12 +14602,12 @@ public class PApplet implements PConstants {
15435
14602
  *
15436
14603
  * Extracts the green value from a color, scaled to match current
15437
14604
  * <b>colorMode()</b>. This value is always returned as a float so be
15438
- * careful not to assign it to an int value.<br /><br />The <b>green()</b>
14605
+ * careful not to assign it to an int value.The <b>green()</b>
15439
14606
  * function is easy to use and undestand, but is slower than another
15440
14607
  * technique. To achieve the same results when working in <b>colorMode(RGB,
15441
14608
  * 255)</b>, but with greater speed, use the &gt;&gt; (right shift)
15442
14609
  * operator with a bit mask. For example, the following two lines of code
15443
- * are equivalent:<br /><pre>float r1 = green(myColor);<br />float r2 =
14610
+ * are equivalent:<pre>float r1 = green(myColor);float r2 =
15444
14611
  * myColor &gt;&gt; 8 &amp; 0xFF;</pre>
15445
14612
  *
15446
14613
  * ( end auto-generated )
@@ -15466,12 +14633,12 @@ public class PApplet implements PConstants {
15466
14633
  *
15467
14634
  * Extracts the blue value from a color, scaled to match current
15468
14635
  * <b>colorMode()</b>. This value is always returned as a float so be
15469
- * careful not to assign it to an int value.<br /><br />The <b>blue()</b>
14636
+ * careful not to assign it to an int value.The <b>blue()</b>
15470
14637
  * function is easy to use and undestand, but is slower than another
15471
14638
  * technique. To achieve the same results when working in <b>colorMode(RGB,
15472
14639
  * 255)</b>, but with greater speed, use a bit mask to remove the other
15473
14640
  * color components. For example, the following two lines of code are
15474
- * equivalent:<br /><pre>float r1 = blue(myColor);<br />float r2 = myColor
14641
+ * equivalent:<pre>float r1 = blue(myColor);float r2 = myColor
15475
14642
  * &amp; 0xFF;</pre>
15476
14643
  *
15477
14644
  * ( end auto-generated )
@@ -15613,6 +14780,15 @@ public class PApplet implements PConstants {
15613
14780
  }
15614
14781
 
15615
14782
 
14783
+ /**
14784
+ * Check the alpha on an image, using a really primitive loop.
14785
+ */
14786
+ public void checkAlpha() {
14787
+ if (recorder != null) recorder.checkAlpha();
14788
+ g.checkAlpha();
14789
+ }
14790
+
14791
+
15616
14792
  /**
15617
14793
  * ( begin auto-generated from PImage_get.xml )
15618
14794
  *
@@ -15622,14 +14798,14 @@ public class PApplet implements PConstants {
15622
14798
  * the display window by specifying an additional <b>width</b> and
15623
14799
  * <b>height</b> parameter. When getting an image, the <b>x</b> and
15624
14800
  * <b>y</b> parameters define the coordinates for the upper-left corner of
15625
- * the image, regardless of the current <b>imageMode()</b>.<br />
15626
- * <br />
14801
+ * the image, regardless of the current <b>imageMode()</b>.
14802
+ *
15627
14803
  * If the pixel requested is outside of the image window, black is
15628
14804
  * returned. The numbers returned are scaled according to the current color
15629
14805
  * ranges, but only RGB values are returned by this function. For example,
15630
14806
  * even though you may have drawn a shape with <b>colorMode(HSB)</b>, the
15631
- * numbers returned will be in RGB format.<br />
15632
- * <br />
14807
+ * numbers returned will be in RGB format.
14808
+ *
15633
14809
  * Getting the color of a single pixel with <b>get(x, y)</b> is easy, but
15634
14810
  * not as fast as grabbing the data directly from <b>pixels[]</b>. The
15635
14811
  * equivalent statement to <b>get(x, y)</b> using <b>pixels[]</b> is
@@ -15696,15 +14872,15 @@ public class PApplet implements PConstants {
15696
14872
  * ( begin auto-generated from PImage_set.xml )
15697
14873
  *
15698
14874
  * Changes the color of any pixel or writes an image directly into the
15699
- * display window.<br />
15700
- * <br />
14875
+ * display window.
14876
+ *
15701
14877
  * The <b>x</b> and <b>y</b> parameters specify the pixel to change and the
15702
14878
  * <b>color</b> parameter specifies the color value. The color parameter is
15703
14879
  * affected by the current color mode (the default is RGB values from 0 to
15704
14880
  * 255). When setting an image, the <b>x</b> and <b>y</b> parameters define
15705
14881
  * the coordinates for the upper-left corner of the image, regardless of
15706
14882
  * the current <b>imageMode()</b>.
15707
- * <br /><br />
14883
+ *
15708
14884
  * Setting the color of a single pixel with <b>set(x, y)</b> is easy, but
15709
14885
  * not as fast as putting the data directly into <b>pixels[]</b>. The
15710
14886
  * equivalent statement to <b>set(x, y, #000000)</b> using <b>pixels[]</b>
@@ -15749,8 +14925,8 @@ public class PApplet implements PConstants {
15749
14925
  * Masks part of an image from displaying by loading another image and
15750
14926
  * using it as an alpha channel. This mask image should only contain
15751
14927
  * grayscale data, but only the blue color channel is used. The mask image
15752
- * needs to be the same size as the image to which it is applied.<br />
15753
- * <br />
14928
+ * needs to be the same size as the image to which it is applied.
14929
+ *
15754
14930
  * In addition to using a mask image, an integer array containing the alpha
15755
14931
  * channel data can be specified directly. This method is useful for
15756
14932
  * creating dynamically generated alpha masks. This array must be of the
@@ -15793,28 +14969,28 @@ public class PApplet implements PConstants {
15793
14969
  /**
15794
14970
  * ( begin auto-generated from PImage_filter.xml )
15795
14971
  *
15796
- * Filters an image as defined by one of the following modes:<br /><br
15797
- * />THRESHOLD - converts the image to black and white pixels depending if
14972
+ * Filters an image as defined by one of the following modes:
14973
+ * THRESHOLD - converts the image to black and white pixels depending if
15798
14974
  * they are above or below the threshold defined by the level parameter.
15799
14975
  * The level must be between 0.0 (black) and 1.0(white). If no level is
15800
- * specified, 0.5 is used.<br />
15801
- * <br />
15802
- * GRAY - converts any colors in the image to grayscale equivalents<br />
15803
- * <br />
15804
- * INVERT - sets each pixel to its inverse value<br />
15805
- * <br />
14976
+ * specified, 0.5 is used.
14977
+ *
14978
+ * GRAY - converts any colors in the image to grayscale equivalents
14979
+ *
14980
+ * INVERT - sets each pixel to its inverse value
14981
+ *
15806
14982
  * POSTERIZE - limits each channel of the image to the number of colors
15807
- * specified as the level parameter<br />
15808
- * <br />
14983
+ * specified as the level parameter
14984
+ *
15809
14985
  * BLUR - executes a Guassian blur with the level parameter specifying the
15810
14986
  * extent of the blurring. If no level parameter is used, the blur is
15811
- * equivalent to Guassian blur of radius 1<br />
15812
- * <br />
15813
- * OPAQUE - sets the alpha channel to entirely opaque<br />
15814
- * <br />
14987
+ * equivalent to Guassian blur of radius 1
14988
+ *
14989
+ * OPAQUE - sets the alpha channel to entirely opaque
14990
+ *
15815
14991
  * ERODE - reduces the light areas with the amount defined by the level
15816
- * parameter<br />
15817
- * <br />
14992
+ * parameter
14993
+ *
15818
14994
  * DILATE - increases the light areas with the amount defined by the level parameter
15819
14995
  *
15820
14996
  * ( end auto-generated )
@@ -15833,7 +15009,7 @@ public class PApplet implements PConstants {
15833
15009
  * </UL>
15834
15010
  * Luminance conversion code contributed by
15835
15011
  * <A HREF="http://www.toxi.co.uk">toxi</A>
15836
- * <P/>
15012
+ *
15837
15013
  * Gaussian blur code contributed by
15838
15014
  * <A HREF="http://incubator.quasimondo.com">Mario Klingemann</A>
15839
15015
  *
@@ -15857,7 +15033,7 @@ public class PApplet implements PConstants {
15857
15033
  * source pixels to fit the specified target region. No alpha information
15858
15034
  * is used in the process, however if the source image has an alpha channel
15859
15035
  * set, it will be copied as well.
15860
- * <br /><br />
15036
+ *
15861
15037
  * As of release 0149, this function ignores <b>imageMode()</b>.
15862
15038
  *
15863
15039
  * ( end auto-generated )
@@ -15907,47 +15083,47 @@ public class PApplet implements PConstants {
15907
15083
  * Blends a region of pixels into the image specified by the <b>img</b>
15908
15084
  * parameter. These copies utilize full alpha channel support and a choice
15909
15085
  * of the following modes to blend the colors of source pixels (A) with the
15910
- * ones of pixels in the destination image (B):<br />
15911
- * <br />
15912
- * BLEND - linear interpolation of colours: C = A*factor + B<br />
15913
- * <br />
15914
- * ADD - additive blending with white clip: C = min(A*factor + B, 255)<br />
15915
- * <br />
15086
+ * ones of pixels in the destination image (B):
15087
+ *
15088
+ * BLEND - linear interpolation of colours: C = A*factor + B
15089
+ *
15090
+ * ADD - additive blending with white clip: C = min(A*factor + B, 255)
15091
+ *
15916
15092
  * SUBTRACT - subtractive blending with black clip: C = max(B - A*factor,
15917
- * 0)<br />
15918
- * <br />
15919
- * DARKEST - only the darkest colour succeeds: C = min(A*factor, B)<br />
15920
- * <br />
15921
- * LIGHTEST - only the lightest colour succeeds: C = max(A*factor, B)<br />
15922
- * <br />
15923
- * DIFFERENCE - subtract colors from underlying image.<br />
15924
- * <br />
15925
- * EXCLUSION - similar to DIFFERENCE, but less extreme.<br />
15926
- * <br />
15927
- * MULTIPLY - Multiply the colors, result will always be darker.<br />
15928
- * <br />
15929
- * SCREEN - Opposite multiply, uses inverse values of the colors.<br />
15930
- * <br />
15093
+ * 0)
15094
+ *
15095
+ * DARKEST - only the darkest colour succeeds: C = min(A*factor, B)
15096
+ *
15097
+ * LIGHTEST - only the lightest colour succeeds: C = max(A*factor, B)
15098
+ *
15099
+ * DIFFERENCE - subtract colors from underlying image.
15100
+ *
15101
+ * EXCLUSION - similar to DIFFERENCE, but less extreme.
15102
+ *
15103
+ * MULTIPLY - Multiply the colors, result will always be darker.
15104
+ *
15105
+ * SCREEN - Opposite multiply, uses inverse values of the colors.
15106
+ *
15931
15107
  * OVERLAY - A mix of MULTIPLY and SCREEN. Multiplies dark values,
15932
- * and screens light values.<br />
15933
- * <br />
15934
- * HARD_LIGHT - SCREEN when greater than 50% gray, MULTIPLY when lower.<br />
15935
- * <br />
15108
+ * and screens light values.
15109
+ *
15110
+ * HARD_LIGHT - SCREEN when greater than 50% gray, MULTIPLY when lower.
15111
+ *
15936
15112
  * SOFT_LIGHT - Mix of DARKEST and LIGHTEST.
15937
- * Works like OVERLAY, but not as harsh.<br />
15938
- * <br />
15113
+ * Works like OVERLAY, but not as harsh.
15114
+ *
15939
15115
  * DODGE - Lightens light tones and increases contrast, ignores darks.
15940
- * Called "Color Dodge" in Illustrator and Photoshop.<br />
15941
- * <br />
15116
+ * Called "Color Dodge" in Illustrator and Photoshop.
15117
+ *
15942
15118
  * BURN - Darker areas are applied, increasing contrast, ignores lights.
15943
- * Called "Color Burn" in Illustrator and Photoshop.<br />
15944
- * <br />
15119
+ * Called "Color Burn" in Illustrator and Photoshop.
15120
+ *
15945
15121
  * All modes use the alpha information (highest byte) of source image
15946
15122
  * pixels as the blending factor. If the source and destination regions are
15947
15123
  * different sizes, the image will be automatically resized to match the
15948
15124
  * destination size. If the <b>srcImg</b> parameter is not used, the
15949
- * display window is used as the source image.<br />
15950
- * <br />
15125
+ * display window is used as the source image.
15126
+ *
15951
15127
  * As of release 0149, this function ignores <b>imageMode()</b>.
15952
15128
  *
15953
15129
  * ( end auto-generated )