propane 3.4.0-java → 3.4.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -2
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +2 -0
  5. data/README.md +12 -7
  6. data/Rakefile +2 -2
  7. data/lib/propane.rb +2 -2
  8. data/lib/propane/app.rb +18 -9
  9. data/lib/propane/helper_methods.rb +1 -1
  10. data/lib/propane/runner.rb +1 -1
  11. data/lib/propane/version.rb +1 -1
  12. data/library/color_group/color_group.rb +26 -0
  13. data/library/dxf/dxf.rb +4 -0
  14. data/library/net/net.rb +5 -0
  15. data/library/video_event/video_event.rb +2 -1
  16. data/pom.rb +3 -3
  17. data/pom.xml +3 -3
  18. data/propane.gemspec +1 -1
  19. data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
  20. data/src/main/java/monkstone/ColorUtil.java +14 -0
  21. data/src/main/java/monkstone/MathToolModule.java +243 -194
  22. data/src/main/java/monkstone/filechooser/Chooser.java +1 -0
  23. data/src/main/java/monkstone/slider/WheelHandler.java +6 -5
  24. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +3 -2
  25. data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
  26. data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +10 -26
  27. data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
  28. data/src/main/java/processing/core/PApplet.java +1236 -599
  29. data/src/main/java/processing/core/PGraphics.java +59 -59
  30. data/src/main/java/processing/core/PImage.java +528 -129
  31. data/src/main/java/processing/core/PShape.java +10 -10
  32. data/src/main/java/processing/core/PVector.java +2 -2
  33. data/src/main/java/processing/core/ThinkDifferent.java +5 -7
  34. data/src/main/java/processing/dxf/RawDXF.java +404 -0
  35. data/src/main/java/processing/net/Client.java +744 -0
  36. data/src/main/java/processing/net/Server.java +388 -0
  37. data/src/main/java/processing/opengl/FontTexture.java +19 -20
  38. data/src/main/java/processing/opengl/FrameBuffer.java +27 -17
  39. data/src/main/java/processing/opengl/LinePath.java +512 -508
  40. data/src/main/java/processing/opengl/PGL.java +3106 -3066
  41. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +4 -4
  42. data/src/main/java/processing/opengl/PShader.java +1442 -1341
  43. data/vendors/Rakefile +3 -27
  44. metadata +12 -25
  45. data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
  46. data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
  47. data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
  48. data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
  49. data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
  50. data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
  51. data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
  52. data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
  53. data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
  54. data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
  55. data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
  56. data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
  57. data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
  58. data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
  59. data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
  60. data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
  61. data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
  62. data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
  63. data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
  64. data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
@@ -32,6 +32,7 @@ import java.io.File;
32
32
  *
33
33
  * @author Martin Prout
34
34
  */
35
+ @FunctionalInterface
35
36
  public interface Chooser {
36
37
 
37
38
  public void file_selected(File selection);
@@ -1,18 +1,18 @@
1
- /*
1
+ /*
2
2
  * Copyright (c) 2016-19 Martin Prout
3
- *
3
+ *
4
4
  * This library is free software; you can redistribute it and/or
5
5
  * modify it under the terms of the GNU Lesser General Public
6
6
  * License as published by the Free Software Foundation; either
7
7
  * version 2.1 of the License, or (at your option) any later version.
8
- *
8
+ *
9
9
  * http://creativecommons.org/licenses/LGPL/2.1/
10
- *
10
+ *
11
11
  * This library is distributed in the hope that it will be useful,
12
12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
14
  * Lesser General Public License for more details.
15
- *
15
+ *
16
16
  * You should have received a copy of the GNU Lesser General Public
17
17
  * License along with this library; if not, write to the Free Software
18
18
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -24,6 +24,7 @@ package monkstone.slider;
24
24
  * Peasycam when I was struggling with non functioning browser applet, probably
25
25
  * superfluous here.
26
26
  */
27
+ @FunctionalInterface
27
28
  public interface WheelHandler {
28
29
 
29
30
  /**
@@ -33,6 +33,7 @@ import org.jruby.runtime.ThreadContext;
33
33
  import org.jruby.runtime.builtin.IRubyObject;
34
34
  import monkstone.vecmath.JRender;
35
35
  import monkstone.vecmath.vec2.Vec2;
36
+ import org.jruby.RubyNumeric;
36
37
 
37
38
  /**
38
39
  *
@@ -385,7 +386,7 @@ public final class Vec3 extends RubyObject {
385
386
  @JRubyMethod(name = "/", required = 1)
386
387
  public IRubyObject op_div(ThreadContext context, IRubyObject scalar) {
387
388
  Ruby runtime = context.runtime;
388
- var divisor = (scalar instanceof RubyFloat)
389
+ double divisor = (scalar instanceof RubyFloat)
389
390
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
390
391
  if (Math.abs(divisor) < Vec3.EPSILON) {
391
392
  return this;
@@ -432,7 +433,7 @@ public final class Vec3 extends RubyObject {
432
433
  return this;
433
434
  }
434
435
  }
435
- var new_mag = (scalar instanceof RubyFloat)
436
+ double new_mag = (scalar instanceof RubyFloat)
436
437
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
437
438
  double current = Math.sqrt(jx * jx + jy * jy + jz * jz);
438
439
  if (current > EPSILON) {
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) 2015-19 Martin Prout
3
+ *
4
+ * This library is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * http://creativecommons.org/licenses/LGPL/2.1/
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ package monkstone.videoevent;
22
+ import processing.video.Capture;
23
+
24
+ @FunctionalInterface
25
+ public interface CaptureEvent{
26
+ public void captureEvent(Capture capture);
27
+ }
@@ -1,48 +1,32 @@
1
- /*
1
+ /*
2
2
  * Copyright (c) 2015-19 Martin Prout
3
- *
3
+ *
4
4
  * This library is free software; you can redistribute it and/or
5
5
  * modify it under the terms of the GNU Lesser General Public
6
6
  * License as published by the Free Software Foundation; either
7
7
  * version 2.1 of the License, or (at your option) any later version.
8
- *
8
+ *
9
9
  * http://creativecommons.org/licenses/LGPL/2.1/
10
- *
10
+ *
11
11
  * This library is distributed in the hope that it will be useful,
12
12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
14
  * Lesser General Public License for more details.
15
- *
15
+ *
16
16
  * You should have received a copy of the GNU Lesser General Public
17
17
  * License along with this library; if not, write to the Free Software
18
18
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
19
  */
20
- package monkstone.videoevent;
21
20
 
21
+ package monkstone.videoevent;
22
22
  import processing.video.Movie;
23
- import processing.video.Capture;
24
23
 
25
24
  /**
26
- * This interface makes it easier/possible to use the reflection methods from
27
- * Movie and Capture classes in Propane::App in propane
28
- *
25
+ * This interface makes it easier/possible to use the reflection methods
26
+ * from Movie and Capture classes in Processing::App in JRubyArt
29
27
  * @author Martin Prout
30
28
  */
31
- public interface VideoInterface {
32
-
33
- /**
34
- * Used to implement reflection method in PApplet
35
- *
36
- * @see processing.video.Movie
37
- * @param movie Movie
38
- */
29
+ @FunctionalInterface
30
+ public interface MovieEvent {
39
31
  public void movieEvent(Movie movie);
40
-
41
- /**
42
- * Used to implement reflection method in PApplet
43
- *
44
- * @see processing.video.Capture
45
- * @param capture Capture
46
- */
47
- public void captureEvent(Capture capture);
48
32
  }
@@ -1024,7 +1024,7 @@ public class PSurfaceAWT extends PSurfaceNone {
1024
1024
  */
1025
1025
  /**
1026
1026
  * Set this sketch to communicate its state back to the PDE.
1027
- * <p/>
1027
+ *
1028
1028
  * This uses the stderr stream to write positions of the window (so that it
1029
1029
  * will be saved by the PDE for the next run) and notify on quit. See more
1030
1030
  * notes in the Worker class.
@@ -31,6 +31,7 @@ import java.awt.DisplayMode;
31
31
  // handleSettings() and displayDensity()
32
32
  import java.awt.GraphicsDevice;
33
33
  import java.awt.GraphicsEnvironment;
34
+ import java.awt.GraphicsConfiguration;
34
35
  // used to present the fullScreen() warning about Spaces on OS X
35
36
  import javax.swing.JOptionPane;
36
37
 
@@ -38,6 +39,14 @@ import javax.swing.JOptionPane;
38
39
  import java.awt.HeadlessException;
39
40
  import java.awt.Toolkit;
40
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
+
41
50
  // used by selectInput(), selectOutput(), selectFolder()
42
51
  import java.awt.EventQueue;
43
52
  import java.awt.FileDialog;
@@ -71,10 +80,7 @@ import java.util.concurrent.ThreadFactory;
71
80
  import java.util.regex.*;
72
81
  import java.util.zip.*;
73
82
  import javax.swing.UnsupportedLookAndFeelException;
74
-
75
- import processing.core.util.image.ImageLoadFacade;
76
- import processing.core.util.io.InputFactory;
77
- import processing.core.util.io.PathUtil;
83
+ import java.awt.geom.AffineTransform;
78
84
  import processing.data.*;
79
85
  import processing.event.*;
80
86
  import processing.opengl.*;
@@ -137,9 +143,8 @@ public class PApplet implements PConstants {
137
143
  }
138
144
 
139
145
  /**
140
- * Do not use; javaPlatform or javaVersionName are better options. For
141
- * instance, javaPlatform is useful when you need a number for comparison,
142
- * i.e. "if (javaPlatform >= 9)".
146
+ * Do not use; or javaVersionName are better options. For instance, is useful
147
+ * when you need a number for comparison, i.e. "if ( >= 9)".
143
148
  */
144
149
  @Deprecated
145
150
  public static final float javaVersion = 1 + JAVA_PLATFORM / 10f;
@@ -434,10 +439,10 @@ public class PApplet implements PConstants {
434
439
  * <b>draw()</b>). But, inside mouse events, they update each time the event
435
440
  * is called. If they weren't separated, then the mouse would be read only
436
441
  * once per frame, making response choppy. If the mouse variables were always
437
- * updated multiple times per frame, using <b>line(pmouseX, pmouseY, mouseX,
438
- * mouseY)</b> inside <b>draw()</b> would have lots of gaps, because
439
- * <b>pmouseX</b> may have changed several times in between the calls to
440
- * <b>line()</b>. Use <b>pmouseX</b> and
442
+ * updated multiple times per frame, using <NOBR><b>line(pmouseX, pmouseY,
443
+ * mouseX, mouseY)</b></NOBR> inside <b>draw()</b> would have lots of gaps,
444
+ * because <b>pmouseX</b> may have changed several times in between the calls
445
+ * to <b>line()</b>. Use <b>pmouseX</b> and
441
446
  * <b>pmouseY</b> inside <b>draw()</b> if you want values relative to the
442
447
  * previous frame. Use <b>pmouseX</b> and <b>pmouseY</b> inside the mouse
443
448
  * functions if you want continuous response.
@@ -988,7 +993,7 @@ public class PApplet implements PConstants {
988
993
  BufferedReader errReader = createReader(p.getErrorStream());
989
994
  StringBuilder stdout = new StringBuilder();
990
995
  StringBuilder stderr = new StringBuilder();
991
- String line;
996
+ String line = null;
992
997
  try {
993
998
  while ((line = outReader.readLine()) != null) {
994
999
  stdout.append(line);
@@ -1114,11 +1119,12 @@ public class PApplet implements PConstants {
1114
1119
  *
1115
1120
  * This function returns the number "2" if the screen is a high-density screen
1116
1121
  * (called a Retina display on OS X or high-dpi on Windows and Linux) and a
1117
- * "1" if not. This iThis information is useful for a program to adapt to run
1118
- * at double the pixel density on a screen that supports it.n( end
1119
- * auto-generated )* @webref
1122
+ * "1" if not. This information is useful for a program to adapt to run at
1123
+ * double the pixel density on a screen that supports it.
1124
+ *
1125
+ * ( end auto-generated )
1120
1126
  *
1121
- * @return environment
1127
+ * @webref environment
1122
1128
  * @see PApplet#pixelDensity(int)
1123
1129
  * @see PApplet#size(int,int)
1124
1130
  */
@@ -1138,65 +1144,20 @@ public class PApplet implements PConstants {
1138
1144
 
1139
1145
  /**
1140
1146
  * @param display the display number to check
1141
- * @return
1142
1147
  */
1143
- public int displayDensity(int display) {
1144
- if (PApplet.platform == PConstants.MACOSX) {
1145
- // This should probably be reset each time there's a display change.
1146
- // A 5-minute search didn't turn up any such event in the Java 7 API.
1147
- // Also, should we use the Toolkit associated with the editor window?
1148
- final String javaVendor = System.getProperty("java.vendor");
1149
- if (javaVendor.contains("Oracle")) {
1150
- GraphicsDevice device;
1151
- GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
1152
-
1153
- switch (display) {
1154
- case -1:
1155
- device = env.getDefaultScreenDevice();
1156
- break;
1157
- case SPAN:
1158
- throw new RuntimeException("displayDensity() only works with specific display numbers");
1159
- default:
1160
- GraphicsDevice[] devices = env.getScreenDevices();
1161
- if (display > 0 && display <= devices.length) {
1162
- device = devices[display - 1];
1163
- } else {
1164
- if (devices.length == 1) {
1165
- System.err.println("Only one display is currently known, use displayDensity(1).");
1166
- } else {
1167
- System.err.format("Your displays are numbered %d through %d, "
1168
- + "pass one of those numbers to displayDensity()%n", 1, devices.length);
1169
- }
1170
- throw new RuntimeException("Display " + display + " does not exist.");
1171
- }
1172
- break;
1173
- }
1174
-
1175
- try {
1176
- Field field = device.getClass().getDeclaredField("scale");
1177
- if (field != null) {
1178
- field.setAccessible(true);
1179
- Object scale = field.get(device);
1148
+ /**
1149
+ * @param display the display number to check
1150
+ */
1151
+ public int displayDensity(int display) {
1152
+ GraphicsDevice graphicsDevice = GraphicsEnvironment
1153
+ .getLocalGraphicsEnvironment()
1154
+ .getDefaultScreenDevice();
1155
+ GraphicsConfiguration graphicsConfig = graphicsDevice
1156
+ .getDefaultConfiguration();
1180
1157
 
1181
- if (scale instanceof Integer && ((Integer) scale) == 2) {
1182
- return 2;
1183
- }
1184
- }
1185
- } catch (IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException ignore) {
1186
- }
1187
- }
1188
- } else if (PApplet.platform == PConstants.WINDOWS
1189
- || PApplet.platform == PConstants.LINUX) {
1190
- if (suggestedDensity == -1) {
1191
- // TODO: detect and return DPI scaling using JNA; Windows has
1192
- // a system-wide value, not sure how it works on Linux
1193
- return 1;
1194
- } else if (suggestedDensity == 1 || suggestedDensity == 2) {
1195
- return suggestedDensity;
1196
- }
1158
+ AffineTransform tx = graphicsConfig.getDefaultTransform();
1159
+ return (int) Math.round(tx.getScaleX());
1197
1160
  }
1198
- return 1;
1199
- }
1200
1161
 
1201
1162
  /**
1202
1163
  * @webref environment
@@ -1208,12 +1169,12 @@ public class PApplet implements PConstants {
1208
1169
  if (density != this.pixelDensity) {
1209
1170
  if (insideSettings("pixelDensity", density)) {
1210
1171
  if (density != 1 && density != 2) {
1211
- throw new RuntimeException("pixelDensity() can only be 1 or 2");
1172
+ throw new RuntimeException("pixel_density can only be 1 or 2");
1212
1173
  }
1213
1174
  if (!FX2D.equals(renderer) && density == 2 && displayDensity() == 1) {
1214
1175
  // FX has its own check in PSurfaceFX
1215
1176
  // Don't throw exception because the sketch should still work
1216
- System.err.println("pixelDensity(2) is not available for this display");
1177
+ System.err.println("pixel_density(2) is not available for this display");
1217
1178
  this.pixelDensity = 1;
1218
1179
  } else {
1219
1180
  this.pixelDensity = density;
@@ -1222,7 +1183,7 @@ public class PApplet implements PConstants {
1222
1183
  System.err.println("not inside settings");
1223
1184
  // this should only be reachable when not running in the PDE,
1224
1185
  // so saying it's a settings()--not just setup()--issue should be ok
1225
- throw new RuntimeException("pixelDensity() can only be used inside settings()");
1186
+ throw new RuntimeException("pixel_density can only be used inside settings()");
1226
1187
  }
1227
1188
  }
1228
1189
  }
@@ -1230,9 +1191,6 @@ public class PApplet implements PConstants {
1230
1191
  /**
1231
1192
  * Called by PSurface objects to set the width and height variables, and
1232
1193
  * update the pixelWidth and pixelHeight variables.
1233
- *
1234
- * @param width
1235
- * @param height
1236
1194
  */
1237
1195
  public void setSize(int width, int height) {
1238
1196
  this.width = width;
@@ -1276,10 +1234,10 @@ public class PApplet implements PConstants {
1276
1234
 
1277
1235
  private void smoothWarning(String method) {
1278
1236
  // When running from the PDE, say setup(), otherwise say settings()
1279
- final String where = external ? "setup" : "settings";
1280
- PGraphics.showWarning("%s() can only be used inside %s()", method, where);
1237
+ final String where = "settings";
1238
+ PGraphics.showWarning("%s can only be used inside %s", method, where);
1281
1239
  if (external) {
1282
- PGraphics.showWarning("When run from the PDE, %s() is automatically moved from setup() to settings()", method);
1240
+ PGraphics.showWarning("In vanilla processing, %s is automatically moved from setup to settings", method);
1283
1241
  }
1284
1242
  }
1285
1243
 
@@ -1497,7 +1455,7 @@ public class PApplet implements PConstants {
1497
1455
  * <li>resume – called when the sketch is resumed
1498
1456
  * <li>dispose – when the sketch is shutting down (definitely not safe to
1499
1457
  * draw)
1500
- * </ul>
1458
+ * <ul>
1501
1459
  * In addition, the new (for 2.0) processing.event classes are passed to the
1502
1460
  * following event types:
1503
1461
  * <ul>
@@ -1512,19 +1470,17 @@ public class PApplet implements PConstants {
1512
1470
  * @param target the target object that should receive the event
1513
1471
  */
1514
1472
  public void registerMethod(String methodName, Object target) {
1515
- switch (methodName) {
1516
- case "mouseEvent":
1517
- registerWithArgs("mouseEvent", target, new Class[]{processing.event.MouseEvent.class});
1518
- break;
1519
- case "keyEvent":
1520
- registerWithArgs("keyEvent", target, new Class[]{processing.event.KeyEvent.class});
1521
- break;
1522
- case "touchEvent":
1523
- registerWithArgs("touchEvent", target, new Class[]{processing.event.TouchEvent.class});
1524
- break;
1525
- default:
1526
- registerNoArgs(methodName, target);
1527
- break;
1473
+ if (methodName.equals("mouseEvent")) {
1474
+ registerWithArgs("mouseEvent", target, new Class[]{processing.event.MouseEvent.class});
1475
+
1476
+ } else if (methodName.equals("keyEvent")) {
1477
+ registerWithArgs("keyEvent", target, new Class[]{processing.event.KeyEvent.class});
1478
+
1479
+ } else if (methodName.equals("touchEvent")) {
1480
+ registerWithArgs("touchEvent", target, new Class[]{processing.event.TouchEvent.class});
1481
+
1482
+ } else {
1483
+ registerNoArgs(methodName, target);
1528
1484
  }
1529
1485
  }
1530
1486
 
@@ -1544,7 +1500,7 @@ public class PApplet implements PConstants {
1544
1500
  die("There is no public " + name + "() method in the class "
1545
1501
  + o.getClass().getName());
1546
1502
 
1547
- } catch (SecurityException e) {
1503
+ } catch (Exception e) {
1548
1504
  die("Could not register " + name + " + () for " + o, e);
1549
1505
  }
1550
1506
  }
@@ -1871,7 +1827,6 @@ public class PApplet implements PConstants {
1871
1827
  }
1872
1828
 
1873
1829
  /**
1874
- * @param renderer
1875
1830
  * @param display the screen to run the sketch on (1, 2, 3, etc. or on
1876
1831
  * multiple screens using SPAN)
1877
1832
  */
@@ -1905,8 +1860,8 @@ public class PApplet implements PConstants {
1905
1860
  * needed.
1906
1861
  *
1907
1862
  * The <b>size()</b> function can only be used once inside a sketch, and
1908
- * cannot be used for resizing.
1909
- * <b>renderer</b> parameter selects which rendering engine to use. For
1863
+ * cannot be used for resizing.<br/>
1864
+ * <br/> <b>renderer</b> parameter selects which rendering engine to use. For
1910
1865
  * example, if you will be drawing 3D shapes, use <b>P3D</b>, if you want to
1911
1866
  * export images from a program as a PDF file use <b>PDF</b>. A brief
1912
1867
  * description of the three primary renderers follows:
@@ -2078,22 +2033,23 @@ public class PApplet implements PConstants {
2078
2033
  /**
2079
2034
  * ( begin auto-generated from createGraphics.xml )
2080
2035
  *
2081
- * Creates and returns a new <b>PGraphics</b> object of the types P2D or
2082
- * P3D.Use this class if you need to draw into an off-screen graphics buffer.
2083
- * The PDF renderer requires the filename parameter. The DXF renderer should
2084
- * not be used with <b>createGraphics()</b>, it's only built for use with
2036
+ * Creates and returns a new <b>PGraphics</b> object of the types P2D or P3D.
2037
+ * Use this class if you need to draw into an off-screen graphics buffer. The
2038
+ * PDF renderer requires the filename parameter. The DXF renderer should not
2039
+ * be used with <b>createGraphics()</b>, it's only built for use with
2085
2040
  * <b>beginRaw()</b> and <b>endRaw()</b>.
2086
2041
  *
2087
2042
  * It's important to call any drawing functions between <b>beginDraw()</b>
2088
2043
  * and <b>endDraw()</b> statements. This is also true for any functions that
2089
- * affect drawing, such as <b>smooth()</b> or <b>colorMode()</b>. the main
2090
- * drawing surface which is completely opaque, surfaces created with
2091
- * <b>createGraphics()</b> can have transparency. This makes it possible to
2092
- * draw into a graphics and maintain the alpha channel. By using <b>save()</b>
2093
- * to write a PNG or TGA file, the transparency of the graphics object will be
2094
- * honored. Note that transparency levels are binary: pixels are either
2095
- * complete opaque or transparent. For the time being, this means that text
2096
- * characters will be opaque blocks. This will be fixed in a future release (<a
2044
+ * affect drawing, such as <b>smooth()</b> or <b>colorMode()</b>.<br/>
2045
+ * <br/> the main drawing surface which is completely opaque, surfaces created
2046
+ * with <b>createGraphics()</b> can have transparency. This makes it possible
2047
+ * to draw into a graphics and maintain the alpha channel. By using
2048
+ * <b>save()</b> to write a PNG or TGA file, the transparency of the graphics
2049
+ * object will be honored. Note that transparency levels are binary: pixels
2050
+ * are either complete opaque or transparent. For the time being, this means
2051
+ * that text characters will be opaque blocks. This will be fixed in a future
2052
+ * release (<a
2097
2053
  * href="http://code.google.com/p/processing/issues/detail?id=80">Issue
2098
2054
  * 80</a>).
2099
2055
  *
@@ -2142,7 +2098,6 @@ public class PApplet implements PConstants {
2142
2098
  * <A HREF="http://dev.processing.org/reference/core/javadoc/processing/core/PImage.html#save(java.lang.String)">PImage.save()</A>.
2143
2099
  * </UL>
2144
2100
  *
2145
- * @return
2146
2101
  * @webref rendering
2147
2102
  * @param w width in pixels
2148
2103
  * @param h height in pixels
@@ -2158,11 +2113,7 @@ public class PApplet implements PConstants {
2158
2113
  * Create an offscreen graphics surface for drawing, in this case for a
2159
2114
  * renderer that writes to a file (such as PDF or DXF).
2160
2115
  *
2161
- * @param w
2162
- * @param h
2163
- * @param renderer
2164
2116
  * @param path the name of the file (can be an absolute or relative path)
2165
- * @return
2166
2117
  */
2167
2118
  public PGraphics createGraphics(int w, int h,
2168
2119
  String renderer, String path) {
@@ -2261,7 +2212,7 @@ public class PApplet implements PConstants {
2261
2212
  + " renderer is not in the class path.");
2262
2213
  }
2263
2214
 
2264
- } catch (Exception e) {
2215
+ } catch (IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException e) {
2265
2216
  if ((e instanceof IllegalArgumentException)
2266
2217
  || (e instanceof NoSuchMethodException)
2267
2218
  || (e instanceof IllegalAccessException)) {
@@ -2290,6 +2241,7 @@ public class PApplet implements PConstants {
2290
2241
 
2291
2242
  /**
2292
2243
  * Create default renderer, likely to be resized, but needed for surface init.
2244
+ * @return
2293
2245
  */
2294
2246
  protected PGraphics createPrimaryGraphics() {
2295
2247
  return makeGraphics(sketchWidth(), sketchHeight(),
@@ -2574,7 +2526,6 @@ public class PApplet implements PConstants {
2574
2526
  /**
2575
2527
  * Add an event to the internal event queue, or process it immediately if the
2576
2528
  * sketch is not currently looping.
2577
- *
2578
2529
  * @param pe
2579
2530
  */
2580
2531
  public void postEvent(processing.event.Event pe) {
@@ -3122,15 +3073,15 @@ public class PApplet implements PConstants {
3122
3073
  * ( begin auto-generated from millis.xml )
3123
3074
  *
3124
3075
  * Returns the number of milliseconds (thousandths of a second) since starting
3125
- * an applet.This information is often used for timing animation sequences. (
3126
- * end auto-generated )
3076
+ * an applet. This information is often used for timing animation sequences.
3077
+ *
3078
+ * ( end auto-generated )
3127
3079
  *
3128
3080
  * <h3>Advanced</h3>
3129
3081
  * <p>
3130
3082
  * This is a function, rather than a variable, because it may change multiple
3131
3083
  * times per frame.
3132
3084
  *
3133
- * @return
3134
3085
  * @webref input:time_date
3135
3086
  * @see PApplet#second()
3136
3087
  * @see PApplet#minute()
@@ -3147,11 +3098,11 @@ public class PApplet implements PConstants {
3147
3098
  /**
3148
3099
  * ( begin auto-generated from second.xml )
3149
3100
  *
3150
- * Processing communicates with the clock on your computer.The
3101
+ * Processing communicates with the clock on your computer. The
3151
3102
  * <b>second()</b> function returns the current second as a value from 0 - 59.
3103
+ *
3152
3104
  * ( end auto-generated )
3153
3105
  *
3154
- * @return
3155
3106
  * @webref input:time_date
3156
3107
  * @see PApplet#millis()
3157
3108
  * @see PApplet#minute()
@@ -3168,11 +3119,11 @@ public class PApplet implements PConstants {
3168
3119
  /**
3169
3120
  * ( begin auto-generated from minute.xml )
3170
3121
  *
3171
- * Processing communicates with the clock on your computer.The
3122
+ * Processing communicates with the clock on your computer. The
3172
3123
  * <b>minute()</b> function returns the current minute as a value from 0 - 59.
3124
+ *
3173
3125
  * ( end auto-generated )
3174
3126
  *
3175
- * @return
3176
3127
  * @webref input:time_date
3177
3128
  * @see PApplet#millis()
3178
3129
  * @see PApplet#second()
@@ -3190,11 +3141,11 @@ public class PApplet implements PConstants {
3190
3141
  /**
3191
3142
  * ( begin auto-generated from hour.xml )
3192
3143
  *
3193
- * Processing communicates with the clock on your computer.The
3194
- * <b>hour()</b> function returns the current hour as a value from 0 - 23. (
3195
- * end auto-generated )
3144
+ * Processing communicates with the clock on your computer. The
3145
+ * <b>hour()</b> function returns the current hour as a value from 0 - 23.
3146
+ *
3147
+ * ( end auto-generated )
3196
3148
  *
3197
- * @return
3198
3149
  * @webref input:time_date
3199
3150
  * @see PApplet#millis()
3200
3151
  * @see PApplet#second()
@@ -3211,16 +3162,16 @@ public class PApplet implements PConstants {
3211
3162
  /**
3212
3163
  * ( begin auto-generated from day.xml )
3213
3164
  *
3214
- * Processing communicates with the clock on your computer.The
3215
- * <b>day()</b> function returns the current day as a value from 1 - 31. ( end
3216
- * auto-generated )
3165
+ * Processing communicates with the clock on your computer. The
3166
+ * <b>day()</b> function returns the current day as a value from 1 - 31.
3167
+ *
3168
+ * ( end auto-generated )
3217
3169
  * <h3>Advanced</h3>
3218
3170
  * Get the current day of the month (1 through 31).
3219
3171
  * <p>
3220
3172
  * If you're looking for the day of the week (M-F or whatever) or day of the
3221
3173
  * year (1..365) then use java's Calendar.get()
3222
3174
  *
3223
- * @return
3224
3175
  * @webref input:time_date
3225
3176
  * @see PApplet#millis()
3226
3177
  * @see PApplet#second()
@@ -3236,11 +3187,11 @@ public class PApplet implements PConstants {
3236
3187
  /**
3237
3188
  * ( begin auto-generated from month.xml )
3238
3189
  *
3239
- * Processing communicates with the clock on your computer.The
3240
- * <b>month()</b> function returns the current month as a value from 1 - 12. (
3241
- * end auto-generated )
3190
+ * Processing communicates with the clock on your computer. The
3191
+ * <b>month()</b> function returns the current month as a value from 1 - 12.
3192
+ *
3193
+ * ( end auto-generated )
3242
3194
  *
3243
- * @return
3244
3195
  * @webref input:time_date
3245
3196
  * @see PApplet#millis()
3246
3197
  * @see PApplet#second()
@@ -3257,12 +3208,13 @@ public class PApplet implements PConstants {
3257
3208
  /**
3258
3209
  * ( begin auto-generated from year.xml )
3259
3210
  *
3260
- * Processing communicates with the clock on your computer.The
3211
+ * Processing communicates with the clock on your computer. The
3261
3212
  * <b>year()</b> function returns the current year as an integer (2003, 2004,
3262
- * 2005, etc). ( end auto-generated ) The <b>year()</b> function returns the
3263
- * current year as an integer (2003, 2004, 2005, etc).
3213
+ * 2005, etc).
3214
+ *
3215
+ * ( end auto-generated ) The <b>year()</b> function returns the current year
3216
+ * as an integer (2003, 2004, 2005, etc).
3264
3217
  *
3265
- * @return
3266
3218
  * @webref input:time_date
3267
3219
  * @see PApplet#millis()
3268
3220
  * @see PApplet#second()
@@ -3367,7 +3319,7 @@ public class PApplet implements PConstants {
3367
3319
  /**
3368
3320
  * ( begin auto-generated from launch.xml )
3369
3321
  *
3370
- * Attempts to open an application or file using your platform's launcher.The
3322
+ * Attempts to open an application or file using your platform's launcher. The
3371
3323
  * <b>file</b> parameter is a String specifying the file name and location.
3372
3324
  * The location parameter must be a full path name, or the name of an
3373
3325
  * executable in the system's PATH. In most cases, using a full path is the
@@ -3396,7 +3348,6 @@ public class PApplet implements PConstants {
3396
3348
  *
3397
3349
  * ( end auto-generated )
3398
3350
  *
3399
- * @return
3400
3351
  * @webref input:files
3401
3352
  * @param args arguments to the launcher, eg. a filename.
3402
3353
  * @usage Application
@@ -3428,14 +3379,12 @@ public class PApplet implements PConstants {
3428
3379
  /*int result =*/ p.waitFor();
3429
3380
  // Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3430
3381
  openLauncher = launcher;
3431
- } catch (IOException | InterruptedException e) {
3382
+ } catch (Exception e) {
3432
3383
  }
3433
- }
3434
- if (openLauncher == null) {
3384
+ } if (openLauncher == null) {
3435
3385
  System.err.println("Could not find xdg-open, gnome-open, or kde-open: "
3436
3386
  + "the open() command may not work.");
3437
- }
3438
- if (openLauncher != null) {
3387
+ } if (openLauncher != null) {
3439
3388
  params = new String[]{openLauncher};
3440
3389
  }
3441
3390
  //} else { // give up and just pass it to Runtime.exec()
@@ -3460,7 +3409,7 @@ public class PApplet implements PConstants {
3460
3409
  }
3461
3410
 
3462
3411
  /**
3463
- * Pass a set of arguments directly to the command line.Uses Java's
3412
+ * Pass a set of arguments directly to the command line. Uses Java's
3464
3413
  * <A HREF="https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#exec-java.lang.String:A-">Runtime.exec()</A>
3465
3414
  * method. This is different from the
3466
3415
  * <A HREF="https://processing.org/reference/launch_.html">launch()</A>
@@ -3478,7 +3427,6 @@ public class PApplet implements PConstants {
3478
3427
  * </pre> You can also get the system output and error streams from the
3479
3428
  * Process object, but that's more that we'd like to cover here.
3480
3429
  *
3481
- * @param args
3482
3430
  * @return a
3483
3431
  * <A HREF="https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html">Process</A>
3484
3432
  * object
@@ -3591,11 +3539,6 @@ public class PApplet implements PConstants {
3591
3539
 
3592
3540
  /**
3593
3541
  * Same as exec() above, but prefixes the call with a shell.
3594
- *
3595
- * @param stdout
3596
- * @param stderr
3597
- * @param args
3598
- * @return
3599
3542
  */
3600
3543
  static public int shell(StringList stdout, StringList stderr, String... args) {
3601
3544
  String shell;
@@ -3645,18 +3588,14 @@ public class PApplet implements PConstants {
3645
3588
  /**
3646
3589
  * Better way of handling e.printStackTrace() calls so that they can be
3647
3590
  * handled by subclasses as necessary.
3648
- *
3649
- * @param t
3650
3591
  */
3651
3592
  protected void printStackTrace(Throwable t) {
3652
3593
  t.printStackTrace();
3653
3594
  }
3654
3595
 
3655
3596
  /**
3656
- * Function for an applet/application to kill itself and display an
3657
- * error.Mostly this is here to be improved later.
3658
- *
3659
- * @param what
3597
+ * Function for an applet/application to kill itself and display an error.
3598
+ * Mostly this is here to be improved later.
3660
3599
  */
3661
3600
  public void die(String what) {
3662
3601
  dispose();
@@ -3664,10 +3603,7 @@ public class PApplet implements PConstants {
3664
3603
  }
3665
3604
 
3666
3605
  /**
3667
- * Same as above but with an exception.Also needs work.
3668
- *
3669
- * @param what
3670
- * @param e
3606
+ * Same as above but with an exception. Also needs work.
3671
3607
  */
3672
3608
  public void die(String what, Exception e) {
3673
3609
  if (e != null) {
@@ -3838,8 +3774,8 @@ public class PApplet implements PConstants {
3838
3774
  * to the name. These files are saved to the sketch's folder, which may be
3839
3775
  * opened by selecting "Show sketch folder" from the "Sketch" menu. It is not
3840
3776
  * possible to use <b>save()</b> while running the program in a web browser.
3841
- * images saved from the main drawing window will be opaque. To save images
3842
- * without a background, use <b>createGraphics()</b>.
3777
+ * <br/> images saved from the main drawing window will be opaque. To save
3778
+ * images without a background, use <b>createGraphics()</b>.
3843
3779
  *
3844
3780
  * ( end auto-generated )
3845
3781
  *
@@ -3883,7 +3819,7 @@ public class PApplet implements PConstants {
3883
3819
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
3884
3820
  * save a file back to a server, see the <a
3885
3821
  * href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to
3886
- * web</A> code snippet on the Processing Wiki.
3822
+ * web</A> code snippet on the Processing Wiki.<br/>
3887
3823
  * <br/ >
3888
3824
  * All images saved from the main drawing window will be opaque. To save
3889
3825
  * images without a background, use <b>createGraphics()</b>.
@@ -3908,13 +3844,10 @@ public class PApplet implements PConstants {
3908
3844
 
3909
3845
  /**
3910
3846
  * Check a string for #### signs to see if the frame number should be
3911
- * inserted.Used for functions like saveFrame() and beginRecord() to replace
3912
- * the # marks with the frame number.If only one # is used, it will be
3847
+ * inserted. Used for functions like saveFrame() and beginRecord() to replace
3848
+ * the # marks with the frame number. If only one # is used, it will be
3913
3849
  * ignored, under the assumption that it's probably not intended to be the
3914
3850
  * frame number.
3915
- *
3916
- * @param what
3917
- * @return
3918
3851
  */
3919
3852
  public String insertFrame(String what) {
3920
3853
  int first = what.indexOf('#');
@@ -3942,10 +3875,8 @@ public class PApplet implements PConstants {
3942
3875
  }
3943
3876
 
3944
3877
  /**
3945
- * Replace the cursor with the specified PImage.The x- and y- coordinate of
3878
+ * Replace the cursor with the specified PImage. The x- and y- coordinate of
3946
3879
  * the center will be the center of the image.
3947
- *
3948
- * @param img
3949
3880
  */
3950
3881
  public void cursor(PImage img) {
3951
3882
  cursor(img, img.width / 2, img.height / 2);
@@ -4205,11 +4136,9 @@ public class PApplet implements PConstants {
4205
4136
  }
4206
4137
  */
4207
4138
  /**
4208
- * For arrays, use printArray() instead.This function causes a warning because
4209
- * the new print(Object...) and println(Object...) functions can't be reliably
4210
- * bound by the compiler.
4211
- *
4212
- * @param what
4139
+ * For arrays, use printArray() instead. This function causes a warning
4140
+ * because the new print(Object...) and println(Object...) functions can't be
4141
+ * reliably bound by the compiler.
4213
4142
  */
4214
4143
  static public void println(Object what) {
4215
4144
  if (what == null) {
@@ -4348,10 +4277,11 @@ public class PApplet implements PConstants {
4348
4277
  /**
4349
4278
  * ( begin auto-generated from abs.xml )
4350
4279
  *
4351
- * Calculates the absolute value (magnitude) of a number.The absolute value of
4352
- * a number is always positive. ( end auto-generated )
4280
+ * Calculates the absolute value (magnitude) of a number. The absolute value
4281
+ * of a number is always positive.
4282
+ *
4283
+ * ( end auto-generated )
4353
4284
  *
4354
- * @return
4355
4285
  * @webref math:calculation
4356
4286
  * @param n number to compute
4357
4287
  */
@@ -4366,13 +4296,12 @@ public class PApplet implements PConstants {
4366
4296
  /**
4367
4297
  * ( begin auto-generated from sq.xml )
4368
4298
  *
4369
- * Squares a number (multiplies a number by itself).The result is always a
4299
+ * Squares a number (multiplies a number by itself). The result is always a
4370
4300
  * positive number, as multiplying two negative numbers always yields a
4371
4301
  * positive result. For example, -1 * -1 = 1.
4372
4302
  *
4373
4303
  * ( end auto-generated )
4374
4304
  *
4375
- * @return
4376
4305
  * @webref math:calculation
4377
4306
  * @param n number to square
4378
4307
  * @see PApplet#sqrt(float)
@@ -4384,14 +4313,13 @@ public class PApplet implements PConstants {
4384
4313
  /**
4385
4314
  * ( begin auto-generated from sqrt.xml )
4386
4315
  *
4387
- * Calculates the square root of a number.The square root of a number is
4316
+ * Calculates the square root of a number. The square root of a number is
4388
4317
  * always positive, even though there may be a valid negative root. The square
4389
4318
  * root <b>s</b> of number <b>a</b> is such that <b>s*s = a</b>. It is the
4390
4319
  * opposite of squaring.
4391
4320
  *
4392
4321
  * ( end auto-generated )
4393
4322
  *
4394
- * @return
4395
4323
  * @webref math:calculation
4396
4324
  * @param n non-negative number
4397
4325
  * @see PApplet#pow(float, float)
@@ -4404,11 +4332,11 @@ public class PApplet implements PConstants {
4404
4332
  /**
4405
4333
  * ( begin auto-generated from log.xml )
4406
4334
  *
4407
- * Calculates the natural logarithm (the base-<i>e</i> logarithm) of a
4408
- * number.This function expects the values greater than 0.0. ( end
4409
- * auto-generated )
4335
+ * Calculates the natural logarithm (the base-<i>e</i> logarithm) of a number.
4336
+ * This function expects the values greater than 0.0.
4337
+ *
4338
+ * ( end auto-generated )
4410
4339
  *
4411
- * @return
4412
4340
  * @webref math:calculation
4413
4341
  * @param n number greater than 0.0
4414
4342
  */
@@ -4420,9 +4348,10 @@ public class PApplet implements PConstants {
4420
4348
  * ( begin auto-generated from exp.xml )
4421
4349
  *
4422
4350
  * Returns Euler's number <i>e</i> (2.71828...) raised to the power of the
4423
- * <b>value</b> parameter.( end auto-generated )
4351
+ * <b>value</b> parameter.
4352
+ *
4353
+ * ( end auto-generated )
4424
4354
  *
4425
- * @return
4426
4355
  * @webref math:calculation
4427
4356
  * @param n exponent to raise
4428
4357
  */
@@ -4433,14 +4362,13 @@ public class PApplet implements PConstants {
4433
4362
  /**
4434
4363
  * ( begin auto-generated from pow.xml )
4435
4364
  *
4436
- * Facilitates exponential expressions.The <b>pow()</b> function is an
4365
+ * Facilitates exponential expressions. The <b>pow()</b> function is an
4437
4366
  * efficient way of multiplying numbers by themselves (or their reciprocal) in
4438
4367
  * large quantities. For example, <b>pow(3, 5)</b> is equivalent to the
4439
4368
  * expression 3*3*3*3*3 and <b>pow(3, -5)</b> is equivalent to 1 / 3*3*3*3*3.
4440
4369
  *
4441
4370
  * ( end auto-generated )
4442
4371
  *
4443
- * @return
4444
4372
  * @webref math:calculation
4445
4373
  * @param n base of the exponential expression
4446
4374
  * @param e power by which to raise the base
@@ -4453,10 +4381,10 @@ public class PApplet implements PConstants {
4453
4381
  /**
4454
4382
  * ( begin auto-generated from max.xml )
4455
4383
  *
4456
- * Determines the largest value in a sequence of numbers.( end auto-generated
4457
- * )
4384
+ * Determines the largest value in a sequence of numbers.
4385
+ *
4386
+ * ( end auto-generated )
4458
4387
  *
4459
- * @return
4460
4388
  * @webref math:calculation
4461
4389
  * @param a first number to compare
4462
4390
  * @param b second number to compare
@@ -4476,10 +4404,7 @@ public class PApplet implements PConstants {
4476
4404
  }
4477
4405
  */
4478
4406
  /**
4479
- * @param a
4480
4407
  * @param c third number to compare
4481
- * @param b
4482
- * @return
4483
4408
  */
4484
4409
  static public final int max(int a, int b, int c) {
4485
4410
  return (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
@@ -4556,10 +4481,10 @@ public class PApplet implements PConstants {
4556
4481
  /**
4557
4482
  * ( begin auto-generated from min.xml )
4558
4483
  *
4559
- * Determines the smallest value in a sequence of numbers.( end auto-generated )
4484
+ * Determines the smallest value in a sequence of numbers.
4560
4485
  *
4486
+ * ( end auto-generated )
4561
4487
  *
4562
- * @return
4563
4488
  * @webref math:calculation
4564
4489
  * @param a first number
4565
4490
  * @param b second number
@@ -4577,7 +4502,6 @@ public class PApplet implements PConstants {
4577
4502
  */
4578
4503
  /**
4579
4504
  * @param list array of numbers to compare
4580
- * @return
4581
4505
  */
4582
4506
  static public final int min(int[] list) {
4583
4507
  if (list.length == 0) {
@@ -4631,10 +4555,10 @@ public class PApplet implements PConstants {
4631
4555
  /**
4632
4556
  * ( begin auto-generated from constrain.xml )
4633
4557
  *
4634
- * Constrains a value to not exceed a maximum and minimum value.( end auto-generated )
4558
+ * Constrains a value to not exceed a maximum and minimum value.
4635
4559
  *
4560
+ * ( end auto-generated )
4636
4561
  *
4637
- * @return
4638
4562
  * @webref math:calculation
4639
4563
  * @param amt the value to constrain
4640
4564
  * @param low minimum limit
@@ -4649,12 +4573,12 @@ public class PApplet implements PConstants {
4649
4573
  /**
4650
4574
  * ( begin auto-generated from sin.xml )
4651
4575
  *
4652
- * Calculates the sine of an angle.This function expects the values of the
4653
- <b>angle</b> parameter to be provided in radians (values from 0 to 6.28). Values are returned in the range -1 to 1.
4654
-
4655
- ( end auto-generated )
4576
+ * Calculates the sine of an angle. This function expects the values of the
4577
+ * <b>angle</b> parameter to be provided in radians (values from 0 to 6.28).
4578
+ * Values are returned in the range -1 to 1.
4579
+ *
4580
+ * ( end auto-generated )
4656
4581
  *
4657
- * @return
4658
4582
  * @webref math:trigonometry
4659
4583
  * @param angle an angle in radians
4660
4584
  * @see PApplet#cos(float)
@@ -4668,12 +4592,12 @@ public class PApplet implements PConstants {
4668
4592
  /**
4669
4593
  * ( begin auto-generated from cos.xml )
4670
4594
  *
4671
- * Calculates the cosine of an angle.This function expects the values of the
4672
- <b>angle</b> parameter to be provided in radians (values from 0 to PI*2). Values are returned in the range -1 to 1.
4673
-
4674
- ( end auto-generated )
4595
+ * Calculates the cosine of an angle. This function expects the values of the
4596
+ * <b>angle</b> parameter to be provided in radians (values from 0 to PI*2).
4597
+ * Values are returned in the range -1 to 1.
4598
+ *
4599
+ * ( end auto-generated )
4675
4600
  *
4676
- * @return
4677
4601
  * @webref math:trigonometry
4678
4602
  * @param angle an angle in radians
4679
4603
  * @see PApplet#sin(float)
@@ -4687,14 +4611,13 @@ public class PApplet implements PConstants {
4687
4611
  /**
4688
4612
  * ( begin auto-generated from tan.xml )
4689
4613
  *
4690
- * Calculates the ratio of the sine and cosine of an angle.This function
4691
- expects the values of the <b>angle</b> parameter to be provided in radians
4692
- (values from 0 to PI*2). Values are returned in the range
4693
- <b>infinity</b> to <b>-infinity</b>.
4614
+ * Calculates the ratio of the sine and cosine of an angle. This function
4615
+ * expects the values of the <b>angle</b> parameter to be provided in radians
4616
+ * (values from 0 to PI*2). Values are returned in the range
4617
+ * <b>infinity</b> to <b>-infinity</b>.
4694
4618
  *
4695
4619
  * ( end auto-generated )
4696
4620
  *
4697
- * @return
4698
4621
  * @webref math:trigonometry
4699
4622
  * @param angle an angle in radians
4700
4623
  * @see PApplet#cos(float)
@@ -4708,11 +4631,12 @@ public class PApplet implements PConstants {
4708
4631
  /**
4709
4632
  * ( begin auto-generated from asin.xml )
4710
4633
  *
4711
- * The inverse of <b>sin()</b>, returns the arc sine of a value.This function
4712
- expects the values in the range of -1 to 1 and values are returned in the
4713
- range <b>-PI/2</b> to <b>PI/2</b>. ( end auto-generated )
4634
+ * The inverse of <b>sin()</b>, returns the arc sine of a value. This function
4635
+ * expects the values in the range of -1 to 1 and values are returned in the
4636
+ * range <b>-PI/2</b> to <b>PI/2</b>.
4637
+ *
4638
+ * ( end auto-generated )
4714
4639
  *
4715
- * @return
4716
4640
  * @webref math:trigonometry
4717
4641
  * @param value the value whose arc sine is to be returned
4718
4642
  * @see PApplet#sin(float)
@@ -4726,11 +4650,12 @@ public class PApplet implements PConstants {
4726
4650
  /**
4727
4651
  * ( begin auto-generated from acos.xml )
4728
4652
  *
4729
- * The inverse of <b>cos()</b>, returns the arc cosine of a value.This
4730
- function expects the values in the range of -1 to 1 and values are returned
4731
- in the range <b>0</b> to <b>PI (3.1415927)</b>. ( end auto-generated )
4653
+ * The inverse of <b>cos()</b>, returns the arc cosine of a value. This
4654
+ * function expects the values in the range of -1 to 1 and values are returned
4655
+ * in the range <b>0</b> to <b>PI (3.1415927)</b>.
4656
+ *
4657
+ * ( end auto-generated )
4732
4658
  *
4733
- * @return
4734
4659
  * @webref math:trigonometry
4735
4660
  * @param value the value whose arc cosine is to be returned
4736
4661
  * @see PApplet#cos(float)
@@ -4744,12 +4669,13 @@ public class PApplet implements PConstants {
4744
4669
  /**
4745
4670
  * ( begin auto-generated from atan.xml )
4746
4671
  *
4747
- * The inverse of <b>tan()</b>, returns the arc tangent of a value.This
4748
- function expects the values in the range of -Infinity to Infinity
4749
- (exclusive) and values are returned in the range <b>-PI/2</b> to <b>PI/2
4750
- </b>. ( end auto-generated )
4672
+ * The inverse of <b>tan()</b>, returns the arc tangent of a value. This
4673
+ * function expects the values in the range of -Infinity to Infinity
4674
+ * (exclusive) and values are returned in the range <b>-PI/2</b> to <b>PI/2
4675
+ * </b>.
4676
+ *
4677
+ * ( end auto-generated )
4751
4678
  *
4752
- * @return
4753
4679
  * @webref math:trigonometry
4754
4680
  * @param value -Infinity to Infinity (exclusive)
4755
4681
  * @see PApplet#tan(float)
@@ -4764,8 +4690,8 @@ public class PApplet implements PConstants {
4764
4690
  * ( begin auto-generated from atan2.xml )
4765
4691
  *
4766
4692
  * Calculates the angle (in radians) from a specified point to the coordinate
4767
- * origin as measured from the positive x-axis.Values are returned as a
4768
- <b>float</b> in the range from <b>PI</b> to <b>-PI</b>. The <b>atan2()</b>
4693
+ * origin as measured from the positive x-axis. Values are returned as a
4694
+ * <b>float</b> in the range from <b>PI</b> to <b>-PI</b>. The <b>atan2()</b>
4769
4695
  * function is most often used for orienting geometry to the position of the
4770
4696
  * cursor. Note: The y-coordinate of the point is the first parameter and the
4771
4697
  * x-coordinate is the second due the the structure of calculating the
@@ -4773,7 +4699,6 @@ public class PApplet implements PConstants {
4773
4699
  *
4774
4700
  * ( end auto-generated )
4775
4701
  *
4776
- * @return
4777
4702
  * @webref math:trigonometry
4778
4703
  * @param y y-coordinate of the point
4779
4704
  * @param x x-coordinate of the point
@@ -4786,15 +4711,14 @@ public class PApplet implements PConstants {
4786
4711
  /**
4787
4712
  * ( begin auto-generated from degrees.xml )
4788
4713
  *
4789
- * Converts a radian measurement to its corresponding value in degrees.Radians and degrees are two ways of measuring the same thing.
4790
- * There are 360
4791
- degrees in a circle and 2*PI radians in a circle. For example, 90&deg; =
4714
+ * Converts a radian measurement to its corresponding value in degrees.
4715
+ * Radians and degrees are two ways of measuring the same thing. There are 360
4716
+ * degrees in a circle and 2*PI radians in a circle. For example, 90&deg; =
4792
4717
  * PI/2 = 1.5707964. All trigonometric functions in Processing require their
4793
4718
  * parameters to be specified in radians.
4794
4719
  *
4795
4720
  * ( end auto-generated )
4796
4721
  *
4797
- * @return
4798
4722
  * @webref math:trigonometry
4799
4723
  * @param radians radian value to convert to degrees
4800
4724
  * @see PApplet#radians(float)
@@ -4806,15 +4730,14 @@ public class PApplet implements PConstants {
4806
4730
  /**
4807
4731
  * ( begin auto-generated from radians.xml )
4808
4732
  *
4809
- * Converts a degree measurement to its corresponding value in radians.Radians and degrees are two ways of measuring the same thing.
4810
- * There are 360
4811
- degrees in a circle and 2*PI radians in a circle. For example, 90&deg; =
4733
+ * Converts a degree measurement to its corresponding value in radians.
4734
+ * Radians and degrees are two ways of measuring the same thing. There are 360
4735
+ * degrees in a circle and 2*PI radians in a circle. For example, 90&deg; =
4812
4736
  * PI/2 = 1.5707964. All trigonometric functions in Processing require their
4813
4737
  * parameters to be specified in radians.
4814
4738
  *
4815
4739
  * ( end auto-generated )
4816
4740
  *
4817
- * @return
4818
4741
  * @webref math:trigonometry
4819
4742
  * @param degrees degree value to convert to radians
4820
4743
  * @see PApplet#degrees(float)
@@ -4827,9 +4750,10 @@ public class PApplet implements PConstants {
4827
4750
  * ( begin auto-generated from ceil.xml )
4828
4751
  *
4829
4752
  * Calculates the closest int value that is greater than or equal to the value
4830
- * of the parameter.For example, <b>ceil(9.03)</b> returns the value 10. ( end auto-generated )
4753
+ * of the parameter. For example, <b>ceil(9.03)</b> returns the value 10.
4754
+ *
4755
+ * ( end auto-generated )
4831
4756
  *
4832
- * @return
4833
4757
  * @webref math:calculation
4834
4758
  * @param n number to round up
4835
4759
  * @see PApplet#floor(float)
@@ -4843,10 +4767,10 @@ public class PApplet implements PConstants {
4843
4767
  * ( begin auto-generated from floor.xml )
4844
4768
  *
4845
4769
  * Calculates the closest int value that is less than or equal to the value of
4846
- * the parameter.( end auto-generated )
4770
+ * the parameter.
4847
4771
  *
4772
+ * ( end auto-generated )
4848
4773
  *
4849
- * @return
4850
4774
  * @webref math:calculation
4851
4775
  * @param n number to round down
4852
4776
  * @see PApplet#ceil(float)
@@ -4859,10 +4783,11 @@ public class PApplet implements PConstants {
4859
4783
  /**
4860
4784
  * ( begin auto-generated from round.xml )
4861
4785
  *
4862
- * Calculates the integer closest to the <b>value</b> parameter.For example,
4863
- <b>round(9.2)</b> returns the value 9. ( end auto-generated )
4786
+ * Calculates the integer closest to the <b>value</b> parameter. For example,
4787
+ * <b>round(9.2)</b> returns the value 9.
4788
+ *
4789
+ * ( end auto-generated )
4864
4790
  *
4865
- * @return
4866
4791
  * @webref math:calculation
4867
4792
  * @param n number to round
4868
4793
  * @see PApplet#floor(float)
@@ -4879,15 +4804,14 @@ public class PApplet implements PConstants {
4879
4804
  /**
4880
4805
  * ( begin auto-generated from mag.xml )
4881
4806
  *
4882
- * Calculates the magnitude (or length) of a vector.A vector is a direction
4883
- in space commonly used in computer graphics and linear algebra. Because it
4884
- has no "start" position, the magnitude of a vector can be thought of as the
4885
- distance from coordinate (0,0) to its (x,y) value. Therefore, mag() is a
4886
- shortcut for writing "dist(0, 0, x, y)".
4887
-
4888
- ( end auto-generated )
4807
+ * Calculates the magnitude (or length) of a vector. A vector is a direction
4808
+ * in space commonly used in computer graphics and linear algebra. Because it
4809
+ * has no "start" position, the magnitude of a vector can be thought of as the
4810
+ * distance from coordinate (0,0) to its (x,y) value. Therefore, mag() is a
4811
+ * shortcut for writing "dist(0, 0, x, y)".
4812
+ *
4813
+ * ( end auto-generated )
4889
4814
  *
4890
- * @return
4891
4815
  * @webref math:calculation
4892
4816
  * @param a first value
4893
4817
  * @param b second value
@@ -4905,10 +4829,10 @@ public class PApplet implements PConstants {
4905
4829
  /**
4906
4830
  * ( begin auto-generated from dist.xml )
4907
4831
  *
4908
- * Calculates the distance between two points.( end auto-generated )
4832
+ * Calculates the distance between two points.
4909
4833
  *
4834
+ * ( end auto-generated )
4910
4835
  *
4911
- * @return
4912
4836
  * @webref math:calculation
4913
4837
  * @param x1 x-coordinate of the first point
4914
4838
  * @param y1 y-coordinate of the first point
@@ -4925,15 +4849,14 @@ public class PApplet implements PConstants {
4925
4849
  /**
4926
4850
  * ( begin auto-generated from lerp.xml )
4927
4851
  *
4928
- * Calculates a number between two numbers at a specific increment.The
4929
- <b>amt</b> parameter is the amount to interpolate between the two values
4930
- where 0.0 equal to the first point, 0.1 is very near the first point, 0.5
4931
- is half-way in between, etc. The lerp function is convenient for creating
4932
- motion along a straight path and for drawing dotted lines.
4933
-
4934
- ( end auto-generated )
4852
+ * Calculates a number between two numbers at a specific increment. The
4853
+ * <b>amt</b> parameter is the amount to interpolate between the two values
4854
+ * where 0.0 equal to the first point, 0.1 is very near the first point, 0.5
4855
+ * is half-way in between, etc. The lerp function is convenient for creating
4856
+ * motion along a straight path and for drawing dotted lines.
4857
+ *
4858
+ * ( end auto-generated )
4935
4859
  *
4936
- * @return
4937
4860
  * @webref math:calculation
4938
4861
  * @param start first value
4939
4862
  * @param stop second value
@@ -4950,14 +4873,15 @@ public class PApplet implements PConstants {
4950
4873
  /**
4951
4874
  * ( begin auto-generated from norm.xml )
4952
4875
  *
4953
- * Normalizes a number from another range into a value between 0 and 1.Identical to map(value, low, high, 0, 1);
4954
-
4955
- Numbers outside the range are not clamped to 0 and 1, because out-of-range
4956
- values are often intentional and useful.
4876
+ * Normalizes a number from another range into a value between 0 and 1.
4877
+ *
4878
+ * Identical to map(value, low, high, 0, 1);
4879
+ *
4880
+ * Numbers outside the range are not clamped to 0 and 1, because out-of-range
4881
+ * values are often intentional and useful.
4957
4882
  *
4958
4883
  * ( end auto-generated )
4959
4884
  *
4960
- * @return
4961
4885
  * @webref math:calculation
4962
4886
  * @param value the incoming value to be converted
4963
4887
  * @param start lower bound of the value's current range
@@ -4972,14 +4896,15 @@ public class PApplet implements PConstants {
4972
4896
  /**
4973
4897
  * ( begin auto-generated from map.xml )
4974
4898
  *
4975
- * Re-maps a number from one range to another.In the example above, the
4976
- number '25' is converted from a value in the range 0..100 into a value that
4977
- ranges from the left edge (0) to the right edge (width) of the screen. Numbers outside the range are not clamped to 0 and 1, because out-of-range
4978
- values are often intentional and useful.
4979
-
4980
- ( end auto-generated )
4899
+ * Re-maps a number from one range to another. In the example above, the
4900
+ * number '25' is converted from a value in the range 0..100 into a value that
4901
+ * ranges from the left edge (0) to the right edge (width) of the screen.
4902
+ *
4903
+ * Numbers outside the range are not clamped to 0 and 1, because out-of-range
4904
+ * values are often intentional and useful.
4905
+ *
4906
+ * ( end auto-generated )
4981
4907
  *
4982
- * @return
4983
4908
  * @webref math:calculation
4984
4909
  * @param value the incoming value to be converted
4985
4910
  * @param start1 lower bound of the value's current range
@@ -5026,8 +4951,6 @@ public class PApplet implements PConstants {
5026
4951
 
5027
4952
  /**
5028
4953
  *
5029
- * @param high
5030
- * @return
5031
4954
  */
5032
4955
  public final float random(float high) {
5033
4956
  // avoid an infinite loop when 0 or NaN are passed in
@@ -5053,16 +4976,15 @@ public class PApplet implements PConstants {
5053
4976
  * ( begin auto-generated from randomGaussian.xml )
5054
4977
  *
5055
4978
  * Returns a float from a random series of numbers having a mean of 0 and
5056
- * standard deviation of 1.Each time the <b>randomGaussian()</b>
5057
- function is called, it returns a number fitting a Gaussian, or normal,
5058
- distribution. There is theoretically no minimum or maximum value that
5059
- <b>randomGaussian()</b> might return. Rather, there is just a very low
4979
+ * standard deviation of 1. Each time the <b>randomGaussian()</b>
4980
+ * function is called, it returns a number fitting a Gaussian, or normal,
4981
+ * distribution. There is theoretically no minimum or maximum value that
4982
+ * <b>randomGaussian()</b> might return. Rather, there is just a very low
5060
4983
  * probability that values far from the mean will be returned; and a higher
5061
4984
  * probability that numbers near the mean will be returned.
5062
4985
  *
5063
4986
  * ( end auto-generated )
5064
4987
  *
5065
- * @return
5066
4988
  * @webref math:random
5067
4989
  * @see PApplet#random(float,float)
5068
4990
  * @see PApplet#noise(float, float, float)
@@ -5077,9 +4999,9 @@ public class PApplet implements PConstants {
5077
4999
  /**
5078
5000
  * ( begin auto-generated from random.xml )
5079
5001
  *
5080
- * Generates random numbers.Each time the <b>random()</b> function is called,
5081
- it returns an unexpected value within the specified range. If one parameter
5082
- is passed to the function it will return a <b>float</b>
5002
+ * Generates random numbers. Each time the <b>random()</b> function is called,
5003
+ * it returns an unexpected value within the specified range. If one parameter
5004
+ * is passed to the function it will return a <b>float</b>
5083
5005
  * between zero and the value of the <b>high</b> parameter. The function call
5084
5006
  * <b>random(5)</b> returns values between 0 and 5 (starting at zero, up to
5085
5007
  * but not including 5). If two parameters are passed, it will return a
@@ -5090,7 +5012,6 @@ public class PApplet implements PConstants {
5090
5012
  *
5091
5013
  * ( end auto-generated )
5092
5014
  *
5093
- * @return
5094
5015
  * @webref math:random
5095
5016
  * @param low lower limit
5096
5017
  * @param high upper limit
@@ -5162,8 +5083,6 @@ public class PApplet implements PConstants {
5162
5083
  Random perlinRandom;
5163
5084
 
5164
5085
  /**
5165
- * @param x
5166
- * @return
5167
5086
  */
5168
5087
  public float noise(float x) {
5169
5088
  // is this legit? it's a dumb way to do it (but repair it later)
@@ -5171,9 +5090,6 @@ public class PApplet implements PConstants {
5171
5090
  }
5172
5091
 
5173
5092
  /**
5174
- * @param x
5175
- * @param y
5176
- * @return
5177
5093
  */
5178
5094
  public float noise(float x, float y) {
5179
5095
  return noise(x, y, 0f);
@@ -5187,7 +5103,7 @@ public class PApplet implements PConstants {
5187
5103
  * succession of numbers compared to the standard <b>random()</b> function. It
5188
5104
  * was invented by Ken Perlin in the 1980s and been used since in graphical
5189
5105
  * applications to produce procedural textures, natural motion, shapes,
5190
- * terrains etc. The main difference to the
5106
+ * terrains etc..contains The main difference to the
5191
5107
  * <b>random()</b> function is that Perlin noise is defined in an infinite
5192
5108
  * n-dimensional space where each pair of coordinates corresponds to a fixed
5193
5109
  * semi-random value (fixed only for the lifespan of the program). The
@@ -5195,11 +5111,11 @@ public class PApplet implements PConstants {
5195
5111
  * 1D, 2D and 3D noise, depending on the number of coordinates given. The
5196
5112
  * noise value can be animated by moving through the noise space as
5197
5113
  * demonstrated in the example above. The 2nd and 3rd dimension can also be
5198
- * interpreted as time.The actual noise is structured similar to an audio
5199
- * signal, in respect to the function's use of frequencies. Similar to the
5200
- * concept of harmonics in physics, perlin noise is computed over several
5201
- * octaves which are added together for the final result. Another way to
5202
- * adjust the character of the resulting sequence is the scale of the input
5114
+ * interpreted as time..containsThe actual noise is structured similar to an
5115
+ * audio signal, in respect to the function's use of frequencies. Similar to
5116
+ * the concept of harmonics in physics, perlin noise is computed over several
5117
+ * octaves which are added together for the final result. .containsAnother way
5118
+ * to adjust the character of the resulting sequence is the scale of the input
5203
5119
  * coordinates. As the function works within an infinite space the value of
5204
5120
  * the coordinates doesn't matter as such, only the distance between
5205
5121
  * successive coordinates does (eg. when using <b>noise()</b> within a loop).
@@ -5327,8 +5243,8 @@ public class PApplet implements PConstants {
5327
5243
  * falloff factor of 0.75 means each octave will now have 75% impact (25%
5328
5244
  * less) of the previous lower octave. Any value between 0.0 and 1.0 is valid,
5329
5245
  * however note that values greater than 0.5 might result in greater than 1.0
5330
- * values returned by <b>noise()</b>.
5331
- * By changing these parameters, the signal created by the <b>noise()</b>
5246
+ * values returned by <b>noise()</b>.<br
5247
+ * />By changing these parameters, the signal created by the <b>noise()</b>
5332
5248
  * function can be adapted to fit very specific needs and characteristics.
5333
5249
  *
5334
5250
  * ( end auto-generated )
@@ -5344,7 +5260,6 @@ public class PApplet implements PConstants {
5344
5260
  }
5345
5261
 
5346
5262
  /**
5347
- * @param lod
5348
5263
  * @see #noiseDetail(int)
5349
5264
  * @param falloff falloff factor for each octave
5350
5265
  */
@@ -5389,33 +5304,35 @@ public class PApplet implements PConstants {
5389
5304
  /**
5390
5305
  * ( begin auto-generated from loadImage.xml )
5391
5306
  *
5392
- * Loads an image into a variable of type <b>PImage</b>.Four types of images
5393
- ( <b>.gif</b>, <b>.jpg</b>, <b>.tga</b>, <b>.png</b>) images may be loaded. To load correctly, images must be located in the data directory of the
5394
- current sketch. In most cases, load all images in
5395
- <b>setup()</b> to preload them at the start of the program. Loading images
5396
- * inside <b>draw()</b> will reduce the speed of a program.
5397
- * <b>filename</b> parameter can also be a URL to a file found online. For
5398
- * security reasons, a Processing sketch found online can only download files
5399
- * from the same server from which it came. Getting around this restriction
5400
- * requires a <a
5401
- * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</a>.
5402
- * <b>extension</b> parameter is used to determine the image type in cases
5403
- * where the image filename does not end with a proper extension. Specify the
5404
- * extension as the second parameter to <b>loadImage()</b>, as shown in the
5405
- * third example on this page. an image is not loaded successfully, the
5406
- * <b>null</b> value is returned and an error message will be printed to the
5407
- * console. The error message does not halt the program, however the null
5408
- * value may cause a NullPointerException if your code does not check whether
5409
- * the value returned from <b>loadImage()</b> is null. on the type of error, a
5410
- * <b>PImage</b> object may still be returned, but the width and height of the
5411
- * image will be set to -1. This happens if bad image data is returned or
5412
- * cannot be decoded properly. Sometimes this happens with image URLs that
5413
- * produce a 403 error or that redirect to a password prompt, because
5414
- * <b>loadImage()</b> will attempt to interpret the HTML as image data.
5415
- *
5416
- * ( end auto-generated )
5417
- *
5418
- * @return
5307
+ * Loads an image into a variable of type <b>PImage</b>. Four types of images
5308
+ * ( <b>.gif</b>, <b>.jpg</b>, <b>.tga</b>, <b>.png</b>) images may be loaded.
5309
+ * To load correctly, images must be located in the data directory of the
5310
+ * current sketch. In most cases, load all images in
5311
+ * <b>setup()</b> to preload them at the start of the program. Loading images
5312
+ * inside <b>draw()</b> will reduce the speed of a program.<br/>
5313
+ * <br/> <b>filename</b> parameter can also be a URL to a file found online.
5314
+ * For security reasons, a Processing sketch found online can only download
5315
+ * files from the same server from which it came. Getting around this
5316
+ * restriction requires a <a
5317
+ * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</a>.<br/>
5318
+ * <br/> <b>extension</b> parameter is used to determine the image type in
5319
+ * cases where the image filename does not end with a proper extension.
5320
+ * Specify the extension as the second parameter to <b>loadImage()</b>, as
5321
+ * shown in the third example on this page.<br/>
5322
+ * <br/> an image is not loaded successfully, the <b>null</b> value is
5323
+ * returned and an error message will be printed to the console. The error
5324
+ * message does not halt the program, however the null value may cause a
5325
+ * NullPointerException if your code does not check whether the value returned
5326
+ * from <b>loadImage()</b> is null.<br/>
5327
+ * <br/> on the type of error, a <b>PImage</b> object may still be returned,
5328
+ * but the width and height of the image will be set to -1. This happens if
5329
+ * bad image data is returned or cannot be decoded properly. Sometimes this
5330
+ * happens with image URLs that produce a 403 error or that redirect to a
5331
+ * password prompt, because <b>loadImage()</b> will attempt to interpret the
5332
+ * HTML as image data.
5333
+ *
5334
+ * ( end auto-generated )
5335
+ *
5419
5336
  * @webref image:loading_displaying
5420
5337
  * @param filename name of file to load, can be .gif, .jpg, .tga, or a handful
5421
5338
  * of other image types depending on your platform
@@ -5442,9 +5359,7 @@ public class PApplet implements PConstants {
5442
5359
  // return loadImage(filename, null, params);
5443
5360
  // }
5444
5361
  /**
5445
- * @param filename
5446
5362
  * @param extension type of image to load, for example "png", "gif", "jpg"
5447
- * @return
5448
5363
  */
5449
5364
  public PImage loadImage(String filename, String extension) { //, Object params) {
5450
5365
 
@@ -5455,7 +5370,127 @@ public class PApplet implements PConstants {
5455
5370
  g.awaitAsyncSaveCompletion(filename);
5456
5371
  }
5457
5372
 
5458
- return ImageLoadFacade.get().loadFromFile(this, filename, extension);
5373
+ if (extension == null) {
5374
+ String lower = filename.toLowerCase();
5375
+ int dot = filename.lastIndexOf('.');
5376
+ if (dot == -1) {
5377
+ extension = "unknown"; // no extension found
5378
+
5379
+ } else {
5380
+ extension = lower.substring(dot + 1);
5381
+
5382
+ // check for, and strip any parameters on the url, i.e.
5383
+ // filename.jpg?blah=blah&something=that
5384
+ int question = extension.indexOf('?');
5385
+ if (question != -1) {
5386
+ extension = extension.substring(0, question);
5387
+ }
5388
+ }
5389
+ }
5390
+
5391
+ // just in case. them users will try anything!
5392
+ extension = extension.toLowerCase();
5393
+
5394
+ if (extension.equals("tga")) {
5395
+ try {
5396
+ PImage image = loadImageTGA(filename);
5397
+ // if (params != null) {
5398
+ // image.setParams(g, params);
5399
+ // }
5400
+ return image;
5401
+ } catch (IOException e) {
5402
+ printStackTrace(e);
5403
+ return null;
5404
+ }
5405
+ }
5406
+
5407
+ if (extension.equals("tif") || extension.equals("tiff")) {
5408
+ byte bytes[] = loadBytes(filename);
5409
+ PImage image = (bytes == null) ? null : PImage.loadTIFF(bytes);
5410
+ // if (params != null) {
5411
+ // image.setParams(g, params);
5412
+ // }
5413
+ return image;
5414
+ }
5415
+
5416
+ // For jpeg, gif, and png, load them using createImage(),
5417
+ // because the javax.imageio code was found to be much slower.
5418
+ // http://dev.processing.org/bugs/show_bug.cgi?id=392
5419
+ try {
5420
+ if (extension.equals("jpg") || extension.equals("jpeg")
5421
+ || extension.equals("gif") || extension.equals("png")
5422
+ || extension.equals("unknown")) {
5423
+ byte bytes[] = loadBytes(filename);
5424
+ if (bytes == null) {
5425
+ return null;
5426
+ } else {
5427
+ //Image awtImage = Toolkit.getDefaultToolkit().createImage(bytes);
5428
+ Image awtImage = new ImageIcon(bytes).getImage();
5429
+
5430
+ if (awtImage instanceof BufferedImage) {
5431
+ BufferedImage buffImage = (BufferedImage) awtImage;
5432
+ int space = buffImage.getColorModel().getColorSpace().getType();
5433
+ if (space == ColorSpace.TYPE_CMYK) {
5434
+ System.err.println(filename + " is a CMYK image, "
5435
+ + "only RGB images are supported.");
5436
+ return null;
5437
+ /*
5438
+ // wishful thinking, appears to not be supported
5439
+ // https://community.oracle.com/thread/1272045?start=0&tstart=0
5440
+ BufferedImage destImage =
5441
+ new BufferedImage(buffImage.getWidth(),
5442
+ buffImage.getHeight(),
5443
+ BufferedImage.TYPE_3BYTE_BGR);
5444
+ ColorConvertOp op = new ColorConvertOp(null);
5445
+ op.filter(buffImage, destImage);
5446
+ image = new PImage(destImage);
5447
+ */
5448
+ }
5449
+ }
5450
+
5451
+ PImage image = new PImage(awtImage);
5452
+ if (image.width == -1) {
5453
+ System.err.println("The file " + filename
5454
+ + " contains bad image data, or may not be an image.");
5455
+ }
5456
+
5457
+ // if it's a .gif image, test to see if it has transparency
5458
+ if (extension.equals("gif") || extension.equals("png")
5459
+ || extension.equals("unknown")) {
5460
+ image.checkAlpha();
5461
+ }
5462
+
5463
+ // if (params != null) {
5464
+ // image.setParams(g, params);
5465
+ // }
5466
+ image.parent = this;
5467
+ return image;
5468
+ }
5469
+ }
5470
+ } catch (Exception e) {
5471
+ // show error, but move on to the stuff below, see if it'll work
5472
+ printStackTrace(e);
5473
+ }
5474
+
5475
+ if (loadImageFormats == null) {
5476
+ loadImageFormats = ImageIO.getReaderFormatNames();
5477
+ }
5478
+ if (loadImageFormats != null) {
5479
+ for (int i = 0; i < loadImageFormats.length; i++) {
5480
+ if (extension.equals(loadImageFormats[i])) {
5481
+ return loadImageIO(filename);
5482
+ // PImage image = loadImageIO(filename);
5483
+ // if (params != null) {
5484
+ // image.setParams(g, params);
5485
+ // }
5486
+ // return image;
5487
+ }
5488
+ }
5489
+ }
5490
+
5491
+ // failed, could not load image after all those attempts
5492
+ System.err.println("Could not find a method to load " + filename);
5493
+ return null;
5459
5494
  }
5460
5495
 
5461
5496
  static private final String REQUEST_IMAGE_THREAD_PREFIX = "requestImage";
@@ -5470,19 +5505,18 @@ public class PApplet implements PConstants {
5470
5505
  * ( begin auto-generated from requestImage.xml )
5471
5506
  *
5472
5507
  * This function load images on a separate thread so that your sketch does not
5473
- * freeze while images load during <b>setup()</b>.While the image is loading,
5474
- its width and height will be 0. If an error occurs while loading the image,
5475
- its width and height will be set to -1. You'll know when the image has
5476
- loaded properly because its width and height will be greater than 0.
5477
- Asynchronous image loading (particularly when downloading from a server)
5478
- can dramatically improve performance.
5479
- <b>extension</b> parameter is used to determine the image type in cases
5480
- * where the image filename does not end with a proper extension. Specify the
5481
- * extension as the second parameter to <b>requestImage()</b>.
5508
+ * freeze while images load during <b>setup()</b>. While the image is loading,
5509
+ * its width and height will be 0. If an error occurs while loading the image,
5510
+ * its width and height will be set to -1. You'll know when the image has
5511
+ * loaded properly because its width and height will be greater than 0.
5512
+ * Asynchronous image loading (particularly when downloading from a server)
5513
+ * can dramatically improve performance.
5514
+ * <br/> <b>extension</b> parameter is used to determine the image type in
5515
+ * cases where the image filename does not end with a proper extension.
5516
+ * Specify the extension as the second parameter to <b>requestImage()</b>.
5482
5517
  *
5483
5518
  * ( end auto-generated )
5484
5519
  *
5485
- * @return
5486
5520
  * @webref image:loading_displaying
5487
5521
  * @param filename name of the file to load, can be .gif, .jpg, .tga, or a
5488
5522
  * handful of other image types depending on your platform
@@ -5500,7 +5534,11 @@ public class PApplet implements PConstants {
5500
5534
 
5501
5535
  // if the image loading thread pool hasn't been created, create it
5502
5536
  if (requestImagePool == null) {
5503
- ThreadFactory factory = (Runnable r) -> new Thread(r, REQUEST_IMAGE_THREAD_PREFIX);
5537
+ ThreadFactory factory = new ThreadFactory() {
5538
+ public Thread newThread(Runnable r) {
5539
+ return new Thread(r, REQUEST_IMAGE_THREAD_PREFIX);
5540
+ }
5541
+ };
5504
5542
  requestImagePool = Executors.newFixedThreadPool(4, factory);
5505
5543
  }
5506
5544
  requestImagePool.execute(() -> {
@@ -5525,6 +5563,256 @@ public class PApplet implements PConstants {
5525
5563
  return vessel;
5526
5564
  }
5527
5565
 
5566
+ /**
5567
+ * Use Java 1.4 ImageIO methods to load an image.
5568
+ */
5569
+ protected PImage loadImageIO(String filename) {
5570
+ InputStream stream = createInput(filename);
5571
+ if (stream == null) {
5572
+ System.err.println("The image " + filename + " could not be found.");
5573
+ return null;
5574
+ }
5575
+
5576
+ try {
5577
+ BufferedImage bi = ImageIO.read(stream);
5578
+ PImage outgoing = new PImage(bi.getWidth(), bi.getHeight());
5579
+ outgoing.parent = this;
5580
+
5581
+ bi.getRGB(0, 0, outgoing.width, outgoing.height,
5582
+ outgoing.pixels, 0, outgoing.width);
5583
+
5584
+ // check the alpha for this image
5585
+ // was gonna call getType() on the image to see if RGB or ARGB,
5586
+ // but it's not actually useful, since gif images will come through
5587
+ // as TYPE_BYTE_INDEXED, which means it'll still have to check for
5588
+ // the transparency. also, would have to iterate through all the other
5589
+ // types and guess whether alpha was in there, so.. just gonna stick
5590
+ // with the old method.
5591
+ outgoing.checkAlpha();
5592
+
5593
+ stream.close();
5594
+ // return the image
5595
+ return outgoing;
5596
+
5597
+ } catch (Exception e) {
5598
+ printStackTrace(e);
5599
+ return null;
5600
+ }
5601
+ }
5602
+
5603
+ /**
5604
+ * Targa image loader for RLE-compressed TGA files.
5605
+ * <p>
5606
+ * Rewritten for 0115 to read/write RLE-encoded targa images. For 0125,
5607
+ * non-RLE encoded images are now supported, along with images whose y-order
5608
+ * is reversed (which is standard for TGA files).
5609
+ * <p>
5610
+ * A version of this function is in MovieMaker.java. Any fixes here should be
5611
+ * applied over in MovieMaker as well.
5612
+ * <p>
5613
+ * Known issue with RLE encoding and odd behavior in some apps:
5614
+ * https://github.com/processing/processing/issues/2096 Please help!
5615
+ */
5616
+ protected PImage loadImageTGA(String filename) throws IOException {
5617
+ InputStream is = createInput(filename);
5618
+ if (is == null) {
5619
+ return null;
5620
+ }
5621
+
5622
+ byte header[] = new byte[18];
5623
+ int offset = 0;
5624
+ do {
5625
+ int count = is.read(header, offset, header.length - offset);
5626
+ if (count == -1) {
5627
+ return null;
5628
+ }
5629
+ offset += count;
5630
+ } while (offset < 18);
5631
+
5632
+ /*
5633
+ header[2] image type code
5634
+ 2 (0x02) - Uncompressed, RGB images.
5635
+ 3 (0x03) - Uncompressed, black and white images.
5636
+ 10 (0x0A) - Run-length encoded RGB images.
5637
+ 11 (0x0B) - Compressed, black and white images. (grayscale?)
5638
+
5639
+ header[16] is the bit depth (8, 24, 32)
5640
+
5641
+ header[17] image descriptor (packed bits)
5642
+ 0x20 is 32 = origin upper-left
5643
+ 0x28 is 32 + 8 = origin upper-left + 32 bits
5644
+
5645
+ 7 6 5 4 3 2 1 0
5646
+ 128 64 32 16 8 4 2 1
5647
+ */
5648
+ int format = 0;
5649
+
5650
+ if (((header[2] == 3) || (header[2] == 11))
5651
+ && // B&W, plus RLE or not
5652
+ (header[16] == 8)
5653
+ && // 8 bits
5654
+ ((header[17] == 0x8) || (header[17] == 0x28))) { // origin, 32 bit
5655
+ format = ALPHA;
5656
+
5657
+ } else if (((header[2] == 2) || (header[2] == 10))
5658
+ && // RGB, RLE or not
5659
+ (header[16] == 24)
5660
+ && // 24 bits
5661
+ ((header[17] == 0x20) || (header[17] == 0))) { // origin
5662
+ format = RGB;
5663
+
5664
+ } else if (((header[2] == 2) || (header[2] == 10))
5665
+ && (header[16] == 32)
5666
+ && ((header[17] == 0x8) || (header[17] == 0x28))) { // origin, 32
5667
+ format = ARGB;
5668
+ }
5669
+
5670
+ if (format == 0) {
5671
+ System.err.println("Unknown .tga file format for " + filename);
5672
+ //" (" + header[2] + " " +
5673
+ //(header[16] & 0xff) + " " +
5674
+ //hex(header[17], 2) + ")");
5675
+ return null;
5676
+ }
5677
+
5678
+ int w = ((header[13] & 0xff) << 8) + (header[12] & 0xff);
5679
+ int h = ((header[15] & 0xff) << 8) + (header[14] & 0xff);
5680
+ PImage outgoing = createImage(w, h, format);
5681
+
5682
+ // where "reversed" means upper-left corner (normal for most of
5683
+ // the modernized world, but "reversed" for the tga spec)
5684
+ //boolean reversed = (header[17] & 0x20) != 0;
5685
+ // https://github.com/processing/processing/issues/1682
5686
+ boolean reversed = (header[17] & 0x20) == 0;
5687
+
5688
+ if ((header[2] == 2) || (header[2] == 3)) { // not RLE encoded
5689
+ if (reversed) {
5690
+ int index = (h - 1) * w;
5691
+ switch (format) {
5692
+ case ALPHA:
5693
+ for (int y = h - 1; y >= 0; y--) {
5694
+ for (int x = 0; x < w; x++) {
5695
+ outgoing.pixels[index + x] = is.read();
5696
+ }
5697
+ index -= w;
5698
+ }
5699
+ break;
5700
+ case RGB:
5701
+ for (int y = h - 1; y >= 0; y--) {
5702
+ for (int x = 0; x < w; x++) {
5703
+ outgoing.pixels[index + x]
5704
+ = is.read() | (is.read() << 8) | (is.read() << 16)
5705
+ | 0xff000000;
5706
+ }
5707
+ index -= w;
5708
+ }
5709
+ break;
5710
+ case ARGB:
5711
+ for (int y = h - 1; y >= 0; y--) {
5712
+ for (int x = 0; x < w; x++) {
5713
+ outgoing.pixels[index + x]
5714
+ = is.read() | (is.read() << 8) | (is.read() << 16)
5715
+ | (is.read() << 24);
5716
+ }
5717
+ index -= w;
5718
+ }
5719
+ }
5720
+ } else { // not reversed
5721
+ int count = w * h;
5722
+ switch (format) {
5723
+ case ALPHA:
5724
+ for (int i = 0; i < count; i++) {
5725
+ outgoing.pixels[i] = is.read();
5726
+ }
5727
+ break;
5728
+ case RGB:
5729
+ for (int i = 0; i < count; i++) {
5730
+ outgoing.pixels[i]
5731
+ = is.read() | (is.read() << 8) | (is.read() << 16)
5732
+ | 0xff000000;
5733
+ }
5734
+ break;
5735
+ case ARGB:
5736
+ for (int i = 0; i < count; i++) {
5737
+ outgoing.pixels[i]
5738
+ = is.read() | (is.read() << 8) | (is.read() << 16)
5739
+ | (is.read() << 24);
5740
+ }
5741
+ break;
5742
+ }
5743
+ }
5744
+
5745
+ } else { // header[2] is 10 or 11
5746
+ int index = 0;
5747
+ int px[] = outgoing.pixels;
5748
+
5749
+ while (index < px.length) {
5750
+ int num = is.read();
5751
+ boolean isRLE = (num & 0x80) != 0;
5752
+ if (isRLE) {
5753
+ num -= 127; // (num & 0x7F) + 1
5754
+ int pixel = 0;
5755
+ switch (format) {
5756
+ case ALPHA:
5757
+ pixel = is.read();
5758
+ break;
5759
+ case RGB:
5760
+ pixel = 0xFF000000
5761
+ | is.read() | (is.read() << 8) | (is.read() << 16);
5762
+ //(is.read() << 16) | (is.read() << 8) | is.read();
5763
+ break;
5764
+ case ARGB:
5765
+ pixel = is.read()
5766
+ | (is.read() << 8) | (is.read() << 16) | (is.read() << 24);
5767
+ break;
5768
+ }
5769
+ for (int i = 0; i < num; i++) {
5770
+ px[index++] = pixel;
5771
+ if (index == px.length) {
5772
+ break;
5773
+ }
5774
+ }
5775
+ } else { // write up to 127 bytes as uncompressed
5776
+ num += 1;
5777
+ switch (format) {
5778
+ case ALPHA:
5779
+ for (int i = 0; i < num; i++) {
5780
+ px[index++] = is.read();
5781
+ }
5782
+ break;
5783
+ case RGB:
5784
+ for (int i = 0; i < num; i++) {
5785
+ px[index++] = 0xFF000000
5786
+ | is.read() | (is.read() << 8) | (is.read() << 16);
5787
+ //(is.read() << 16) | (is.read() << 8) | is.read();
5788
+ }
5789
+ break;
5790
+ case ARGB:
5791
+ for (int i = 0; i < num; i++) {
5792
+ px[index++] = is.read()
5793
+ | //(is.read() << 24) |
5794
+ (is.read() << 8) | (is.read() << 16) | (is.read() << 24);
5795
+ //(is.read() << 16) | (is.read() << 8) | is.read();
5796
+ }
5797
+ break;
5798
+ }
5799
+ }
5800
+ }
5801
+
5802
+ if (!reversed) {
5803
+ int[] temp = new int[w];
5804
+ for (int y = 0; y < h / 2; y++) {
5805
+ int z = (h - 1) - y;
5806
+ System.arraycopy(px, y * w, temp, 0, w);
5807
+ System.arraycopy(px, z * w, px, y * w, w);
5808
+ System.arraycopy(temp, 0, px, z * w, w);
5809
+ }
5810
+ }
5811
+ }
5812
+ is.close();
5813
+ return outgoing;
5814
+ }
5815
+
5528
5816
  //////////////////////////////////////////////////////////////
5529
5817
  // DATA I/O
5530
5818
  // /**
@@ -5546,7 +5834,6 @@ public class PApplet implements PConstants {
5546
5834
  // }
5547
5835
  // }
5548
5836
  /**
5549
- * @return
5550
5837
  * @webref input:files
5551
5838
  * @param filename name of a file in the data folder or a URL.
5552
5839
  * @see XML
@@ -5574,7 +5861,13 @@ public class PApplet implements PConstants {
5574
5861
 
5575
5862
  // can't use catch-all exception, since it might catch the
5576
5863
  // RuntimeException about the incorrect case sensitivity
5577
- } catch (IOException | ParserConfigurationException | SAXException e) {
5864
+ } catch (IOException e) {
5865
+ throw new RuntimeException(e);
5866
+
5867
+ } catch (ParserConfigurationException e) {
5868
+ throw new RuntimeException(e);
5869
+
5870
+ } catch (SAXException e) {
5578
5871
  throw new RuntimeException(e);
5579
5872
  }
5580
5873
  }
@@ -5596,13 +5889,12 @@ public class PApplet implements PConstants {
5596
5889
  try {
5597
5890
  return XML.parse(xmlString, options);
5598
5891
 
5599
- } catch (IOException | ParserConfigurationException | SAXException e) {
5892
+ } catch (Exception e) {
5600
5893
  throw new RuntimeException(e);
5601
5894
  }
5602
5895
  }
5603
5896
 
5604
5897
  /**
5605
- * @return
5606
5898
  * @webref output:files
5607
5899
  * @param xml the XML object to save to disk
5608
5900
  * @param filename name of the file to write to
@@ -5622,7 +5914,6 @@ public class PApplet implements PConstants {
5622
5914
  }
5623
5915
 
5624
5916
  /**
5625
- * @return
5626
5917
  * @webref input:files
5627
5918
  * @param input String to parse as a JSONObject
5628
5919
  * @see PApplet#loadJSONObject(String)
@@ -5633,7 +5924,6 @@ public class PApplet implements PConstants {
5633
5924
  }
5634
5925
 
5635
5926
  /**
5636
- * @return
5637
5927
  * @webref input:files
5638
5928
  * @param filename name of a file in the data folder or a URL
5639
5929
  * @see JSONObject
@@ -5649,6 +5939,7 @@ public class PApplet implements PConstants {
5649
5939
  try {
5650
5940
  reader.close();
5651
5941
  } catch (IOException e) { // not sure what would cause this
5942
+ e.printStackTrace();
5652
5943
  }
5653
5944
  return outgoing;
5654
5945
  }
@@ -5663,12 +5954,12 @@ public class PApplet implements PConstants {
5663
5954
  try {
5664
5955
  reader.close();
5665
5956
  } catch (IOException e) { // not sure what would cause this
5957
+ e.printStackTrace();
5666
5958
  }
5667
5959
  return outgoing;
5668
5960
  }
5669
5961
 
5670
5962
  /**
5671
- * @return
5672
5963
  * @webref output:files
5673
5964
  * @param json the JSONObject to save
5674
5965
  * @param filename the name of the file to save to
@@ -5683,18 +5974,14 @@ public class PApplet implements PConstants {
5683
5974
  }
5684
5975
 
5685
5976
  /**
5686
- * @param json
5687
- * @param filename
5688
5977
  * @param options "compact" and "indent=N", replace N with the number of
5689
5978
  * spaces
5690
- * @return
5691
5979
  */
5692
5980
  public boolean saveJSONObject(JSONObject json, String filename, String options) {
5693
5981
  return json.save(saveFile(filename), options);
5694
5982
  }
5695
5983
 
5696
5984
  /**
5697
- * @return
5698
5985
  * @webref input:files
5699
5986
  * @param input String to parse as a JSONArray
5700
5987
  * @see JSONObject
@@ -5706,7 +5993,6 @@ public class PApplet implements PConstants {
5706
5993
  }
5707
5994
 
5708
5995
  /**
5709
- * @return
5710
5996
  * @webref input:files
5711
5997
  * @param filename name of a file in the data folder or a URL
5712
5998
  * @see JSONArray
@@ -5721,6 +6007,7 @@ public class PApplet implements PConstants {
5721
6007
  try {
5722
6008
  reader.close();
5723
6009
  } catch (IOException e) { // not sure what would cause this
6010
+ e.printStackTrace();
5724
6011
  }
5725
6012
  return outgoing;
5726
6013
  }
@@ -5732,12 +6019,12 @@ public class PApplet implements PConstants {
5732
6019
  try {
5733
6020
  reader.close();
5734
6021
  } catch (IOException e) { // not sure what would cause this
6022
+ e.printStackTrace();
5735
6023
  }
5736
6024
  return outgoing;
5737
6025
  }
5738
6026
 
5739
6027
  /**
5740
- * @return
5741
6028
  * @webref output:files
5742
6029
  * @param json the JSONArray to save
5743
6030
  * @param filename the name of the file to save to
@@ -5752,11 +6039,8 @@ public class PApplet implements PConstants {
5752
6039
  }
5753
6040
 
5754
6041
  /**
5755
- * @param json
5756
- * @param filename
5757
6042
  * @param options "compact" and "indent=N", replace N with the number of
5758
6043
  * spaces
5759
- * @return
5760
6044
  */
5761
6045
  public boolean saveJSONArray(JSONArray json, String filename, String options) {
5762
6046
  return json.save(saveFile(filename), options);
@@ -5772,7 +6056,6 @@ public class PApplet implements PConstants {
5772
6056
  // return new Table();
5773
6057
  // }
5774
6058
  /**
5775
- * @return
5776
6059
  * @webref input:files
5777
6060
  * @param filename name of a file in the data folder or a URL.
5778
6061
  * @see Table
@@ -5786,26 +6069,24 @@ public class PApplet implements PConstants {
5786
6069
  }
5787
6070
 
5788
6071
  /**
5789
- * Options may contain "header", "tsv", "csv", or "bin" separated by commas.Another option is "dictionary=filename.tsv", which allows users to specify
5790
- a "dictionary" file that contains a mapping of the column titles and the
5791
- data types used in the table file.This can be far more efficient (in terms
5792
- of speed and memory usage) for loading and parsing tables.
6072
+ * Options may contain "header", "tsv", "csv", or "bin" separated by commas.
5793
6073
  *
5794
- * The dictionary
5795
- file can only be tab separated values (.tsv) and its extension will be
5796
- ignored. This option was added in Processing 2.0.2.
6074
+ * Another option is "dictionary=filename.tsv", which allows users to specify
6075
+ * a "dictionary" file that contains a mapping of the column titles and the
6076
+ * data types used in the table file. This can be far more efficient (in terms
6077
+ * of speed and memory usage) for loading and parsing tables. The dictionary
6078
+ * file can only be tab separated values (.tsv) and its extension will be
6079
+ * ignored. This option was added in Processing 2.0.2.
5797
6080
  *
5798
- * @param filename
5799
6081
  * @param options may contain "header", "tsv", "csv", or "bin" separated by
5800
6082
  * commas
5801
- * @return
5802
6083
  */
5803
6084
  public Table loadTable(String filename, String options) {
5804
6085
  try {
5805
6086
  String optionStr = Table.extensionOptions(true, filename, options);
5806
6087
  String[] optionList = trim(split(optionStr, ','));
5807
6088
 
5808
- Table dictionary;
6089
+ Table dictionary = null;
5809
6090
  for (String opt : optionList) {
5810
6091
  if (opt.startsWith("dictionary=")) {
5811
6092
  dictionary = loadTable(opt.substring(opt.indexOf('=') + 1), "tsv");
@@ -5826,23 +6107,18 @@ public class PApplet implements PConstants {
5826
6107
  }
5827
6108
 
5828
6109
  /**
5829
- * @webref
5830
- * @return output:files
6110
+ * @webref output:files
5831
6111
  * @param table the Table object to save to a file
5832
6112
  * @param filename the filename to which the Table should be saved
5833
6113
  * @see Table
5834
6114
  * @see PApplet#loadTable(String)
5835
6115
  */
5836
-
5837
6116
  public boolean saveTable(Table table, String filename) {
5838
6117
  return saveTable(table, filename, null);
5839
6118
  }
5840
6119
 
5841
6120
  /**
5842
- * @param table
5843
6121
  * @param options can be one of "tsv", "csv", "bin", or "html"
5844
- * @param filename
5845
- * @return
5846
6122
  */
5847
6123
  public boolean saveTable(Table table, String filename, String options) {
5848
6124
  // String ext = checkExtension(filename);
@@ -6114,60 +6390,58 @@ public class PApplet implements PConstants {
6114
6390
 
6115
6391
  // Will remove the 'sketch' parameter once we get an upstream JOGL fix
6116
6392
  // https://github.com/processing/processing/issues/3831
6117
- static protected void selectImpl(final String prompt,
6118
- final String callbackMethod,
6119
- final File defaultSelection,
6120
- final Object callbackObject,
6121
- final Frame parentFrame,
6122
- final int mode,
6123
- final PApplet sketch) {
6124
- EventQueue.invokeLater(new Runnable() {
6125
- public void run() {
6126
- File selectedFile = null;
6127
-
6128
- boolean hide = (sketch != null)
6129
- && (sketch.g instanceof PGraphicsOpenGL) && (platform == WINDOWS);
6130
- if (hide) {
6131
- sketch.surface.setVisible(false);
6132
- }
6393
+ static protected void selectImpl(final String prompt,
6394
+ final String callbackMethod,
6395
+ final File defaultSelection,
6396
+ final Object callbackObject,
6397
+ final Frame parentFrame,
6398
+ final int mode,
6399
+ final PApplet sketch) {
6400
+ EventQueue.invokeLater(() -> {
6401
+ File selectedFile = null;
6133
6402
 
6134
- if (useNativeSelect) {
6135
- FileDialog dialog = new FileDialog(parentFrame, prompt, mode);
6136
- if (defaultSelection != null) {
6137
- dialog.setDirectory(defaultSelection.getParent());
6138
- dialog.setFile(defaultSelection.getName());
6139
- }
6403
+ boolean hide = (sketch != null)
6404
+ && (sketch.g instanceof PGraphicsOpenGL) && (platform == WINDOWS);
6405
+ if (hide) {
6406
+ sketch.surface.setVisible(false);
6407
+ }
6140
6408
 
6141
- dialog.setVisible(true);
6142
- String directory = dialog.getDirectory();
6143
- String filename = dialog.getFile();
6144
- if (filename != null) {
6145
- selectedFile = new File(directory, filename);
6146
- }
6409
+ if (useNativeSelect) {
6410
+ FileDialog dialog = new FileDialog(parentFrame, prompt, mode);
6411
+ if (defaultSelection != null) {
6412
+ dialog.setDirectory(defaultSelection.getParent());
6413
+ dialog.setFile(defaultSelection.getName());
6414
+ }
6147
6415
 
6148
- } else {
6149
- JFileChooser chooser = new JFileChooser();
6150
- chooser.setDialogTitle(prompt);
6151
- if (defaultSelection != null) {
6152
- chooser.setSelectedFile(defaultSelection);
6153
- }
6416
+ dialog.setVisible(true);
6417
+ String directory = dialog.getDirectory();
6418
+ String filename = dialog.getFile();
6419
+ if (filename != null) {
6420
+ selectedFile = new File(directory, filename);
6421
+ }
6154
6422
 
6155
- int result = -1;
6156
- if (mode == FileDialog.SAVE) {
6157
- result = chooser.showSaveDialog(parentFrame);
6158
- } else if (mode == FileDialog.LOAD) {
6159
- result = chooser.showOpenDialog(parentFrame);
6160
- }
6161
- if (result == JFileChooser.APPROVE_OPTION) {
6162
- selectedFile = chooser.getSelectedFile();
6163
- }
6423
+ } else {
6424
+ JFileChooser chooser = new JFileChooser();
6425
+ chooser.setDialogTitle(prompt);
6426
+ if (defaultSelection != null) {
6427
+ chooser.setSelectedFile(defaultSelection);
6164
6428
  }
6165
6429
 
6166
- if (hide) {
6167
- sketch.surface.setVisible(true);
6430
+ int result = -1;
6431
+ if (mode == FileDialog.SAVE) {
6432
+ result = chooser.showSaveDialog(parentFrame);
6433
+ } else if (mode == FileDialog.LOAD) {
6434
+ result = chooser.showOpenDialog(parentFrame);
6168
6435
  }
6169
- selectCallback(selectedFile, callbackMethod, callbackObject);
6436
+ if (result == JFileChooser.APPROVE_OPTION) {
6437
+ selectedFile = chooser.getSelectedFile();
6438
+ }
6439
+ }
6440
+
6441
+ if (hide) {
6442
+ sketch.surface.setVisible(true);
6170
6443
  }
6444
+ selectCallback(selectedFile, callbackMethod, callbackObject);
6171
6445
  });
6172
6446
  }
6173
6447
 
@@ -6419,15 +6693,16 @@ public class PApplet implements PConstants {
6419
6693
  * ( begin auto-generated from createReader.xml )
6420
6694
  *
6421
6695
  * Creates a <b>BufferedReader</b> object that can be used to read files
6422
- * line-by-line as individual <b>String</b> objects.This is the complement to
6423
- the <b>createWriter()</b> function. Starting with Processing release 0134, all files loaded and saved by the
6424
- Processing API use UTF-8 encoding. In previous releases, the default
6425
- encoding for your platform was used, which causes problems when files are
6426
- moved to other platforms.
6427
-
6428
- ( end auto-generated )
6696
+ * line-by-line as individual <b>String</b> objects. This is the complement to
6697
+ * the <b>createWriter()</b> function.
6698
+ *
6699
+ * Starting with Processing release 0134, all files loaded and saved by the
6700
+ * Processing API use UTF-8 encoding. In previous releases, the default
6701
+ * encoding for your platform was used, which causes problems when files are
6702
+ * moved to other platforms.
6703
+ *
6704
+ * ( end auto-generated )
6429
6705
  *
6430
- * @return
6431
6706
  * @webref input:files
6432
6707
  * @param filename name of the file to be opened
6433
6708
  * @see BufferedReader
@@ -6481,6 +6756,7 @@ public class PApplet implements PConstants {
6481
6756
  reader.reset();
6482
6757
  }
6483
6758
  } catch (IOException e) {
6759
+ e.printStackTrace();
6484
6760
  }
6485
6761
  return reader;
6486
6762
  }
@@ -6489,16 +6765,19 @@ public class PApplet implements PConstants {
6489
6765
  * ( begin auto-generated from createWriter.xml )
6490
6766
  *
6491
6767
  * Creates a new file in the sketch folder, and a <b>PrintWriter</b> object to
6492
- * write to it.For the file to be made coFor the file to be made correctly, it should be flushed and
6493
- must be closed with its <b>flush()</b> and <b>close()</b> methods (see
6494
- above example).rStarting with Processing release 0134, all files loaded and saved by the
6495
- Processing API use UTF-8 encoding. In previous releases, the default
6496
- encoding for your platform was used, which causes problems when files are
6497
- moved to other platforms.
6498
-
6499
- ( end auto-generated )iles
6500
- * @param filename
6501
- * @return
6768
+ * write to it. For the file to be made correctly, it should be flushed and
6769
+ * must be closed with its <b>flush()</b> and <b>close()</b> methods (see
6770
+ * above example).
6771
+ *
6772
+ * Starting with Processing release 0134, all files loaded and saved by the
6773
+ * Processing API use UTF-8 encoding. In previous releases, the default
6774
+ * encoding for your platform was used, which causes problems when files are
6775
+ * moved to other platforms.
6776
+ *
6777
+ * ( end auto-generated )
6778
+ *
6779
+ * @webref output:files
6780
+ * @param filename name of the file to be created
6502
6781
  * @see PrintWriter
6503
6782
  * @see PApplet#createReader
6504
6783
  * @see BufferedReader
@@ -6523,7 +6802,7 @@ public class PApplet implements PConstants {
6523
6802
  }
6524
6803
  return createWriter(output);
6525
6804
 
6526
- } catch (IOException e) {
6805
+ } catch (Exception e) {
6527
6806
  throw new RuntimeException("Couldn't create a writer for "
6528
6807
  + file.getAbsolutePath(), e);
6529
6808
  }
@@ -6545,12 +6824,14 @@ public class PApplet implements PConstants {
6545
6824
  /**
6546
6825
  * ( begin auto-generated from createInput.xml )
6547
6826
  *
6548
- * This is a function for advanced programmers to open a Java InputStream.It's useful if you want to use the facilities provided by PApplet to easily
6549
- open files from the data folder or from a URL, but want an InputStream
6550
- object so that you can use other parts of Java to take more control of how
6551
- the stream is read.
6827
+ * This is a function for advanced programmers to open a Java InputStream.
6828
+ * It's useful if you want to use the facilities provided by PApplet to easily
6829
+ * open files from the data folder or from a URL, but want an InputStream
6830
+ * object so that you can use other parts of Java to take more control of how
6831
+ * the stream is read.
6832
+ *
6552
6833
  * The filename passed in can be: - A URL, for instance
6553
- <b>openStream("http://processing.org/")</b>
6834
+ * <b>openStream("http://processing.org/")</b>
6554
6835
  * - A file in the sketch's <b>data</b> folder - The full path to a file to be
6555
6836
  * opened locally (when running as an application)
6556
6837
  *
@@ -6602,7 +6883,6 @@ public class PApplet implements PConstants {
6602
6883
  * <LI>Another file to be opened locally (when running as an application)
6603
6884
  * </UL>
6604
6885
  *
6605
- * @return
6606
6886
  * @webref input:files
6607
6887
  * @param filename the name of the file to use as input
6608
6888
  * @see PApplet#createOutput(String)
@@ -6611,39 +6891,239 @@ public class PApplet implements PConstants {
6611
6891
  *
6612
6892
  */
6613
6893
  public InputStream createInput(String filename) {
6614
- return InputFactory.createInput(this, filename);
6894
+ InputStream input = createInputRaw(filename);
6895
+ if (input != null) {
6896
+ // if it's gzip-encoded, automatically decode
6897
+ final String lower = filename.toLowerCase();
6898
+ if (lower.endsWith(".gz") || lower.endsWith(".svgz")) {
6899
+ try {
6900
+ // buffered has to go *around* the GZ, otherwise 25x slower
6901
+ return new BufferedInputStream(new GZIPInputStream(input));
6902
+
6903
+ } catch (IOException e) {
6904
+ printStackTrace(e);
6905
+ }
6906
+ } else {
6907
+ return new BufferedInputStream(input);
6908
+ }
6909
+ }
6910
+ return null;
6615
6911
  }
6616
6912
 
6617
6913
  /**
6618
6914
  * Call openStream() without automatic gzip decompression.
6619
- * @param filename
6620
- * @return
6621
6915
  */
6622
6916
  public InputStream createInputRaw(String filename) {
6623
- return InputFactory.createInputRaw(this, filename);
6917
+ if (filename == null) {
6918
+ return null;
6919
+ }
6920
+
6921
+ if (sketchPath == null) {
6922
+ System.err.println("The sketch path is not set.");
6923
+ throw new RuntimeException("Files must be loaded inside setup() or after it has been called.");
6924
+ }
6925
+
6926
+ if (filename.length() == 0) {
6927
+ // an error will be called by the parent function
6928
+ //System.err.println("The filename passed to openStream() was empty.");
6929
+ return null;
6930
+ }
6931
+
6932
+ // First check whether this looks like a URL
6933
+ if (filename.contains(":")) { // at least smells like URL
6934
+ try {
6935
+ URL url = new URL(filename);
6936
+ URLConnection conn = url.openConnection();
6937
+
6938
+ if (conn instanceof HttpURLConnection) {
6939
+ HttpURLConnection httpConn = (HttpURLConnection) conn;
6940
+ // Will not handle a protocol change (see below)
6941
+ httpConn.setInstanceFollowRedirects(true);
6942
+ int response = httpConn.getResponseCode();
6943
+ // Default won't follow HTTP -> HTTPS redirects for security reasons
6944
+ // http://stackoverflow.com/a/1884427
6945
+ if (response >= 300 && response < 400) {
6946
+ String newLocation = httpConn.getHeaderField("Location");
6947
+ return createInputRaw(newLocation);
6948
+ }
6949
+ return conn.getInputStream();
6950
+ } else if (conn instanceof JarURLConnection) {
6951
+ return url.openStream();
6952
+ }
6953
+ } catch (MalformedURLException | FileNotFoundException mfue) {
6954
+ // not a url, that's fine
6955
+
6956
+ } // Added in 0119 b/c Java 1.5 throws FNFE when URL not available.
6957
+ // http://dev.processing.org/bugs/show_bug.cgi?id=403
6958
+ catch (IOException e) {
6959
+ // changed for 0117, shouldn't be throwing exception
6960
+ printStackTrace(e);
6961
+ //System.err.println("Error downloading from URL " + filename);
6962
+ return null;
6963
+ //throw new RuntimeException("Error downloading from URL " + filename);
6964
+ }
6965
+ }
6966
+
6967
+ InputStream stream = null;
6968
+
6969
+ // Moved this earlier than the getResourceAsStream() checks, because
6970
+ // calling getResourceAsStream() on a directory lists its contents.
6971
+ // http://dev.processing.org/bugs/show_bug.cgi?id=716
6972
+ try {
6973
+ // First see if it's in a data folder. This may fail by throwing
6974
+ // a SecurityException. If so, this whole block will be skipped.
6975
+ File file = new File(dataPath(filename));
6976
+ if (!file.exists()) {
6977
+ // next see if it's just in the sketch folder
6978
+ file = sketchFile(filename);
6979
+ }
6980
+
6981
+ if (file.isDirectory()) {
6982
+ return null;
6983
+ }
6984
+ if (file.exists()) {
6985
+ try {
6986
+ // handle case sensitivity check
6987
+ String filePath = file.getCanonicalPath();
6988
+ String filenameActual = new File(filePath).getName();
6989
+ // make sure there isn't a subfolder prepended to the name
6990
+ String filenameShort = new File(filename).getName();
6991
+ // if the actual filename is the same, but capitalized
6992
+ // differently, warn the user.
6993
+ //if (filenameActual.equalsIgnoreCase(filenameShort) &&
6994
+ //!filenameActual.equals(filenameShort)) {
6995
+ if (!filenameActual.equals(filenameShort)) {
6996
+ throw new RuntimeException("This file is named "
6997
+ + filenameActual + " not "
6998
+ + filename + ". Rename the file "
6999
+ + "or change your code.");
7000
+ }
7001
+ } catch (IOException e) {
7002
+ }
7003
+ }
7004
+
7005
+ // if this file is ok, may as well just load it
7006
+ stream = new FileInputStream(file);
7007
+ if (stream != null) {
7008
+ return stream;
7009
+ }
7010
+
7011
+ // have to break these out because a general Exception might
7012
+ // catch the RuntimeException being thrown above
7013
+ } catch (IOException ioe) {
7014
+ } catch (SecurityException se) {
7015
+ }
7016
+
7017
+ // Using getClassLoader() prevents java from converting dots
7018
+ // to slashes or requiring a slash at the beginning.
7019
+ // (a slash as a prefix means that it'll load from the root of
7020
+ // the jar, rather than trying to dig into the package location)
7021
+ ClassLoader cl = getClass().getClassLoader();
7022
+
7023
+ // by default, data files are exported to the root path of the jar.
7024
+ // (not the data folder) so check there first.
7025
+ stream = cl.getResourceAsStream("data/" + filename);
7026
+ if (stream != null) {
7027
+ String cn = stream.getClass().getName();
7028
+ // this is an irritation of sun's java plug-in, which will return
7029
+ // a non-null stream for an object that doesn't exist. like all good
7030
+ // things, this is probably introduced in java 1.5. awesome!
7031
+ // http://dev.processing.org/bugs/show_bug.cgi?id=359
7032
+ if (!cn.equals("sun.plugin.cache.EmptyInputStream")) {
7033
+ return stream;
7034
+ }
7035
+ }
7036
+
7037
+ // When used with an online script, also need to check without the
7038
+ // data folder, in case it's not in a subfolder called 'data'.
7039
+ // http://dev.processing.org/bugs/show_bug.cgi?id=389
7040
+ stream = cl.getResourceAsStream(filename);
7041
+ if (stream != null) {
7042
+ String cn = stream.getClass().getName();
7043
+ if (!cn.equals("sun.plugin.cache.EmptyInputStream")) {
7044
+ return stream;
7045
+ }
7046
+ }
7047
+
7048
+ try {
7049
+ // attempt to load from a local file, used when running as
7050
+ // an application, or as a signed applet
7051
+ try { // first try to catch any security exceptions
7052
+ try {
7053
+ stream = new FileInputStream(dataPath(filename));
7054
+ if (stream != null) {
7055
+ return stream;
7056
+ }
7057
+ } catch (IOException e2) {
7058
+ }
7059
+
7060
+ try {
7061
+ stream = new FileInputStream(sketchPath(filename));
7062
+ if (stream != null) {
7063
+ return stream;
7064
+ }
7065
+ } catch (Exception e) {
7066
+ } // ignored
7067
+
7068
+ try {
7069
+ stream = new FileInputStream(filename);
7070
+ if (stream != null) {
7071
+ return stream;
7072
+ }
7073
+ } catch (IOException e1) {
7074
+ }
7075
+
7076
+ } catch (SecurityException se) {
7077
+ } // online, whups
7078
+
7079
+ } catch (Exception e) {
7080
+ printStackTrace(e);
7081
+ }
7082
+
7083
+ return null;
6624
7084
  }
6625
7085
 
6626
7086
  /**
6627
7087
  * @nowebref
6628
7088
  */
6629
7089
  static public InputStream createInput(File file) {
6630
- return InputFactory.createInput(file);
7090
+ if (file == null) {
7091
+ throw new IllegalArgumentException("File passed to createInput() was null");
7092
+ }
7093
+ if (!file.exists()) {
7094
+ System.err.println(file + " does not exist, createInput() will return null");
7095
+ return null;
7096
+ }
7097
+ try {
7098
+ InputStream input = new FileInputStream(file);
7099
+ final String lower = file.getName().toLowerCase();
7100
+ if (lower.endsWith(".gz") || lower.endsWith(".svgz")) {
7101
+ return new BufferedInputStream(new GZIPInputStream(input));
7102
+ }
7103
+ return new BufferedInputStream(input);
7104
+
7105
+ } catch (IOException e) {
7106
+ System.err.println("Could not createInput() for " + file);
7107
+ e.printStackTrace();
7108
+ return null;
7109
+ }
6631
7110
  }
6632
7111
 
6633
7112
  /**
6634
7113
  * ( begin auto-generated from loadBytes.xml )
6635
7114
  *
6636
- * Reads the contents of a file or url and places it in a byte array.If a
6637
- file is specified, it must be located in the sketch's "data"
6638
- directory/folder. The filename parameter can also be a URL to a file found online. For
6639
- security reasons, a Processing sketch found online can only download files
6640
- from the same server from which it came. Getting around this restriction
6641
- requires a <a
7115
+ * Reads the contents of a file or url and places it in a byte array. If a
7116
+ * file is specified, it must be located in the sketch's "data"
7117
+ * directory/folder.
7118
+ *
7119
+ * The filename parameter can also be a URL to a file found online. For
7120
+ * security reasons, a Processing sketch found online can only download files
7121
+ * from the same server from which it came. Getting around this restriction
7122
+ * requires a <a
6642
7123
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</a>.
6643
7124
  *
6644
7125
  * ( end auto-generated )
6645
7126
  *
6646
- * @return
6647
7127
  * @webref input:files
6648
7128
  * @param filename name of a file in the data folder or a URL.
6649
7129
  * @see PApplet#loadStrings(String)
@@ -6685,7 +7165,7 @@ public class PApplet implements PConstants {
6685
7165
  }
6686
7166
 
6687
7167
  if (input != null) {
6688
- byte[] buffer;
7168
+ byte[] buffer = null;
6689
7169
  if (length != -1) {
6690
7170
  buffer = new byte[length];
6691
7171
  int count;
@@ -6702,10 +7182,9 @@ public class PApplet implements PConstants {
6702
7182
  } catch (MalformedURLException | FileNotFoundException mfue) {
6703
7183
  // not a url, that's fine
6704
7184
 
6705
- }
6706
- // Java 1.5+ throws FNFE when URL not available
7185
+ } // Java 1.5+ throws FNFE when URL not available
6707
7186
  // http://dev.processing.org/bugs/show_bug.cgi?id=403
6708
- catch (IOException e) {
7187
+ catch (IOException e) {
6709
7188
  printStackTrace(e);
6710
7189
  return null;
6711
7190
 
@@ -6827,6 +7306,7 @@ public class PApplet implements PConstants {
6827
7306
  try {
6828
7307
  is.close();
6829
7308
  } catch (IOException e) {
7309
+ e.printStackTrace();
6830
7310
  }
6831
7311
  return outgoing;
6832
7312
  }
@@ -6837,11 +7317,13 @@ public class PApplet implements PConstants {
6837
7317
  * ( begin auto-generated from loadStrings.xml )
6838
7318
  *
6839
7319
  * Reads the contents of a file or url and creates a String array of its
6840
- * individual lines.If a file is specified, it must be located in the
6841
- sketch's "data" directory/folder. The filename parameter can also be a URL to a file found online. For
6842
- security reasons, a Processing sketch found online can only download files
6843
- from the same server from which it came. Getting around this restriction
6844
- requires a <a
7320
+ * individual lines. If a file is specified, it must be located in the
7321
+ * sketch's "data" directory/folder.
7322
+ *
7323
+ * The filename parameter can also be a URL to a file found online. For
7324
+ * security reasons, a Processing sketch found online can only download files
7325
+ * from the same server from which it came. Getting around this restriction
7326
+ * requires a <a
6845
7327
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</a>.
6846
7328
  *
6847
7329
  * If the file is not available or an error occurs, <b>null</b> will be
@@ -6868,7 +7350,6 @@ public class PApplet implements PConstants {
6868
7350
  * things done in a "scripting" fashion. If you want to handle exceptions, use
6869
7351
  * Java methods for I/O.
6870
7352
  *
6871
- * @return
6872
7353
  * @webref input:files
6873
7354
  * @param filename name of the file or url to load
6874
7355
  * @see PApplet#loadBytes(String)
@@ -6903,6 +7384,7 @@ public class PApplet implements PConstants {
6903
7384
  = new BufferedReader(new InputStreamReader(input, "UTF-8"));
6904
7385
  return loadStrings(reader);
6905
7386
  } catch (IOException e) {
7387
+ e.printStackTrace();
6906
7388
  }
6907
7389
  return null;
6908
7390
  }
@@ -6911,7 +7393,7 @@ public class PApplet implements PConstants {
6911
7393
  try {
6912
7394
  String lines[] = new String[100];
6913
7395
  int lineCount = 0;
6914
- String line;
7396
+ String line = null;
6915
7397
  while ((line = reader.readLine()) != null) {
6916
7398
  if (lineCount == lines.length) {
6917
7399
  String temp[] = new String[lineCount << 1];
@@ -6932,6 +7414,7 @@ public class PApplet implements PConstants {
6932
7414
  return output;
6933
7415
 
6934
7416
  } catch (IOException e) {
7417
+ e.printStackTrace();
6935
7418
  //throw new RuntimeException("Error inside loadStrings()");
6936
7419
  }
6937
7420
  return null;
@@ -6943,9 +7426,11 @@ public class PApplet implements PConstants {
6943
7426
  * ( begin auto-generated from createOutput.xml )
6944
7427
  *
6945
7428
  * Similar to <b>createInput()</b>, this creates a Java <b>OutputStream</b>
6946
- * for a given filename or path.The file will be created in the sketch
6947
- folder, or in the same folder as an exported application. If the path does not exist, intermediate folders will be created. If an
6948
- exception occurs, it will be printed to the console, and <b>null</b>
7429
+ * for a given filename or path. The file will be created in the sketch
7430
+ * folder, or in the same folder as an exported application.
7431
+ *
7432
+ * If the path does not exist, intermediate folders will be created. If an
7433
+ * exception occurs, it will be printed to the console, and <b>null</b>
6949
7434
  * will be returned.
6950
7435
  *
6951
7436
  * This function is a convenience over the Java approach that requires you to
@@ -6958,7 +7443,6 @@ public class PApplet implements PConstants {
6958
7443
  *
6959
7444
  * ( end auto-generated )
6960
7445
  *
6961
- * @return
6962
7446
  * @webref output:files
6963
7447
  * @param filename name of the file to open
6964
7448
  * @see PApplet#createInput(String)
@@ -6981,6 +7465,7 @@ public class PApplet implements PConstants {
6981
7465
  return new BufferedOutputStream(output);
6982
7466
 
6983
7467
  } catch (IOException e) {
7468
+ e.printStackTrace();
6984
7469
  }
6985
7470
  return null;
6986
7471
  }
@@ -6988,16 +7473,17 @@ public class PApplet implements PConstants {
6988
7473
  /**
6989
7474
  * ( begin auto-generated from saveStream.xml )
6990
7475
  *
6991
- * Save the contents of a stream to a file in the sketch folder.This is
6992
- basically <b>saveBytes(blah, loadBytes())</b>, but done more efficiently
6993
- (and with less confusing syntax). When using the <b>targetFile</b> parameter, it writes to a <b>File</b>
7476
+ * Save the contents of a stream to a file in the sketch folder. This is
7477
+ * basically <b>saveBytes(blah, loadBytes())</b>, but done more efficiently
7478
+ * (and with less confusing syntax).
7479
+ *
7480
+ * When using the <b>targetFile</b> parameter, it writes to a <b>File</b>
6994
7481
  * object for greater control over the file location. (Note that unlike some
6995
7482
  * other functions, this will not automatically compress or uncompress gzip
6996
7483
  * files.)
6997
7484
  *
6998
7485
  * ( end auto-generated )
6999
7486
  *
7000
- * @return
7001
7487
  * @webref output:files
7002
7488
  * @param target name of the file to write to
7003
7489
  * @param source location to read from (a filename, path, or URL)
@@ -7009,12 +7495,10 @@ public class PApplet implements PConstants {
7009
7495
 
7010
7496
  /**
7011
7497
  * Identical to the other saveStream(), but writes to a File object, for
7012
- * greater control over the file location.Note that unlike other api methods, this will not automatically compress or
7013
- uncompress gzip files.
7498
+ * greater control over the file location.
7014
7499
  *
7015
- * @param target
7016
- * @param source
7017
- * @return
7500
+ * Note that unlike other api methods, this will not automatically compress or
7501
+ * uncompress gzip files.
7018
7502
  */
7019
7503
  public boolean saveStream(File target, String source) {
7020
7504
  return saveStream(target, createInputRaw(source));
@@ -7036,9 +7520,11 @@ public class PApplet implements PConstants {
7036
7520
  // make sure that this path actually exists before writing
7037
7521
  createPath(target);
7038
7522
  tempFile = createTempFile(target);
7039
- try (FileOutputStream targetStream = new FileOutputStream(tempFile)) {
7040
- saveStream(targetStream, source);
7041
- }
7523
+ FileOutputStream targetStream = new FileOutputStream(tempFile);
7524
+
7525
+ saveStream(targetStream, source);
7526
+ targetStream.close();
7527
+ targetStream = null;
7042
7528
 
7043
7529
  if (target.exists()) {
7044
7530
  if (!target.delete()) {
@@ -7057,6 +7543,7 @@ public class PApplet implements PConstants {
7057
7543
  if (tempFile != null) {
7058
7544
  tempFile.delete();
7059
7545
  }
7546
+ e.printStackTrace();
7060
7547
  return false;
7061
7548
  }
7062
7549
  }
@@ -7144,9 +7631,10 @@ public class PApplet implements PConstants {
7144
7631
  try {
7145
7632
  tempFile = createTempFile(file);
7146
7633
 
7147
- try (OutputStream output = createOutput(tempFile)) {
7148
- saveBytes(output, data);
7149
- }
7634
+ OutputStream output = createOutput(tempFile);
7635
+ saveBytes(output, data);
7636
+ output.close();
7637
+ output = null;
7150
7638
 
7151
7639
  if (file.exists()) {
7152
7640
  if (!file.delete()) {
@@ -7164,6 +7652,7 @@ public class PApplet implements PConstants {
7164
7652
  if (tempFile != null) {
7165
7653
  tempFile.delete();
7166
7654
  }
7655
+ e.printStackTrace();
7167
7656
  }
7168
7657
  }
7169
7658
 
@@ -7176,6 +7665,7 @@ public class PApplet implements PConstants {
7176
7665
  output.flush();
7177
7666
 
7178
7667
  } catch (IOException e) {
7668
+ e.printStackTrace();
7179
7669
  }
7180
7670
  }
7181
7671
 
@@ -7192,7 +7682,7 @@ public class PApplet implements PConstants {
7192
7682
  * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
7193
7683
  * save a file back to a server, see the <a
7194
7684
  * href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to
7195
- * web</A> code snippet on the Processing Wiki.
7685
+ * web</A> code snippet on the Processing Wiki.<br/>
7196
7686
  * <br/ >
7197
7687
  * Starting with Processing 1.0, all files loaded and saved by the Processing
7198
7688
  * API use UTF-8 encoding. In previous releases, the default encoding for your
@@ -7223,12 +7713,12 @@ public class PApplet implements PConstants {
7223
7713
  * @nowebref
7224
7714
  */
7225
7715
  static public void saveStrings(OutputStream output, String[] data) {
7226
- try (PrintWriter writer = createWriter(output)) {
7227
- for (String data1 : data) {
7228
- writer.println(data1);
7229
- }
7230
- writer.flush();
7716
+ PrintWriter writer = createWriter(output);
7717
+ for (int i = 0; i < data.length; i++) {
7718
+ writer.println(data[i]);
7231
7719
  }
7720
+ writer.flush();
7721
+ writer.close();
7232
7722
  }
7233
7723
 
7234
7724
  //////////////////////////////////////////////////////////////
@@ -7429,15 +7919,42 @@ public class PApplet implements PConstants {
7429
7919
  * exist.
7430
7920
  */
7431
7921
  static public void createPath(String path) {
7432
- PathUtil.createPath(path);
7922
+ createPath(new File(path));
7433
7923
  }
7434
7924
 
7435
7925
  static public void createPath(File file) {
7436
- PathUtil.createPath(file);
7926
+ try {
7927
+ String parent = file.getParent();
7928
+ if (parent != null) {
7929
+ File unit = new File(parent);
7930
+ if (!unit.exists()) {
7931
+ unit.mkdirs();
7932
+ }
7933
+ }
7934
+ } catch (SecurityException se) {
7935
+ System.err.println("You don't have permissions to create "
7936
+ + file.getAbsolutePath());
7937
+ }
7437
7938
  }
7438
7939
 
7439
7940
  static public String getExtension(String filename) {
7440
- return PathUtil.parseExtension(filename);
7941
+ String extension;
7942
+
7943
+ String lower = filename.toLowerCase();
7944
+ int dot = filename.lastIndexOf('.');
7945
+ if (dot == -1) {
7946
+ return ""; // no extension found
7947
+ }
7948
+ extension = lower.substring(dot + 1);
7949
+
7950
+ // check for, and strip any parameters on the url, i.e.
7951
+ // filename.jpg?blah=blah&something=that
7952
+ int question = extension.indexOf('?');
7953
+ if (question != -1) {
7954
+ extension = extension.substring(0, question);
7955
+ }
7956
+
7957
+ return extension;
7441
7958
  }
7442
7959
 
7443
7960
  //////////////////////////////////////////////////////////////
@@ -9110,9 +9627,9 @@ public class PApplet implements PConstants {
9110
9627
  * Utility function for formatting numbers into strings. There are two
9111
9628
  * versions, one for formatting floats and one for formatting ints. The values
9112
9629
  * for the <b>digits</b>, <b>left</b>, and <b>right</b> parameters should
9113
- * always be positive integers.As shown in the above example, <b>nf()</b> is
9114
- * used to add zeros to the left and/or right of a number. This is typically
9115
- * for aligning a list of numbers. To
9630
+ * always be positive integers..containsAs shown in the above example,
9631
+ * <b>nf()</b> is used to add zeros to the left and/or right of a number. This
9632
+ * is typically for aligning a list of numbers. To
9116
9633
  * <em>remove</em> digits from a floating-point number, use the
9117
9634
  * <b>int()</b>, <b>ceil()</b>, <b>floor()</b>, or <b>round()</b>
9118
9635
  * functions.
@@ -9797,7 +10314,7 @@ public class PApplet implements PConstants {
9797
10314
  * com.sketchycompany.Sketchy should be used as the class name.
9798
10315
  * <li>The [sketch args] are any command line parameters you want to send to
9799
10316
  * the sketch itself. These will be passed into the args[] array in PApplet.
9800
- * <p>
10317
+ * </ul>
9801
10318
  * The simplest way to turn and sketch into an application is to add the
9802
10319
  * following code to your program:
9803
10320
  * <PRE>static public void main(String args[]) {
@@ -9989,75 +10506,77 @@ public class PApplet implements PConstants {
9989
10506
  String folder = calcSketchPath();
9990
10507
 
9991
10508
  int argIndex = 0;
9992
- while (argIndex < args.length) {
9993
- int equals = args[argIndex].indexOf('=');
9994
- if (equals != -1) {
9995
- param = args[argIndex].substring(0, equals);
9996
- value = args[argIndex].substring(equals + 1);
9997
-
9998
- if (param.equals(ARGS_EDITOR_LOCATION)) {
9999
- external = true;
10000
- editorLocation = parseInt(split(value, ','));
10001
-
10002
- } else if (param.equals(ARGS_DISPLAY)) {
10003
- displayNum = parseInt(value, -2);
10004
- if (displayNum == -2) {
10005
- // this means the display value couldn't be parsed properly
10006
- System.err.println(value + " is not a valid choice for " + ARGS_DISPLAY);
10007
- displayNum = -1; // use the default
10008
- }
10009
-
10010
- } else if (param.equals(ARGS_WINDOW_COLOR)) {
10011
- if (value.charAt(0) == '#' && value.length() == 7) {
10012
- value = value.substring(1);
10013
- windowColor = 0xff000000 | Integer.parseInt(value, 16);
10014
- } else {
10015
- System.err.println(ARGS_WINDOW_COLOR + " should be a # followed by six digits");
10016
- }
10017
-
10018
- } else if (param.equals(ARGS_STOP_COLOR)) {
10019
- if (value.charAt(0) == '#' && value.length() == 7) {
10020
- value = value.substring(1);
10021
- stopColor = 0xff000000 | Integer.parseInt(value, 16);
10022
- } else {
10023
- System.err.println(ARGS_STOP_COLOR + " should be a # followed by six digits");
10024
- }
10025
-
10026
- } else if (param.equals(ARGS_SKETCH_FOLDER)) {
10027
- folder = value;
10028
-
10029
- } else if (param.equals(ARGS_LOCATION)) {
10030
- location = parseInt(split(value, ','));
10031
-
10032
- } else if (param.equals(ARGS_DENSITY)) {
10033
- density = parseInt(value, -1);
10034
- if (density == -1) {
10035
- System.err.println("Could not parse " + value + " for " + ARGS_DENSITY);
10036
- } else if (density != 1 && density != 2) {
10037
- density = -1;
10038
- System.err.println(ARGS_DENSITY + " should be 1 or 2");
10509
+ OUTER:
10510
+ while (argIndex < args.length) {
10511
+ int equals = args[argIndex].indexOf('=');
10512
+ if (equals != -1) {
10513
+ param = args[argIndex].substring(0, equals);
10514
+ value = args[argIndex].substring(equals + 1);
10515
+
10516
+ switch (param) {
10517
+ case ARGS_EDITOR_LOCATION:
10518
+ external = true;
10519
+ editorLocation = parseInt(split(value, ','));
10520
+ break;
10521
+ case ARGS_DISPLAY:
10522
+ displayNum = parseInt(value, -2);
10523
+ if (displayNum == -2) {
10524
+ // this means the display value couldn't be parsed properly
10525
+ System.err.println(value + " is not a valid choice for " + ARGS_DISPLAY);
10526
+ displayNum = -1; // use the default
10527
+ } break;
10528
+ case ARGS_WINDOW_COLOR:
10529
+ if (value.charAt(0) == '#' && value.length() == 7) {
10530
+ value = value.substring(1);
10531
+ windowColor = 0xff000000 | Integer.parseInt(value, 16);
10532
+ } else {
10533
+ System.err.println(ARGS_WINDOW_COLOR + " should be a # followed by six digits");
10534
+ } break;
10535
+ case ARGS_STOP_COLOR:
10536
+ if (value.charAt(0) == '#' && value.length() == 7) {
10537
+ value = value.substring(1);
10538
+ stopColor = 0xff000000 | Integer.parseInt(value, 16);
10539
+ } else {
10540
+ System.err.println(ARGS_STOP_COLOR + " should be a # followed by six digits");
10541
+ } break;
10542
+ case ARGS_SKETCH_FOLDER:
10543
+ folder = value;
10544
+ break;
10545
+ case ARGS_LOCATION:
10546
+ location = parseInt(split(value, ','));
10547
+ break;
10548
+ case ARGS_DENSITY:
10549
+ density = parseInt(value, -1);
10550
+ if (density == -1) {
10551
+ System.err.println("Could not parse " + value + " for " + ARGS_DENSITY);
10552
+ } else if (density != 1 && density != 2) {
10553
+ density = -1;
10554
+ System.err.println(ARGS_DENSITY + " should be 1 or 2");
10555
+ } break;
10556
+ default:
10557
+ break;
10039
10558
  }
10040
- }
10041
-
10042
- } else {
10043
- if (args[argIndex].equals(ARGS_PRESENT)) {
10044
- present = true;
10559
+ } else {
10560
+ switch (args[argIndex]) {
10561
+ case ARGS_PRESENT:
10562
+ present = true;
10045
10563
 
10046
10564
  // } else if (args[argIndex].equals(ARGS_SPAN_DISPLAYS)) {
10047
10565
  // spanDisplays = true;
10048
- } else if (args[argIndex].equals(ARGS_HIDE_STOP)) {
10049
- hideStop = true;
10050
-
10051
- } else if (args[argIndex].equals(ARGS_EXTERNAL)) {
10052
- external = true;
10053
-
10054
- } else {
10055
- name = args[argIndex];
10056
- break; // because of break, argIndex won't increment again
10566
+ break;
10567
+ case ARGS_HIDE_STOP:
10568
+ hideStop = true;
10569
+ break;
10570
+ case ARGS_EXTERNAL:
10571
+ external = true;
10572
+ break;
10573
+ default:
10574
+ name = args[argIndex];
10575
+ break OUTER; // because of break, argIndex won't increment again
10576
+ }
10057
10577
  }
10578
+ argIndex++;
10058
10579
  }
10059
- argIndex++;
10060
- }
10061
10580
 
10062
10581
  // // Now that sketch path is passed in args after the sketch name
10063
10582
  // // it's not set in the above loop(the above loop breaks after
@@ -10094,8 +10613,8 @@ public class PApplet implements PConstants {
10094
10613
  Method method
10095
10614
  = thinkDifferent.getMethod("init", new Class[]{PApplet.class});
10096
10615
  method.invoke(null, new Object[]{sketch});
10097
- } catch (Exception e) {
10098
- e.printStackTrace(); // That's unfortunate
10616
+ } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
10617
+ // That's unfortunate
10099
10618
  }
10100
10619
  }
10101
10620
 
@@ -10308,14 +10827,13 @@ public class PApplet implements PConstants {
10308
10827
  }
10309
10828
 
10310
10829
  /**
10311
- * Convenience method for Python Mode to run an already-constructed
10312
- * sketch.This makes it makes it easy to launch a sketch in Jython:
10830
+ * Convenience method for Python Mode to run an already-constructed sketch.
10831
+ * This makes it makes it easy to launch a sketch in Jython:
10832
+ *
10313
10833
  * <pre>class MySketch(PApplet):
10314
10834
  * pass
10315
10835
  *
10316
10836
  *MySketch().runSketch();</pre>
10317
- *
10318
- * @param args
10319
10837
  */
10320
10838
  protected void runSketch(final String[] args) {
10321
10839
  final String[] argsWithSketchName = new String[args.length + 1];
@@ -10327,13 +10845,6 @@ public class PApplet implements PConstants {
10327
10845
  runSketch(argsWithSketchName, this);
10328
10846
  }
10329
10847
 
10330
- /**
10331
- * Convenience method for Python Mode
10332
- */
10333
- protected void runSketch() {
10334
- runSketch(new String[0]);
10335
- }
10336
-
10337
10848
  /**
10338
10849
  * Convenience method for propane with jdk9
10339
10850
  */
@@ -10346,7 +10857,7 @@ public class PApplet implements PConstants {
10346
10857
  * ( begin auto-generated from beginRecord.xml )
10347
10858
  *
10348
10859
  * Opens a new file and all subsequent drawing functions are echoed to this
10349
- * file as well as the display window. The <b>beginRecord()</b> function
10860
+ * file as well as the display window.The <b>beginRecord()</b> function
10350
10861
  * requires two parameters, the first is the renderer and the second is the
10351
10862
  * file name. This function is always used with <b>endRecord()</b> to stop the
10352
10863
  * recording process and close the file.
@@ -10357,6 +10868,7 @@ public class PApplet implements PConstants {
10357
10868
  *
10358
10869
  * ( end auto-generated )
10359
10870
  *
10871
+ * @return
10360
10872
  * @webref output:files
10361
10873
  * @param renderer PDF or SVG
10362
10874
  * @param filename filename for output
@@ -11447,6 +11959,32 @@ public class PApplet implements PConstants {
11447
11959
  g.rect(a, b, c, d, tl, tr, br, bl);
11448
11960
  }
11449
11961
 
11962
+ /**
11963
+ * ( begin auto-generated from square.xml )
11964
+ *
11965
+ * Draws a square to the screen. A square is a four-sided shape with every
11966
+ * angle at ninety degrees and each side is the same length. By default, the
11967
+ * first two parameters set the location of the upper-left corner, the third
11968
+ * sets the width and height. The way these parameters are interpreted,
11969
+ * however, may be changed with the
11970
+ * <b>rectMode()</b> function.
11971
+ *
11972
+ * ( end auto-generated )
11973
+ *
11974
+ * @webref shape:2d_primitives
11975
+ * @param x x-coordinate of the rectangle by default
11976
+ * @param y y-coordinate of the rectangle by default
11977
+ * @param extent width and height of the rectangle by default
11978
+ * @see PGraphics#rect(float, float, float, float)
11979
+ * @see PGraphics#rectMode(int)
11980
+ */
11981
+ public void square(float x, float y, float extent) {
11982
+ if (recorder != null) {
11983
+ recorder.square(x, y, extent);
11984
+ }
11985
+ g.square(x, y, extent);
11986
+ }
11987
+
11450
11988
  /**
11451
11989
  * ( begin auto-generated from ellipseMode.xml )
11452
11990
  *
@@ -11543,6 +12081,30 @@ public class PApplet implements PConstants {
11543
12081
  g.arc(a, b, c, d, start, stop, mode);
11544
12082
  }
11545
12083
 
12084
+ /**
12085
+ * ( begin auto-generated from circle.xml )
12086
+ *
12087
+ * Draws a circle to the screen. By default, the first two parameters set the
12088
+ * location of the center, and the third sets the shape's width and height.
12089
+ * The origin may be changed with the <b>ellipseMode()</b>
12090
+ * function.
12091
+ *
12092
+ * ( end auto-generated )
12093
+ *
12094
+ * @webref shape:2d_primitives
12095
+ * @param x x-coordinate of the ellipse
12096
+ * @param y y-coordinate of the ellipse
12097
+ * @param extent width and height of the ellipse by default
12098
+ * @see PApplet#ellipse(float, float, float, float)
12099
+ * @see PApplet#ellipseMode(int)
12100
+ */
12101
+ public void circle(float x, float y, float extent) {
12102
+ if (recorder != null) {
12103
+ recorder.circle(x, y, extent);
12104
+ }
12105
+ g.circle(x, y, extent);
12106
+ }
12107
+
11546
12108
  /**
11547
12109
  * ( begin auto-generated from box.xml )
11548
12110
  *
@@ -12605,6 +13167,81 @@ public class PApplet implements PConstants {
12605
13167
  g.text(num, x, y, z);
12606
13168
  }
12607
13169
 
13170
+ /**
13171
+ * ( begin auto-generated from push.xml )
13172
+ *
13173
+ * The <b>push()</b> function saves the current drawing style settings and
13174
+ * transformations, while <b>pop()</b> restores these settings. Note that
13175
+ * these functions are always used together. They allow you to change the
13176
+ * style and transformation settings and later return to what you had. When a
13177
+ * new state is started with push(), it builds on the current style and
13178
+ * transform information.
13179
+ *
13180
+ * <b>push()</b> stores information related to the current transformation
13181
+ * state and style settings controlled by the following functions:
13182
+ * <b>rotate()</b>, <b>translate()</b>,
13183
+ * <b>scale()</b>, <b>fill()</b>, <b>stroke()</b>, <b>tint()</b>,
13184
+ * <b>strokeWeight()</b>, <b>strokeCap()</b>, <b>strokeJoin()</b>,
13185
+ * <b>imageMode()</b>, <b>rectMode()</b>, <b>ellipseMode()</b>,
13186
+ * <b>colorMode()</b>, <b>textAlign()</b>, <b>textFont()</b>,
13187
+ * <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.
13188
+ *
13189
+ * The <b>push()</b> and <b>pop()</b> functions were added with Processing
13190
+ * 3.5. They can be used in place of <b>pushMatrix()</b>,
13191
+ * <b>popMatrix()</b>, <b>pushStyles()</b>, and <b>popStyles()</b>. The
13192
+ * difference is that push() and pop() control both the transformations
13193
+ * (rotate, scale, translate) and the drawing styles at the same time.
13194
+ *
13195
+ * ( end auto-generated )
13196
+ *
13197
+ * @webref structure
13198
+ * @see PGraphics#pop()
13199
+ */
13200
+ public void push() {
13201
+ if (recorder != null) {
13202
+ recorder.push();
13203
+ }
13204
+ g.push();
13205
+ }
13206
+
13207
+ /**
13208
+ * ( begin auto-generated from pop.xml )
13209
+ *
13210
+ * The <b>pop()</b> function restores the previous drawing style settings and
13211
+ * transformations after <b>push()</b> has changed them. Note that these
13212
+ * functions are always used together. They allow you to change the style and
13213
+ * transformation settings and later return to what you had. When a new state
13214
+ * is started with push(), it builds on the current style and transform
13215
+ * information.
13216
+ *
13217
+ *
13218
+ * <b>push()</b> stores information related to the current transformation
13219
+ * state and style settings controlled by the following functions:
13220
+ * <b>rotate()</b>, <b>translate()</b>,
13221
+ * <b>scale()</b>, <b>fill()</b>, <b>stroke()</b>, <b>tint()</b>,
13222
+ * <b>strokeWeight()</b>, <b>strokeCap()</b>, <b>strokeJoin()</b>,
13223
+ * <b>imageMode()</b>, <b>rectMode()</b>, <b>ellipseMode()</b>,
13224
+ * <b>colorMode()</b>, <b>textAlign()</b>, <b>textFont()</b>,
13225
+ * <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.
13226
+ *
13227
+ * The <b>push()</b> and <b>pop()</b> functions were added with Processing
13228
+ * 3.5. They can be used in place of <b>pushMatrix()</b>,
13229
+ * <b>popMatrix()</b>, <b>pushStyles()</b>, and <b>popStyles()</b>. The
13230
+ * difference is that push() and pop() control both the transformations
13231
+ * (rotate, scale, translate) and the drawing styles at the same time.
13232
+ *
13233
+ * ( end auto-generated )
13234
+ *
13235
+ * @webref structure
13236
+ * @see PGraphics#push()
13237
+ */
13238
+ public void pop() {
13239
+ if (recorder != null) {
13240
+ recorder.pop();
13241
+ }
13242
+ g.pop();
13243
+ }
13244
+
12608
13245
  /**
12609
13246
  * ( begin auto-generated from pushMatrix.xml )
12610
13247
  *
@@ -13171,8 +13808,8 @@ public class PApplet implements PConstants {
13171
13808
  * The <b>beginCamera()</b> and <b>endCamera()</b> functions enable advanced
13172
13809
  * customization of the camera space. The functions are useful if you want to
13173
13810
  * more control over camera movement, however for most users, the
13174
- * <b>camera()</b> function will be sufficient.The camera functions will
13175
- * replace any transformations (such as <b>rotate()</b> or
13811
+ * <b>camera()</b> function will be sufficient..containsThe camera functions
13812
+ * will replace any transformations (such as <b>rotate()</b> or
13176
13813
  * <b>translate()</b>) that occur before them in <b>draw()</b>, but they will
13177
13814
  * not automatically replace the camera transform itself. For this reason,
13178
13815
  * camera functions should be placed at the beginning of
@@ -14431,10 +15068,10 @@ public class PApplet implements PConstants {
14431
15068
  *
14432
15069
  * Sets the falloff rates for point lights, spot lights, and ambient lights.
14433
15070
  * The parameters are used to determine the falloff with the following
14434
- * equation:d = distance from light position to vertex positionfalloff = 1 /
14435
- * (CONSTANT + d * LINEAR + (d*d) * QUADRATIC)Like <b>fill()</b>, it affects
14436
- * only the elements which are created after it in the code. The default value
14437
- * if
15071
+ * equation:.containsd = distance from light position to vertex
15072
+ * positionfalloff = 1 / (CONSTANT + d * LINEAR + (d*d) *
15073
+ * QUADRATIC).containsLike <b>fill()</b>, it affects only the elements which
15074
+ * are created after it in the code. The default value if
14438
15075
  * <b>LightFalloff(1.0, 0.0, 0.0)</b>. Thinking about an ambient light with a
14439
15076
  * falloff can be tricky. It is used, for example, if you wanted a region of
14440
15077
  * your scene to be lit ambiently one color and another region to be lit
@@ -14601,13 +15238,13 @@ public class PApplet implements PConstants {
14601
15238
  /**
14602
15239
  * Takes an RGB or ARGB image and sets it as the background. The width and
14603
15240
  * height of the image must be the same size as the sketch. Use
14604
- * image.resize(width, height) to make short work of such a task.
14605
- *
15241
+ * image.resize(width, height) to make short work of such a task.<br/>
15242
+ * <br/>
14606
15243
  * Note that even if the image is set as RGB, the high 8 bits of each pixel
14607
15244
  * should be set opaque (0xFF000000) because the image data will be copied
14608
15245
  * directly to the screen, and non-opaque background images may have strange
14609
- * behavior. Use image.filter(OPAQUE) to handle this easily.
14610
- *
15246
+ * behavior. Use image.filter(OPAQUE) to handle this easily.<br/>
15247
+ * <br/>
14611
15248
  * When using 3D, this will also clear the zbuffer (if it exists).
14612
15249
  *
14613
15250
  * @param image PImage to set as background (must be same size as the sketch
@@ -14710,8 +15347,8 @@ public class PApplet implements PConstants {
14710
15347
  *
14711
15348
  * Extracts the red value from a color, scaled to match current
14712
15349
  * <b>colorMode()</b>. This value is always returned as a float so be careful
14713
- * not to assign it to an int value.The red() function is easy to use and
14714
- * undestand, but is slower than another technique. To achieve the same
15350
+ * not to assign it to an int value..containsThe red() function is easy to use
15351
+ * and undestand, but is slower than another technique. To achieve the same
14715
15352
  * results when working in <b>colorMode(RGB, 255)</b>, but with greater speed,
14716
15353
  * use the &gt;&gt; (right shift) operator with a bit mask. For example, the
14717
15354
  * following two lines of code are equivalent:<br
@@ -14740,7 +15377,7 @@ public class PApplet implements PConstants {
14740
15377
  *
14741
15378
  * Extracts the green value from a color, scaled to match current
14742
15379
  * <b>colorMode()</b>. This value is always returned as a float so be careful
14743
- * not to assign it to an int value.The <b>green()</b>
15380
+ * not to assign it to an int value..containsThe <b>green()</b>
14744
15381
  * function is easy to use and undestand, but is slower than another
14745
15382
  * technique. To achieve the same results when working in <b>colorMode(RGB,
14746
15383
  * 255)</b>, but with greater speed, use the &gt;&gt; (right shift) operator
@@ -14770,7 +15407,7 @@ public class PApplet implements PConstants {
14770
15407
  *
14771
15408
  * Extracts the blue value from a color, scaled to match current
14772
15409
  * <b>colorMode()</b>. This value is always returned as a float so be careful
14773
- * not to assign it to an int value.The <b>blue()</b>
15410
+ * not to assign it to an int value..containsThe <b>blue()</b>
14774
15411
  * function is easy to use and undestand, but is slower than another
14775
15412
  * technique. To achieve the same results when working in <b>colorMode(RGB,
14776
15413
  * 255)</b>, but with greater speed, use a bit mask to remove the other color