propane 3.3.1-java → 3.6.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -2
- data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
- data/.mvn/wrapper/maven-wrapper.properties +2 -3
- data/.travis.yml +9 -0
- data/CHANGELOG.md +17 -5
- data/Gemfile +2 -0
- data/README.md +17 -8
- data/Rakefile +16 -30
- data/bin/propane +3 -1
- data/lib/propane.rb +6 -4
- data/lib/propane/app.rb +20 -10
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +23 -24
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +21 -15
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +14 -6
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +28 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +6 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +7 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +4 -1
- data/mvnw +127 -51
- data/mvnw.cmd +182 -145
- data/pom.rb +53 -50
- data/pom.xml +17 -8
- data/propane.gemspec +13 -11
- data/src/main/java/monkstone/ColorUtil.java +13 -1
- data/src/main/java/monkstone/MathToolModule.java +253 -203
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +7 -6
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +2164 -1661
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +280 -268
- data/src/main/java/processing/awt/PSurfaceAWT.java +942 -829
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +831 -824
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +229 -213
- data/src/main/java/processing/core/PImage.java +620 -318
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -409
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2888 -2652
- data/src/main/java/processing/core/PShapeOBJ.java +436 -415
- data/src/main/java/processing/core/PShapeSVG.java +1702 -1479
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -208
- data/src/main/java/processing/core/PVector.java +997 -965
- data/src/main/java/processing/core/ThinkDifferent.java +12 -17
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/dxf/RawDXF.java +404 -0
- data/src/main/java/processing/event/Event.java +87 -66
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +744 -0
- data/src/main/java/processing/net/Server.java +388 -0
- data/src/main/java/processing/opengl/FontTexture.java +289 -270
- data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
- data/src/main/java/processing/opengl/LinePath.java +547 -500
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +3047 -2914
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +1266 -1257
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +33 -62
- metadata +54 -45
- data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
- data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
- data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
- data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
- data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
- data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
- data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
- data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
- data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
- data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
- data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
- data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
- data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
- data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
- data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
- data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
- data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
- data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
- data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
- data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -3,7 +3,7 @@
|
|
3
3
|
/*
|
4
4
|
Part of the Processing project - http://processing.org
|
5
5
|
|
6
|
-
Copyright (c) 2012-
|
6
|
+
Copyright (c) 2012-20 The Processing Foundation
|
7
7
|
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
8
8
|
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
9
9
|
|
@@ -24,40 +24,6 @@
|
|
24
24
|
|
25
25
|
package processing.core;
|
26
26
|
|
27
|
-
// dummy object for backwards compatibility, plus the select methods
|
28
|
-
import java.awt.Frame;
|
29
|
-
|
30
|
-
// before calling settings() to get displayWidth/Height
|
31
|
-
import java.awt.DisplayMode;
|
32
|
-
// handleSettings() and displayDensity()
|
33
|
-
import java.awt.GraphicsDevice;
|
34
|
-
import java.awt.GraphicsEnvironment;
|
35
|
-
// used to present the fullScreen() warning about Spaces on OS X
|
36
|
-
import javax.swing.JOptionPane;
|
37
|
-
|
38
|
-
// inside runSketch() to warn users about headless
|
39
|
-
import java.awt.HeadlessException;
|
40
|
-
import java.awt.Toolkit;
|
41
|
-
|
42
|
-
// used by selectInput(), selectOutput(), selectFolder()
|
43
|
-
import java.awt.EventQueue;
|
44
|
-
import java.awt.FileDialog;
|
45
|
-
import javax.swing.JFileChooser;
|
46
|
-
|
47
|
-
// set the look and feel, if specified
|
48
|
-
import javax.swing.UIManager;
|
49
|
-
|
50
|
-
// used by link()
|
51
|
-
import java.awt.Desktop;
|
52
|
-
|
53
|
-
// used by desktopFile() method
|
54
|
-
import javax.swing.filechooser.FileSystemView;
|
55
|
-
|
56
|
-
// loadXML() error handling
|
57
|
-
import javax.xml.parsers.ParserConfigurationException;
|
58
|
-
|
59
|
-
import org.xml.sax.SAXException;
|
60
|
-
|
61
27
|
import java.io.*;
|
62
28
|
import java.lang.reflect.*;
|
63
29
|
import java.net.*;
|
@@ -72,9 +38,13 @@ import java.util.concurrent.ThreadFactory;
|
|
72
38
|
import java.util.regex.*;
|
73
39
|
import java.util.zip.*;
|
74
40
|
|
75
|
-
|
76
|
-
import
|
77
|
-
import
|
41
|
+
// loadXML() error handling
|
42
|
+
import javax.xml.parsers.ParserConfigurationException;
|
43
|
+
import org.xml.sax.SAXException;
|
44
|
+
|
45
|
+
// TODO have this removed by 4.0 final
|
46
|
+
import processing.awt.ShimAWT;
|
47
|
+
|
78
48
|
import processing.data.*;
|
79
49
|
import processing.event.*;
|
80
50
|
import processing.opengl.*;
|
@@ -117,45 +87,44 @@ import processing.opengl.*;
|
|
117
87
|
*/
|
118
88
|
public class PApplet implements PConstants {
|
119
89
|
/** Full name of the Java version (i.e. 1.5.0_11). */
|
120
|
-
static public final String
|
90
|
+
static public final String JAVA_VERSION_NAME =
|
121
91
|
System.getProperty("java.version");
|
122
92
|
|
123
|
-
static public final int
|
93
|
+
static public final int JAVA_PLATFORM;
|
124
94
|
static {
|
125
|
-
String version =
|
126
|
-
if (
|
95
|
+
String version = JAVA_VERSION_NAME;
|
96
|
+
if (JAVA_VERSION_NAME.startsWith("1.")) {
|
127
97
|
version = version.substring(2);
|
128
|
-
|
98
|
+
JAVA_PLATFORM = parseInt(version.substring(0, version.indexOf('.')));
|
129
99
|
} else {
|
130
100
|
// Remove -xxx and .yyy from java.version (@see JEP-223)
|
131
|
-
|
101
|
+
JAVA_PLATFORM = parseInt(version.replaceAll("-.*","").replaceAll("\\..*",""));
|
132
102
|
}
|
133
103
|
}
|
134
104
|
|
135
105
|
/**
|
136
|
-
* Do not use;
|
137
|
-
* For instance,
|
138
|
-
* comparison, i.e. "if (
|
106
|
+
* Do not use; JAVA_PLATFORM or JAVA_VERSION_NAME are better options.
|
107
|
+
* For instance, JAVA_PLATFORM is useful when you need a number for
|
108
|
+
* comparison, i.e. "if (JAVA_PLATFORM >= 9)".
|
139
109
|
*/
|
140
110
|
@Deprecated
|
141
|
-
public static final float
|
111
|
+
public static final float JAVA_VERSION = 1 + JAVA_PLATFORM / 10f;
|
142
112
|
|
143
113
|
/**
|
144
|
-
* Current platform in use, one of the
|
145
|
-
* PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.
|
114
|
+
* Current platform in use, one of the PConstants WINDOWS, MACOS, LINUX or OTHER.
|
146
115
|
*/
|
147
116
|
static public int platform;
|
148
117
|
|
149
118
|
static {
|
150
|
-
String
|
119
|
+
final String name = System.getProperty("os.name");
|
151
120
|
|
152
|
-
if (
|
153
|
-
platform =
|
121
|
+
if (name.contains("Mac")) {
|
122
|
+
platform = MACOS;
|
154
123
|
|
155
|
-
} else if (
|
124
|
+
} else if (name.contains("Windows")) {
|
156
125
|
platform = WINDOWS;
|
157
126
|
|
158
|
-
} else if (
|
127
|
+
} else if (name.equals("Linux")) { // true for the ibm vm
|
159
128
|
platform = LINUX;
|
160
129
|
|
161
130
|
} else {
|
@@ -232,24 +201,6 @@ public class PApplet implements PConstants {
|
|
232
201
|
static public final int DEFAULT_WIDTH = 100;
|
233
202
|
static public final int DEFAULT_HEIGHT = 100;
|
234
203
|
|
235
|
-
// /**
|
236
|
-
// * Exception thrown when size() is called the first time.
|
237
|
-
// * <p>
|
238
|
-
// * This is used internally so that setup() is forced to run twice
|
239
|
-
// * when the renderer is changed. This is the only way for us to handle
|
240
|
-
// * invoking the new renderer while also in the midst of rendering.
|
241
|
-
// */
|
242
|
-
// static public class RendererChangeException extends RuntimeException { }
|
243
|
-
|
244
|
-
/**
|
245
|
-
* true if no size() command has been executed. This is used to wait until
|
246
|
-
* a size has been set before placing in the window and showing it.
|
247
|
-
*/
|
248
|
-
// public boolean defaultSize;
|
249
|
-
|
250
|
-
// /** Storage for the current renderer size to avoid re-allocation. */
|
251
|
-
// Dimension currentSize = new Dimension();
|
252
|
-
|
253
204
|
/**
|
254
205
|
* ( begin auto-generated from pixels.xml )
|
255
206
|
*
|
@@ -276,6 +227,9 @@ public class PApplet implements PConstants {
|
|
276
227
|
* @see PApplet#get(int, int, int, int)
|
277
228
|
* @see PApplet#set(int, int, int)
|
278
229
|
* @see PImage
|
230
|
+
* @see PApplet#pixelDensity(int)
|
231
|
+
* @see PApplet#pixelWidth
|
232
|
+
* @see PApplet#pixelHeight
|
279
233
|
*/
|
280
234
|
public int[] pixels;
|
281
235
|
|
@@ -573,7 +527,7 @@ public class PApplet implements PConstants {
|
|
573
527
|
*
|
574
528
|
* The system variable <b>key</b> always contains the value of the most
|
575
529
|
* recent key on the keyboard that was used (either pressed or released).
|
576
|
-
*
|
530
|
+
*
|
577
531
|
* For non-ASCII keys, use the <b>keyCode</b> variable. The keys included
|
578
532
|
* in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and
|
579
533
|
* DELETE) do not require checking to see if they key is coded, and you
|
@@ -608,7 +562,7 @@ public class PApplet implements PConstants {
|
|
608
562
|
* for these keys, it's first necessary to check and see if the key is
|
609
563
|
* coded. This is done with the conditional "if (key == CODED)" as shown in
|
610
564
|
* the example.
|
611
|
-
*
|
565
|
+
*
|
612
566
|
* The keys included in the ASCII specification (BACKSPACE, TAB, ENTER,
|
613
567
|
* RETURN, ESC, and DELETE) do not require checking to see if they key is
|
614
568
|
* coded, and you should simply use the <b>key</b> variable instead of
|
@@ -616,7 +570,7 @@ public class PApplet implements PConstants {
|
|
616
570
|
* ENTER key is commonly used on PCs and Unix and the RETURN key is used
|
617
571
|
* instead on Macintosh. Check for both ENTER and RETURN to make sure your
|
618
572
|
* program will work for all platforms.
|
619
|
-
*
|
573
|
+
*
|
620
574
|
* For users familiar with Java, the values for UP and DOWN are simply
|
621
575
|
* shorter versions of Java's KeyEvent.VK_UP and KeyEvent.VK_DOWN. Other
|
622
576
|
* keyCode values can be found in the Java <a
|
@@ -746,6 +700,9 @@ public class PApplet implements PConstants {
|
|
746
700
|
*/
|
747
701
|
protected boolean exitCalled;
|
748
702
|
|
703
|
+
// ok to be static because it's not possible to mix enabled/disabled
|
704
|
+
static protected boolean disableAWT;
|
705
|
+
|
749
706
|
// messages to send if attached as an external vm
|
750
707
|
|
751
708
|
/**
|
@@ -768,6 +725,9 @@ public class PApplet implements PConstants {
|
|
768
725
|
/** Used by the PDE to suggest a display (set in prefs, passed on Run) */
|
769
726
|
static public final String ARGS_DISPLAY = "--display";
|
770
727
|
|
728
|
+
/** Disable AWT so that LWJGL and others can run */
|
729
|
+
static public final String ARGS_DISABLE_AWT = "--disable-awt";
|
730
|
+
|
771
731
|
// static public final String ARGS_SPAN_DISPLAYS = "--span";
|
772
732
|
|
773
733
|
static public final String ARGS_BGCOLOR = "--bgcolor";
|
@@ -825,75 +785,11 @@ public class PApplet implements PConstants {
|
|
825
785
|
}
|
826
786
|
|
827
787
|
|
828
|
-
/**
|
829
|
-
* A dummy frame to keep compatibility with 2.x code
|
830
|
-
* and encourage users to update.
|
831
|
-
*/
|
832
|
-
public Frame frame;
|
833
|
-
|
834
|
-
|
835
|
-
// public Frame getFrame() {
|
836
|
-
// return frame;
|
837
|
-
// }
|
838
|
-
//
|
839
|
-
//
|
840
|
-
// public void setFrame(Frame frame) {
|
841
|
-
// this.frame = frame;
|
842
|
-
// }
|
843
|
-
|
844
|
-
|
845
|
-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
846
|
-
|
847
|
-
|
848
788
|
// /**
|
849
|
-
// *
|
850
|
-
// *
|
789
|
+
// * A dummy frame to keep compatibility with 2.x code
|
790
|
+
// * and encourage users to update.
|
851
791
|
// */
|
852
|
-
// public
|
853
|
-
//// println("init() called " + Integer.toHexString(hashCode()));
|
854
|
-
// // using a local version here since the class variable is deprecated
|
855
|
-
//// Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
856
|
-
//// screenWidth = screen.width;
|
857
|
-
//// screenHeight = screen.height;
|
858
|
-
//
|
859
|
-
// defaultSize = true;
|
860
|
-
// finished = false; // just for clarity
|
861
|
-
//
|
862
|
-
// // this will be cleared by draw() if it is not overridden
|
863
|
-
// looping = true;
|
864
|
-
// redraw = true; // draw this guy at least once
|
865
|
-
// firstMouse = true;
|
866
|
-
//
|
867
|
-
// // calculated dynamically on first call
|
868
|
-
//// // Removed in 2.1.2, brought back for 2.1.3. Usually sketchPath is set
|
869
|
-
//// // inside runSketch(), but if this sketch takes care of calls to init()
|
870
|
-
//// // when PApplet.main() is not used (i.e. it's in a Java application).
|
871
|
-
//// // THe path needs to be set here so that loadXxxx() functions work.
|
872
|
-
//// if (sketchPath == null) {
|
873
|
-
//// sketchPath = calcSketchPath();
|
874
|
-
//// }
|
875
|
-
//
|
876
|
-
// // set during Surface.initFrame()
|
877
|
-
//// // Figure out the available display width and height.
|
878
|
-
//// // No major problem if this fails, we have to try again anyway in
|
879
|
-
//// // handleDraw() on the first (== 0) frame.
|
880
|
-
//// checkDisplaySize();
|
881
|
-
//
|
882
|
-
//// // Set the default size, until the user specifies otherwise
|
883
|
-
//// int w = sketchWidth();
|
884
|
-
//// int h = sketchHeight();
|
885
|
-
//// defaultSize = (w == DEFAULT_WIDTH) && (h == DEFAULT_HEIGHT);
|
886
|
-
////
|
887
|
-
//// g = makeGraphics(w, h, sketchRenderer(), null, true);
|
888
|
-
//// // Fire component resize event
|
889
|
-
//// setSize(w, h);
|
890
|
-
//// setPreferredSize(new Dimension(w, h));
|
891
|
-
////
|
892
|
-
//// width = g.width;
|
893
|
-
//// height = g.height;
|
894
|
-
//
|
895
|
-
// surface.startThread();
|
896
|
-
// }
|
792
|
+
// public Frame frame;
|
897
793
|
|
898
794
|
|
899
795
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
@@ -902,12 +798,11 @@ public class PApplet implements PConstants {
|
|
902
798
|
boolean insideSettings;
|
903
799
|
|
904
800
|
String renderer = JAVA2D;
|
905
|
-
// int quality = 2;
|
906
801
|
int smooth = 1; // default smoothing (whatever that means for the renderer)
|
907
802
|
|
908
803
|
boolean fullScreen;
|
909
804
|
int display = -1; // use default
|
910
|
-
GraphicsDevice[] displayDevices;
|
805
|
+
// GraphicsDevice[] displayDevices;
|
911
806
|
// Unlike the others above, needs to be public to support
|
912
807
|
// the pixelWidth and pixelHeight fields.
|
913
808
|
public int pixelDensity = 1;
|
@@ -949,31 +844,19 @@ public class PApplet implements PConstants {
|
|
949
844
|
void handleSettings() {
|
950
845
|
insideSettings = true;
|
951
846
|
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
959
|
-
GraphicsDevice device = ge.getDefaultScreenDevice();
|
960
|
-
displayDevices = ge.getScreenDevices();
|
961
|
-
|
962
|
-
// Default or unparsed will be -1, spanning will be 0, actual displays will
|
963
|
-
// be numbered from 1 because it's too weird to say "display 0" in prefs.
|
964
|
-
if (display > 0 && display <= displayDevices.length) {
|
965
|
-
device = displayDevices[display-1];
|
847
|
+
if (!disableAWT) {
|
848
|
+
displayWidth = ShimAWT.getDisplayWidth();
|
849
|
+
displayHeight = ShimAWT.getDisplayHeight();
|
850
|
+
} else {
|
851
|
+
// https://github.com/processing/processing4/issues/57
|
852
|
+
System.err.println("AWT disabled, displayWidth/displayHeight will be 0");
|
966
853
|
}
|
967
|
-
// Set displayWidth and displayHeight for people still using those.
|
968
|
-
DisplayMode displayMode = device.getDisplayMode();
|
969
|
-
displayWidth = displayMode.getWidth();
|
970
|
-
displayHeight = displayMode.getHeight();
|
971
854
|
|
972
855
|
// Here's where size(), fullScreen(), smooth(N) and noSmooth() might
|
973
856
|
// be called, conjuring up the demons of various rendering configurations.
|
974
857
|
settings();
|
975
858
|
|
976
|
-
if (display == SPAN && platform ==
|
859
|
+
if (display == SPAN && platform == MACOS) {
|
977
860
|
// Make sure "Displays have separate Spaces" is unchecked
|
978
861
|
// in System Preferences > Mission Control
|
979
862
|
Process p = exec("defaults", "read", "com.apple.spaces", "spans-displays");
|
@@ -981,7 +864,7 @@ public class PApplet implements PConstants {
|
|
981
864
|
BufferedReader errReader = createReader(p.getErrorStream());
|
982
865
|
StringBuilder stdout = new StringBuilder();
|
983
866
|
StringBuilder stderr = new StringBuilder();
|
984
|
-
String line
|
867
|
+
String line;
|
985
868
|
try {
|
986
869
|
while ((line = outReader.readLine()) != null) {
|
987
870
|
stdout.append(line);
|
@@ -996,24 +879,21 @@ public class PApplet implements PConstants {
|
|
996
879
|
int resultCode = -1;
|
997
880
|
try {
|
998
881
|
resultCode = p.waitFor();
|
999
|
-
} catch (InterruptedException
|
1000
|
-
|
1001
|
-
|
1002
|
-
if ("0".equals(result)) {
|
1003
|
-
EventQueue.invokeLater(new Runnable() {
|
1004
|
-
public void run() {
|
1005
|
-
checkLookAndFeel();
|
1006
|
-
final String msg =
|
1007
|
-
"To use fullScreen(SPAN), first turn off “Displays have separate spaces”\n" +
|
1008
|
-
"in System Preferences \u2192 Mission Control. Then log out and log back in.";
|
1009
|
-
JOptionPane.showMessageDialog(null, msg, "Apple's Defaults Stink",
|
1010
|
-
JOptionPane.WARNING_MESSAGE);
|
1011
|
-
}
|
1012
|
-
});
|
1013
|
-
} else if (!"1".equals(result)) {
|
882
|
+
} catch (InterruptedException ignored) { }
|
883
|
+
|
884
|
+
if (resultCode == 1) {
|
1014
885
|
System.err.println("Could not check the status of “Displays have separate spaces.”");
|
1015
886
|
System.err.format("Received message '%s' and result code %d.%n", trim(stderr.toString()), resultCode);
|
1016
887
|
}
|
888
|
+
|
889
|
+
String processOutput = trim(stdout.toString());
|
890
|
+
// It looks like on Catalina, the option may not be set, so resultCode
|
891
|
+
// will be 1 (an error, since the param doesn't exist. But "Displays
|
892
|
+
// have separate spaces" is on by default, so show the message.
|
893
|
+
if (resultCode == 1 || "0".equals(processOutput)) {
|
894
|
+
System.err.println("To use fullScreen(SPAN), first turn off “Displays have separate spaces”");
|
895
|
+
System.err.println("in System Preferences \u2192 Mission Control. Then log out and log back in.");
|
896
|
+
}
|
1017
897
|
}
|
1018
898
|
|
1019
899
|
insideSettings = false;
|
@@ -1056,17 +936,6 @@ public class PApplet implements PConstants {
|
|
1056
936
|
}
|
1057
937
|
|
1058
938
|
|
1059
|
-
// Named quality instead of smooth to avoid people trying to set (or get)
|
1060
|
-
// the current smooth level this way. Also that smooth(number) isn't really
|
1061
|
-
// public or well-known API. It's specific to the capabilities of the
|
1062
|
-
// rendering surface, and somewhat independent of whether the sketch is
|
1063
|
-
// smoothing at any given time. It's also a bit like getFill() would return
|
1064
|
-
// true/false for whether fill was enabled, getFillColor() would return the
|
1065
|
-
// color itself. Or at least that's what I can recall at the moment. [fry]
|
1066
|
-
// public int sketchQuality() {
|
1067
|
-
// //return 2;
|
1068
|
-
// return quality;
|
1069
|
-
// }
|
1070
939
|
// smoothing 1 is default.. 0 is none.. 2,4,8 depend on renderer
|
1071
940
|
final public int sketchSmooth() {
|
1072
941
|
return smooth;
|
@@ -1074,20 +943,10 @@ public class PApplet implements PConstants {
|
|
1074
943
|
|
1075
944
|
|
1076
945
|
final public boolean sketchFullScreen() {
|
1077
|
-
//return false;
|
1078
946
|
return fullScreen;
|
1079
947
|
}
|
1080
948
|
|
1081
949
|
|
1082
|
-
// // Could be named 'screen' instead of display since it's the people using
|
1083
|
-
// // full screen who will be looking for it. On the other hand, screenX/Y/Z
|
1084
|
-
// // makes things confusing, and if 'displayIndex' exists...
|
1085
|
-
// public boolean sketchSpanDisplays() {
|
1086
|
-
// //return false;
|
1087
|
-
// return spanDisplays;
|
1088
|
-
// }
|
1089
|
-
|
1090
|
-
|
1091
950
|
// Numbered from 1, SPAN (0) means all displays, -1 means the default display
|
1092
951
|
final public int sketchDisplay() {
|
1093
952
|
return display;
|
@@ -1095,13 +954,11 @@ public class PApplet implements PConstants {
|
|
1095
954
|
|
1096
955
|
|
1097
956
|
final public String sketchOutputPath() {
|
1098
|
-
//return null;
|
1099
957
|
return outputPath;
|
1100
958
|
}
|
1101
959
|
|
1102
960
|
|
1103
961
|
final public OutputStream sketchOutputStream() {
|
1104
|
-
//return null;
|
1105
962
|
return outputStream;
|
1106
963
|
}
|
1107
964
|
|
@@ -1136,8 +993,16 @@ public class PApplet implements PConstants {
|
|
1136
993
|
if (display != SPAN && (fullScreen || present)) {
|
1137
994
|
return displayDensity(display);
|
1138
995
|
}
|
996
|
+
|
997
|
+
int displayCount = 0;
|
998
|
+
if (!disableAWT) {
|
999
|
+
displayCount = ShimAWT.getDisplayCount();
|
1000
|
+
} else {
|
1001
|
+
// https://github.com/processing/processing4/issues/57
|
1002
|
+
System.err.println("display count needs to be implemented for non-AWT");
|
1003
|
+
}
|
1139
1004
|
// walk through all displays, use 2 if any display is 2
|
1140
|
-
for (int i = 0; i <
|
1005
|
+
for (int i = 0; i < displayCount; i++) {
|
1141
1006
|
if (displayDensity(i+1) == 2) {
|
1142
1007
|
return 2;
|
1143
1008
|
}
|
@@ -1146,70 +1011,37 @@ public class PApplet implements PConstants {
|
|
1146
1011
|
return 1;
|
1147
1012
|
}
|
1148
1013
|
|
1014
|
+
|
1149
1015
|
/**
|
1150
1016
|
* @param display the display number to check
|
1017
|
+
* (1-indexed to match the Preferences dialog box)
|
1151
1018
|
*/
|
1152
1019
|
public int displayDensity(int display) {
|
1153
|
-
if (
|
1154
|
-
|
1155
|
-
// A 5-minute search didn't turn up any such event in the Java 7 API.
|
1156
|
-
// Also, should we use the Toolkit associated with the editor window?
|
1157
|
-
final String javaVendor = System.getProperty("java.vendor");
|
1158
|
-
if (javaVendor.contains("Oracle")) {
|
1159
|
-
GraphicsDevice device;
|
1160
|
-
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
1161
|
-
|
1162
|
-
if (display == -1) {
|
1163
|
-
device = env.getDefaultScreenDevice();
|
1164
|
-
|
1165
|
-
} else if (display == SPAN) {
|
1166
|
-
throw new RuntimeException("displayDensity() only works with specific display numbers");
|
1167
|
-
|
1168
|
-
} else {
|
1169
|
-
GraphicsDevice[] devices = env.getScreenDevices();
|
1170
|
-
if (display > 0 && display <= devices.length) {
|
1171
|
-
device = devices[display - 1];
|
1172
|
-
} else {
|
1173
|
-
if (devices.length == 1) {
|
1174
|
-
System.err.println("Only one display is currently known, use displayDensity(1).");
|
1175
|
-
} else {
|
1176
|
-
System.err.format("Your displays are numbered %d through %d, " +
|
1177
|
-
"pass one of those numbers to displayDensity()%n", 1, devices.length);
|
1178
|
-
}
|
1179
|
-
throw new RuntimeException("Display " + display + " does not exist.");
|
1180
|
-
}
|
1181
|
-
}
|
1182
|
-
|
1183
|
-
try {
|
1184
|
-
Field field = device.getClass().getDeclaredField("scale");
|
1185
|
-
if (field != null) {
|
1186
|
-
field.setAccessible(true);
|
1187
|
-
Object scale = field.get(device);
|
1188
|
-
|
1189
|
-
if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
|
1190
|
-
return 2;
|
1191
|
-
}
|
1192
|
-
}
|
1193
|
-
} catch (Exception ignore) { }
|
1194
|
-
}
|
1195
|
-
} else if (PApplet.platform == PConstants.WINDOWS ||
|
1196
|
-
PApplet.platform == PConstants.LINUX) {
|
1197
|
-
if (suggestedDensity == -1) {
|
1198
|
-
// TODO: detect and return DPI scaling using JNA; Windows has
|
1199
|
-
// a system-wide value, not sure how it works on Linux
|
1200
|
-
return 1;
|
1201
|
-
} else if (suggestedDensity == 1 || suggestedDensity == 2) {
|
1202
|
-
return suggestedDensity;
|
1203
|
-
}
|
1020
|
+
if (!disableAWT) {
|
1021
|
+
return ShimAWT.getDisplayDensity(display);
|
1204
1022
|
}
|
1205
|
-
|
1023
|
+
/*
|
1024
|
+
if (display > 0 && display <= displayDevices.length) {
|
1025
|
+
GraphicsConfiguration graphicsConfig =
|
1026
|
+
displayDevices[display - 1].getDefaultConfiguration();
|
1027
|
+
AffineTransform tx = graphicsConfig.getDefaultTransform();
|
1028
|
+
return (int) Math.round(tx.getScaleX());
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
System.err.println("Display " + display + " does not exist, " +
|
1032
|
+
"returning 1 for displayDensity(" + display + ")");
|
1033
|
+
*/
|
1034
|
+
// https://github.com/processing/processing4/issues/57
|
1035
|
+
System.err.println("displayDensity() unavailable because AWT is disabled");
|
1036
|
+
return 1; // not the end of the world, so don't throw a RuntimeException
|
1206
1037
|
}
|
1207
1038
|
|
1208
1039
|
|
1209
1040
|
/**
|
1210
1041
|
* @webref environment
|
1211
1042
|
* @param density 1 or 2
|
1212
|
-
*
|
1043
|
+
* @see PApplet#pixelWidth
|
1044
|
+
* @see PApplet#pixelHeight
|
1213
1045
|
*/
|
1214
1046
|
public void pixelDensity(int density) {
|
1215
1047
|
//println(density + " " + this.pixelDensity);
|
@@ -1420,6 +1252,7 @@ public class PApplet implements PConstants {
|
|
1420
1252
|
Object[] emptyArgs = new Object[] { };
|
1421
1253
|
|
1422
1254
|
|
1255
|
+
@SuppressWarnings("unused")
|
1423
1256
|
void handle() {
|
1424
1257
|
handle(emptyArgs);
|
1425
1258
|
}
|
@@ -1429,7 +1262,7 @@ public class PApplet implements PConstants {
|
|
1429
1262
|
for (int i = 0; i < count; i++) {
|
1430
1263
|
try {
|
1431
1264
|
methods[i].invoke(objects[i], args);
|
1432
|
-
} catch (
|
1265
|
+
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
1433
1266
|
// check for wrapped exception, get root exception
|
1434
1267
|
Throwable t;
|
1435
1268
|
if (e instanceof InvocationTargetException) {
|
@@ -1566,13 +1399,13 @@ public class PApplet implements PConstants {
|
|
1566
1399
|
die("There is no public " + name + "() method in the class " +
|
1567
1400
|
o.getClass().getName());
|
1568
1401
|
|
1569
|
-
} catch (
|
1402
|
+
} catch (SecurityException e) {
|
1570
1403
|
die("Could not register " + name + " + () for " + o, e);
|
1571
1404
|
}
|
1572
1405
|
}
|
1573
1406
|
|
1574
1407
|
|
1575
|
-
private void registerWithArgs(String name, Object o, Class<?> cargs
|
1408
|
+
private void registerWithArgs(String name, Object o, Class<?>[] cargs) {
|
1576
1409
|
Class<?> c = o.getClass();
|
1577
1410
|
try {
|
1578
1411
|
Method method = c.getMethod(name, cargs);
|
@@ -1588,7 +1421,7 @@ public class PApplet implements PConstants {
|
|
1588
1421
|
die("There is no public " + name + "() method in the class " +
|
1589
1422
|
o.getClass().getName());
|
1590
1423
|
|
1591
|
-
} catch (
|
1424
|
+
} catch (SecurityException e) {
|
1592
1425
|
die("Could not register " + name + " + () for " + o, e);
|
1593
1426
|
}
|
1594
1427
|
}
|
@@ -1606,8 +1439,6 @@ public class PApplet implements PConstants {
|
|
1606
1439
|
die("No registered methods with the name " + name + "() were found.");
|
1607
1440
|
}
|
1608
1441
|
try {
|
1609
|
-
// Method method = o.getClass().getMethod(name, new Class[] {});
|
1610
|
-
// meth.remove(o, method);
|
1611
1442
|
meth.remove(target);
|
1612
1443
|
} catch (Exception e) {
|
1613
1444
|
die("Could not unregister " + name + "() for " + target, e);
|
@@ -1615,18 +1446,7 @@ public class PApplet implements PConstants {
|
|
1615
1446
|
}
|
1616
1447
|
}
|
1617
1448
|
|
1618
|
-
|
1619
|
-
protected void handleMethods(String methodName) {
|
1620
|
-
synchronized (registerLock) {
|
1621
|
-
RegisteredMethods meth = registerMap.get(methodName);
|
1622
|
-
if (meth != null) {
|
1623
|
-
meth.handle();
|
1624
|
-
}
|
1625
|
-
}
|
1626
|
-
}
|
1627
|
-
|
1628
|
-
|
1629
|
-
protected void handleMethods(String methodName, Object[] args) {
|
1449
|
+
protected void handleMethods(String methodName, Object...args) {
|
1630
1450
|
synchronized (registerLock) {
|
1631
1451
|
RegisteredMethods meth = registerMap.get(methodName);
|
1632
1452
|
if (meth != null) {
|
@@ -1945,8 +1765,8 @@ public class PApplet implements PConstants {
|
|
1945
1765
|
* are needed.
|
1946
1766
|
*
|
1947
1767
|
* The <b>size()</b> function can only be used once inside a sketch, and
|
1948
|
-
* cannot be used for resizing
|
1949
|
-
*
|
1768
|
+
* cannot be used for resizing.
|
1769
|
+
* <b>renderer</b> parameter selects which rendering engine to use.
|
1950
1770
|
* For example, if you will be drawing 3D shapes, use <b>P3D</b>, if you
|
1951
1771
|
* want to export images from a program as a PDF file use <b>PDF</b>. A
|
1952
1772
|
* brief description of the three primary renderers follows:
|
@@ -1967,7 +1787,7 @@ public class PApplet implements PConstants {
|
|
1967
1787
|
* <b>strokeJoin()</b>, which can lead to ugly results when using
|
1968
1788
|
* <b>strokeWeight()</b>. (<a
|
1969
1789
|
* href="http://code.google.com/p/processing/issues/detail?id=123">Issue
|
1970
|
-
* 123</a>)
|
1790
|
+
* 123</a>)
|
1971
1791
|
*
|
1972
1792
|
* The maximum width and height is limited by your operating system, and is
|
1973
1793
|
* usually the width and height of your actual screen. On some machines it
|
@@ -1999,6 +1819,9 @@ public class PApplet implements PConstants {
|
|
1999
1819
|
* @param height height of the display window in units of pixels
|
2000
1820
|
* @see PApplet#width
|
2001
1821
|
* @see PApplet#height
|
1822
|
+
* @see PApplet#setup()
|
1823
|
+
* @see PApplet#settings()
|
1824
|
+
* @see PApplet#fullScreen()
|
2002
1825
|
*/
|
2003
1826
|
public void size(int width, int height) {
|
2004
1827
|
// Check to make sure the width/height have actually changed. It's ok to
|
@@ -2132,8 +1955,8 @@ public class PApplet implements PConstants {
|
|
2132
1955
|
*
|
2133
1956
|
* It's important to call any drawing functions between <b>beginDraw()</b>
|
2134
1957
|
* and <b>endDraw()</b> statements. This is also true for any functions
|
2135
|
-
* that affect drawing, such as <b>smooth()</b> or <b>colorMode()</b
|
2136
|
-
*
|
1958
|
+
* that affect drawing, such as <b>smooth()</b> or <b>colorMode()</b>.
|
1959
|
+
* the main drawing surface which is completely opaque, surfaces
|
2137
1960
|
* created with <b>createGraphics()</b> can have transparency. This makes
|
2138
1961
|
* it possible to draw into a graphics and maintain the alpha channel. By
|
2139
1962
|
* using <b>save()</b> to write a PNG or TGA file, the transparency of the
|
@@ -2254,7 +2077,7 @@ public class PApplet implements PConstants {
|
|
2254
2077
|
Class<?> rendererClass =
|
2255
2078
|
Thread.currentThread().getContextClassLoader().loadClass(renderer);
|
2256
2079
|
|
2257
|
-
Constructor<?> constructor = rendererClass.getConstructor(
|
2080
|
+
Constructor<?> constructor = rendererClass.getConstructor();
|
2258
2081
|
PGraphics pg = (PGraphics) constructor.newInstance();
|
2259
2082
|
|
2260
2083
|
pg.setParent(this);
|
@@ -2346,10 +2169,10 @@ public class PApplet implements PConstants {
|
|
2346
2169
|
* fresh buffer of pixels to play with. Set the size of the buffer with the
|
2347
2170
|
* <b>width</b> and <b>height</b> parameters. The <b>format</b> parameter
|
2348
2171
|
* defines how the pixels are stored. See the PImage reference for more information.
|
2349
|
-
*
|
2172
|
+
*
|
2350
2173
|
* Be sure to include all three parameters, specifying only the width and
|
2351
2174
|
* height (but no format) will produce a strange error.
|
2352
|
-
*
|
2175
|
+
*
|
2353
2176
|
* Advanced users please note that createImage() should be used instead of
|
2354
2177
|
* the syntax <tt>new PImage()</tt>.
|
2355
2178
|
*
|
@@ -2525,11 +2348,11 @@ public class PApplet implements PConstants {
|
|
2525
2348
|
* the program to update the display window only when necessary, for
|
2526
2349
|
* example when an event registered by <b>mousePressed()</b> or
|
2527
2350
|
* <b>keyPressed()</b> occurs.
|
2528
|
-
*
|
2351
|
+
* structuring a program, it only makes sense to call redraw()
|
2529
2352
|
* within events such as <b>mousePressed()</b>. This is because
|
2530
2353
|
* <b>redraw()</b> does not run <b>draw()</b> immediately (it only sets a
|
2531
2354
|
* flag that indicates an update is needed).
|
2532
|
-
*
|
2355
|
+
* <b>redraw()</b> within <b>draw()</b> has no effect because
|
2533
2356
|
* <b>draw()</b> is continuously called anyway.
|
2534
2357
|
*
|
2535
2358
|
* ( end auto-generated )
|
@@ -2583,7 +2406,7 @@ public class PApplet implements PConstants {
|
|
2583
2406
|
* <b>draw()</b>. If <b>loop()</b> is called, the code in <b>draw()</b>
|
2584
2407
|
* begin to run continuously again. If using <b>noLoop()</b> in
|
2585
2408
|
* <b>setup()</b>, it should be the last line inside the block.
|
2586
|
-
*
|
2409
|
+
*
|
2587
2410
|
* When <b>noLoop()</b> is used, it's not possible to manipulate or access
|
2588
2411
|
* the screen inside event handling functions such as <b>mousePressed()</b>
|
2589
2412
|
* or <b>keyPressed()</b>. Instead, use those functions to call
|
@@ -2591,7 +2414,7 @@ public class PApplet implements PConstants {
|
|
2591
2414
|
* can update the screen properly. This means that when noLoop() has been
|
2592
2415
|
* called, no drawing can happen, and functions like saveFrame() or
|
2593
2416
|
* loadPixels() may not be used.
|
2594
|
-
*
|
2417
|
+
*
|
2595
2418
|
* Note that if the sketch is resized, <b>redraw()</b> will be called to
|
2596
2419
|
* update the sketch, even after <b>noLoop()</b> has been specified.
|
2597
2420
|
* Otherwise, the sketch would enter an odd state until <b>loop()</b> was called.
|
@@ -2684,7 +2507,7 @@ public class PApplet implements PConstants {
|
|
2684
2507
|
int button = event.getButton();
|
2685
2508
|
|
2686
2509
|
// If running on Mac OS, allow ctrl-click as right mouse.
|
2687
|
-
if (PApplet.platform == PConstants.
|
2510
|
+
if (PApplet.platform == PConstants.MACOS && event.getButton() == PConstants.LEFT) {
|
2688
2511
|
if (action == MouseEvent.PRESS && event.isControlDown()) {
|
2689
2512
|
macosxLeftButtonWithCtrlPressed = true;
|
2690
2513
|
}
|
@@ -2738,7 +2561,7 @@ public class PApplet implements PConstants {
|
|
2738
2561
|
break;
|
2739
2562
|
}
|
2740
2563
|
|
2741
|
-
handleMethods("mouseEvent",
|
2564
|
+
handleMethods("mouseEvent", event);
|
2742
2565
|
|
2743
2566
|
switch (action) {
|
2744
2567
|
case MouseEvent.PRESS:
|
@@ -3010,7 +2833,7 @@ public class PApplet implements PConstants {
|
|
3010
2833
|
}
|
3011
2834
|
*/
|
3012
2835
|
|
3013
|
-
handleMethods("keyEvent",
|
2836
|
+
handleMethods("keyEvent", event);
|
3014
2837
|
|
3015
2838
|
// if someone else wants to intercept the key, they should
|
3016
2839
|
// set key to zero (or something besides the ESC).
|
@@ -3025,8 +2848,8 @@ public class PApplet implements PConstants {
|
|
3025
2848
|
// embedded inside an application that has its own close behavior.
|
3026
2849
|
if (external &&
|
3027
2850
|
event.getKeyCode() == 'W' &&
|
3028
|
-
((event.isMetaDown() && platform ==
|
3029
|
-
(event.isControlDown() && platform !=
|
2851
|
+
((event.isMetaDown() && platform == MACOS) ||
|
2852
|
+
(event.isControlDown() && platform != MACOS))) {
|
3030
2853
|
// Can't use this native stuff b/c the native event might be NEWT
|
3031
2854
|
// if (external && event.getNative() instanceof java.awt.event.KeyEvent &&
|
3032
2855
|
// ((java.awt.event.KeyEvent) event.getNative()).getModifiers() ==
|
@@ -3044,7 +2867,7 @@ public class PApplet implements PConstants {
|
|
3044
2867
|
*
|
3045
2868
|
* The <b>keyPressed()</b> function is called once every time a key is
|
3046
2869
|
* pressed. The key that was pressed is stored in the <b>key</b> variable.
|
3047
|
-
*
|
2870
|
+
*
|
3048
2871
|
* For non-ASCII keys, use the <b>keyCode</b> variable. The keys included
|
3049
2872
|
* in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and
|
3050
2873
|
* DELETE) do not require checking to see if they key is coded, and you
|
@@ -3053,7 +2876,7 @@ public class PApplet implements PConstants {
|
|
3053
2876
|
* commonly used on PCs and Unix and the RETURN key is used instead on
|
3054
2877
|
* Macintosh. Check for both ENTER and RETURN to make sure your program
|
3055
2878
|
* will work for all platforms.
|
3056
|
-
*
|
2879
|
+
*
|
3057
2880
|
* Because of how operating systems handle key repeats, holding down a key
|
3058
2881
|
* may cause multiple calls to keyPressed() (and keyReleased() as well).
|
3059
2882
|
* The rate of repeat is set by the operating system and how each computer
|
@@ -3426,17 +3249,9 @@ public class PApplet implements PConstants {
|
|
3426
3249
|
* @param url the complete URL, as a String in quotes
|
3427
3250
|
*/
|
3428
3251
|
public void link(String url) {
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3432
|
-
} else {
|
3433
|
-
// Just pass it off to open() and hope for the best
|
3434
|
-
launch(url);
|
3435
|
-
}
|
3436
|
-
} catch (IOException e) {
|
3437
|
-
printStackTrace(e);
|
3438
|
-
} catch (URISyntaxException e) {
|
3439
|
-
printStackTrace(e);
|
3252
|
+
if (!surface.openLink(url)) {
|
3253
|
+
// Just pass it off to launch() and hope for the best
|
3254
|
+
launch(url);
|
3440
3255
|
}
|
3441
3256
|
}
|
3442
3257
|
|
@@ -3453,25 +3268,25 @@ public class PApplet implements PConstants {
|
|
3453
3268
|
* of an executable in the system's PATH. In most cases, using a full path
|
3454
3269
|
* is the best option, rather than relying on the system PATH. Be sure to
|
3455
3270
|
* make the file executable before attempting to open it (chmod +x).
|
3456
|
-
*
|
3271
|
+
*
|
3457
3272
|
* The <b>args</b> parameter is a String or String array which is passed to
|
3458
3273
|
* the command line. If you have multiple parameters, e.g. an application
|
3459
3274
|
* and a document, or a command with multiple switches, use the version
|
3460
3275
|
* that takes a String array, and place each individual item in a separate
|
3461
3276
|
* element.
|
3462
|
-
*
|
3277
|
+
*
|
3463
3278
|
* If args is a String (not an array), then it can only be a single file or
|
3464
3279
|
* application with no parameters. It's not the same as executing that
|
3465
3280
|
* String using a shell. For instance, launch("javac -help") will not work
|
3466
3281
|
* properly.
|
3467
|
-
*
|
3282
|
+
*
|
3468
3283
|
* This function behaves differently on each platform. On Windows, the
|
3469
3284
|
* parameters are sent to the Windows shell via "cmd /c". On Mac OS X, the
|
3470
3285
|
* "open" command is used (type "man open" in Terminal.app for
|
3471
3286
|
* documentation). On Linux, it first tries gnome-open, then kde-open, but
|
3472
3287
|
* if neither are available, it sends the command to the shell without any
|
3473
3288
|
* alterations.
|
3474
|
-
*
|
3289
|
+
*
|
3475
3290
|
* For users familiar with Java, this is not quite the same as
|
3476
3291
|
* Runtime.exec(), because the launcher command is prepended. Instead, the
|
3477
3292
|
* <b>exec(String[])</b> function is a shortcut for
|
@@ -3492,7 +3307,7 @@ public class PApplet implements PConstants {
|
|
3492
3307
|
// in the user.dir part of the url
|
3493
3308
|
params = new String[] { "cmd", "/c" };
|
3494
3309
|
|
3495
|
-
} else if (platform ==
|
3310
|
+
} else if (platform == MACOS) {
|
3496
3311
|
params = new String[] { "open" };
|
3497
3312
|
|
3498
3313
|
} else if (platform == LINUX) {
|
@@ -3829,7 +3644,7 @@ public class PApplet implements PConstants {
|
|
3829
3644
|
handleMethods("dispose");
|
3830
3645
|
}
|
3831
3646
|
|
3832
|
-
if (platform ==
|
3647
|
+
if (platform == MACOS) {
|
3833
3648
|
try {
|
3834
3649
|
final String td = "processing.core.ThinkDifferent";
|
3835
3650
|
final Class<?> thinkDifferent = getClass().getClassLoader().loadClass(td);
|
@@ -3855,8 +3670,8 @@ public class PApplet implements PConstants {
|
|
3855
3670
|
*/
|
3856
3671
|
public void method(String name) {
|
3857
3672
|
try {
|
3858
|
-
Method method = getClass().getMethod(name
|
3859
|
-
method.invoke(this
|
3673
|
+
Method method = getClass().getMethod(name);
|
3674
|
+
method.invoke(this);
|
3860
3675
|
|
3861
3676
|
} catch (IllegalArgumentException e) {
|
3862
3677
|
e.printStackTrace();
|
@@ -3891,13 +3706,7 @@ public class PApplet implements PConstants {
|
|
3891
3706
|
* @see PApplet#noLoop()
|
3892
3707
|
*/
|
3893
3708
|
public void thread(final String name) {
|
3894
|
-
|
3895
|
-
@Override
|
3896
|
-
public void run() {
|
3897
|
-
method(name);
|
3898
|
-
}
|
3899
|
-
};
|
3900
|
-
later.start();
|
3709
|
+
new Thread(() -> method(name)).start();
|
3901
3710
|
}
|
3902
3711
|
|
3903
3712
|
|
@@ -3919,7 +3728,7 @@ public class PApplet implements PConstants {
|
|
3919
3728
|
* which may be opened by selecting "Show sketch folder" from the "Sketch"
|
3920
3729
|
* menu. It is not possible to use <b>save()</b> while running the program
|
3921
3730
|
* in a web browser.
|
3922
|
-
*
|
3731
|
+
* images saved from the main drawing window will be opaque. To save
|
3923
3732
|
* images without a background, use <b>createGraphics()</b>.
|
3924
3733
|
*
|
3925
3734
|
* ( end auto-generated )
|
@@ -3966,7 +3775,7 @@ public class PApplet implements PConstants {
|
|
3966
3775
|
* href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
|
3967
3776
|
* save a file back to a server, see the <a
|
3968
3777
|
* href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to
|
3969
|
-
* web</A> code snippet on the Processing Wiki
|
3778
|
+
* web</A> code snippet on the Processing Wiki.
|
3970
3779
|
* <br/ >
|
3971
3780
|
* All images saved from the main drawing window will be opaque. To save
|
3972
3781
|
* images without a background, use <b>createGraphics()</b>.
|
@@ -4208,7 +4017,7 @@ public class PApplet implements PConstants {
|
|
4208
4017
|
* to this function creates a new line of output. Individual elements can
|
4209
4018
|
* be separated with quotes ("") and joined with the string concatenation
|
4210
4019
|
* operator (+). See <b>print()</b> for more about what to expect in the output.
|
4211
|
-
*
|
4020
|
+
* <b>println()</b> on an array (by itself) will write the
|
4212
4021
|
* contents of the array to the console. This is often helpful for looking
|
4213
4022
|
* at the data a program is producing. A new line is put between each
|
4214
4023
|
* element of the array. This function can only print one dimensional
|
@@ -5018,9 +4827,9 @@ public class PApplet implements PConstants {
|
|
5018
4827
|
* ( begin auto-generated from norm.xml )
|
5019
4828
|
*
|
5020
4829
|
* Normalizes a number from another range into a value between 0 and 1.
|
5021
|
-
*
|
4830
|
+
*
|
5022
4831
|
* Identical to map(value, low, high, 0, 1);
|
5023
|
-
*
|
4832
|
+
*
|
5024
4833
|
* Numbers outside the range are not clamped to 0 and 1, because
|
5025
4834
|
* out-of-range values are often intentional and useful.
|
5026
4835
|
*
|
@@ -5043,7 +4852,7 @@ public class PApplet implements PConstants {
|
|
5043
4852
|
* the number '25' is converted from a value in the range 0..100 into
|
5044
4853
|
* a value that ranges from the left edge (0) to the right edge (width)
|
5045
4854
|
* of the screen.
|
5046
|
-
*
|
4855
|
+
*
|
5047
4856
|
* Numbers outside the range are not clamped to 0 and 1, because
|
5048
4857
|
* out-of-range values are often intentional and useful.
|
5049
4858
|
*
|
@@ -5432,8 +5241,6 @@ public class PApplet implements PConstants {
|
|
5432
5241
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
5433
5242
|
|
5434
5243
|
|
5435
|
-
protected String[] loadImageFormats;
|
5436
|
-
|
5437
5244
|
/**
|
5438
5245
|
* ( begin auto-generated from loadImage.xml )
|
5439
5246
|
*
|
@@ -5442,23 +5249,23 @@ public class PApplet implements PConstants {
|
|
5442
5249
|
* be loaded. To load correctly, images must be located in the data
|
5443
5250
|
* directory of the current sketch. In most cases, load all images in
|
5444
5251
|
* <b>setup()</b> to preload them at the start of the program. Loading
|
5445
|
-
* images inside <b>draw()</b> will reduce the speed of a program
|
5446
|
-
*
|
5252
|
+
* images inside <b>draw()</b> will reduce the speed of a program.
|
5253
|
+
* <b>filename</b> parameter can also be a URL to a file found
|
5447
5254
|
* online. For security reasons, a Processing sketch found online can only
|
5448
5255
|
* download files from the same server from which it came. Getting around
|
5449
5256
|
* this restriction requires a <a
|
5450
5257
|
* href="http://wiki.processing.org/w/Sign_an_Applet">signed
|
5451
|
-
* applet</a
|
5452
|
-
*
|
5258
|
+
* applet</a>.
|
5259
|
+
* <b>extension</b> parameter is used to determine the image type in
|
5453
5260
|
* cases where the image filename does not end with a proper extension.
|
5454
5261
|
* Specify the extension as the second parameter to <b>loadImage()</b>, as
|
5455
|
-
* shown in the third example on this page
|
5456
|
-
*
|
5262
|
+
* shown in the third example on this page.
|
5263
|
+
* an image is not loaded successfully, the <b>null</b> value is
|
5457
5264
|
* returned and an error message will be printed to the console. The error
|
5458
5265
|
* message does not halt the program, however the null value may cause a
|
5459
5266
|
* NullPointerException if your code does not check whether the value
|
5460
|
-
* returned from <b>loadImage()</b> is null
|
5461
|
-
*
|
5267
|
+
* returned from <b>loadImage()</b> is null.
|
5268
|
+
* on the type of error, a <b>PImage</b> object may still be
|
5462
5269
|
* returned, but the width and height of the image will be set to -1. This
|
5463
5270
|
* happens if bad image data is returned or cannot be decoded properly.
|
5464
5271
|
* Sometimes this happens with image URLs that produce a 403 error or that
|
@@ -5475,29 +5282,14 @@ public class PApplet implements PConstants {
|
|
5475
5282
|
* @see PGraphics#background(float, float, float, float)
|
5476
5283
|
*/
|
5477
5284
|
public PImage loadImage(String filename) {
|
5478
|
-
// return loadImage(filename, null, null);
|
5479
5285
|
return loadImage(filename, null);
|
5480
5286
|
}
|
5481
5287
|
|
5482
|
-
// /**
|
5483
|
-
// * @param extension the type of image to load, for example "png", "gif", "jpg"
|
5484
|
-
// */
|
5485
|
-
// public PImage loadImage(String filename, String extension) {
|
5486
|
-
// return loadImage(filename, extension, null);
|
5487
|
-
// }
|
5488
|
-
|
5489
|
-
// /**
|
5490
|
-
// * @nowebref
|
5491
|
-
// */
|
5492
|
-
// public PImage loadImage(String filename, Object params) {
|
5493
|
-
// return loadImage(filename, null, params);
|
5494
|
-
// }
|
5495
5288
|
|
5496
5289
|
/**
|
5497
5290
|
* @param extension type of image to load, for example "png", "gif", "jpg"
|
5498
5291
|
*/
|
5499
|
-
public PImage loadImage(String filename, String extension) {
|
5500
|
-
|
5292
|
+
public PImage loadImage(String filename, String extension) {
|
5501
5293
|
// awaitAsyncSaveCompletion() has to run on the main thread, because P2D
|
5502
5294
|
// and P3D call GL functions. If this runs on background, requestImage()
|
5503
5295
|
// already called awaitAsyncSaveCompletion() on the main thread.
|
@@ -5505,7 +5297,7 @@ public class PApplet implements PConstants {
|
|
5505
5297
|
g.awaitAsyncSaveCompletion(filename);
|
5506
5298
|
}
|
5507
5299
|
|
5508
|
-
return
|
5300
|
+
return surface.loadImage(filename, extension);
|
5509
5301
|
}
|
5510
5302
|
|
5511
5303
|
|
@@ -5529,7 +5321,7 @@ public class PApplet implements PConstants {
|
|
5529
5321
|
* when the image has loaded properly because its width and height will be
|
5530
5322
|
* greater than 0. Asynchronous image loading (particularly when
|
5531
5323
|
* downloading from a server) can dramatically improve performance.
|
5532
|
-
*
|
5324
|
+
* <b>extension</b> parameter is used to determine the image type in
|
5533
5325
|
* cases where the image filename does not end with a proper extension.
|
5534
5326
|
* Specify the extension as the second parameter to <b>requestImage()</b>.
|
5535
5327
|
*
|
@@ -5551,11 +5343,7 @@ public class PApplet implements PConstants {
|
|
5551
5343
|
|
5552
5344
|
// if the image loading thread pool hasn't been created, create it
|
5553
5345
|
if (requestImagePool == null) {
|
5554
|
-
ThreadFactory factory = new
|
5555
|
-
public Thread newThread(Runnable r) {
|
5556
|
-
return new Thread(r, REQUEST_IMAGE_THREAD_PREFIX);
|
5557
|
-
}
|
5558
|
-
};
|
5346
|
+
ThreadFactory factory = r -> new Thread(r, REQUEST_IMAGE_THREAD_PREFIX);
|
5559
5347
|
requestImagePool = Executors.newFixedThreadPool(4, factory);
|
5560
5348
|
}
|
5561
5349
|
requestImagePool.execute(() -> {
|
@@ -5635,13 +5423,7 @@ public class PApplet implements PConstants {
|
|
5635
5423
|
|
5636
5424
|
// can't use catch-all exception, since it might catch the
|
5637
5425
|
// RuntimeException about the incorrect case sensitivity
|
5638
|
-
} catch (IOException e) {
|
5639
|
-
throw new RuntimeException(e);
|
5640
|
-
|
5641
|
-
} catch (ParserConfigurationException e) {
|
5642
|
-
throw new RuntimeException(e);
|
5643
|
-
|
5644
|
-
} catch (SAXException e) {
|
5426
|
+
} catch (IOException | ParserConfigurationException | SAXException e) {
|
5645
5427
|
throw new RuntimeException(e);
|
5646
5428
|
}
|
5647
5429
|
}
|
@@ -5872,10 +5654,9 @@ public class PApplet implements PConstants {
|
|
5872
5654
|
String optionStr = Table.extensionOptions(true, filename, options);
|
5873
5655
|
String[] optionList = trim(split(optionStr, ','));
|
5874
5656
|
|
5875
|
-
Table dictionary = null;
|
5876
5657
|
for (String opt : optionList) {
|
5877
5658
|
if (opt.startsWith("dictionary=")) {
|
5878
|
-
dictionary = loadTable(opt.substring(opt.indexOf('=') + 1), "tsv");
|
5659
|
+
Table dictionary = loadTable(opt.substring(opt.indexOf('=') + 1), "tsv");
|
5879
5660
|
return dictionary.typedParse(createInput(filename), optionStr);
|
5880
5661
|
}
|
5881
5662
|
}
|
@@ -6085,25 +5866,6 @@ public class PApplet implements PConstants {
|
|
6085
5866
|
*/
|
6086
5867
|
|
6087
5868
|
|
6088
|
-
static private boolean lookAndFeelCheck;
|
6089
|
-
|
6090
|
-
/**
|
6091
|
-
* Initialize the Look & Feel if it hasn't been already.
|
6092
|
-
* Call this before using any Swing-related code in PApplet methods.
|
6093
|
-
*/
|
6094
|
-
static private void checkLookAndFeel() {
|
6095
|
-
if (!lookAndFeelCheck) {
|
6096
|
-
if (platform == WINDOWS) {
|
6097
|
-
// Windows is defaulting to Metal or something else awful.
|
6098
|
-
// Which also is not scaled properly with HiDPI interfaces.
|
6099
|
-
try {
|
6100
|
-
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
6101
|
-
} catch (Exception e) { }
|
6102
|
-
}
|
6103
|
-
lookAndFeelCheck = true;
|
6104
|
-
}
|
6105
|
-
}
|
6106
|
-
|
6107
5869
|
/**
|
6108
5870
|
* Open a platform-specific file chooser dialog to select a file for input.
|
6109
5871
|
* After the selection is made, the selected File will be passed to the
|
@@ -6145,10 +5907,12 @@ public class PApplet implements PConstants {
|
|
6145
5907
|
|
6146
5908
|
public void selectInput(String prompt, String callback,
|
6147
5909
|
File file, Object callbackObject) {
|
6148
|
-
selectInput(prompt, callback, file, callbackObject, null, this);
|
5910
|
+
//selectInput(prompt, callback, file, callbackObject, null, this);
|
5911
|
+
surface.selectInput(prompt, callback, file, callbackObject);
|
6149
5912
|
}
|
6150
5913
|
|
6151
5914
|
|
5915
|
+
/*
|
6152
5916
|
static public void selectInput(String prompt, String callbackMethod,
|
6153
5917
|
File file, Object callbackObject, Frame parent,
|
6154
5918
|
PApplet sketch) {
|
@@ -6160,6 +5924,7 @@ public class PApplet implements PConstants {
|
|
6160
5924
|
File file, Object callbackObject, Frame parent) {
|
6161
5925
|
selectImpl(prompt, callbackMethod, file, callbackObject, parent, FileDialog.LOAD, null);
|
6162
5926
|
}
|
5927
|
+
*/
|
6163
5928
|
|
6164
5929
|
|
6165
5930
|
/**
|
@@ -6181,10 +5946,12 @@ public class PApplet implements PConstants {
|
|
6181
5946
|
|
6182
5947
|
public void selectOutput(String prompt, String callback,
|
6183
5948
|
File file, Object callbackObject) {
|
6184
|
-
selectOutput(prompt, callback, file, callbackObject, null, this);
|
5949
|
+
//selectOutput(prompt, callback, file, callbackObject, null, this);
|
5950
|
+
surface.selectOutput(prompt, callback, file, callbackObject);
|
6185
5951
|
}
|
6186
5952
|
|
6187
5953
|
|
5954
|
+
/*
|
6188
5955
|
static public void selectOutput(String prompt, String callbackMethod,
|
6189
5956
|
File file, Object callbackObject, Frame parent) {
|
6190
5957
|
selectImpl(prompt, callbackMethod, file, callbackObject, parent, FileDialog.SAVE, null);
|
@@ -6252,6 +6019,7 @@ public class PApplet implements PConstants {
|
|
6252
6019
|
}
|
6253
6020
|
});
|
6254
6021
|
}
|
6022
|
+
*/
|
6255
6023
|
|
6256
6024
|
|
6257
6025
|
/**
|
@@ -6273,10 +6041,12 @@ public class PApplet implements PConstants {
|
|
6273
6041
|
|
6274
6042
|
public void selectFolder(String prompt, String callback,
|
6275
6043
|
File file, Object callbackObject) {
|
6276
|
-
selectFolder(prompt, callback, file, callbackObject, null, this);
|
6044
|
+
//selectFolder(prompt, callback, file, callbackObject, null, this);
|
6045
|
+
surface.selectFolder(prompt, callback, file, callbackObject);
|
6277
6046
|
}
|
6278
6047
|
|
6279
6048
|
|
6049
|
+
/*
|
6280
6050
|
static public void selectFolder(final String prompt,
|
6281
6051
|
final String callbackMethod,
|
6282
6052
|
final File defaultSelection,
|
@@ -6302,7 +6072,7 @@ public class PApplet implements PConstants {
|
|
6302
6072
|
(sketch.g instanceof PGraphicsOpenGL) && (platform == WINDOWS);
|
6303
6073
|
if (hide) sketch.surface.setVisible(false);
|
6304
6074
|
|
6305
|
-
if (platform ==
|
6075
|
+
if (platform == MACOS && useNativeSelect != false) {
|
6306
6076
|
FileDialog fileDialog =
|
6307
6077
|
new FileDialog(parentFrame, prompt, FileDialog.LOAD);
|
6308
6078
|
if (defaultSelection != null) {
|
@@ -6335,16 +6105,17 @@ public class PApplet implements PConstants {
|
|
6335
6105
|
}
|
6336
6106
|
});
|
6337
6107
|
}
|
6108
|
+
*/
|
6338
6109
|
|
6339
6110
|
|
6340
|
-
static
|
6341
|
-
|
6342
|
-
|
6111
|
+
static public void selectCallback(File selectedFile,
|
6112
|
+
String callbackMethod,
|
6113
|
+
Object callbackObject) {
|
6343
6114
|
try {
|
6344
6115
|
Class<?> callbackClass = callbackObject.getClass();
|
6345
6116
|
Method selectMethod =
|
6346
|
-
callbackClass.getMethod(callbackMethod,
|
6347
|
-
selectMethod.invoke(callbackObject,
|
6117
|
+
callbackClass.getMethod(callbackMethod, File.class);
|
6118
|
+
selectMethod.invoke(callbackObject, selectedFile);
|
6348
6119
|
|
6349
6120
|
} catch (IllegalAccessException iae) {
|
6350
6121
|
System.err.println(callbackMethod + "() must be public");
|
@@ -6358,7 +6129,6 @@ public class PApplet implements PConstants {
|
|
6358
6129
|
}
|
6359
6130
|
|
6360
6131
|
|
6361
|
-
|
6362
6132
|
//////////////////////////////////////////////////////////////
|
6363
6133
|
|
6364
6134
|
// LISTING DIRECTORIES
|
@@ -6522,7 +6292,7 @@ public class PApplet implements PConstants {
|
|
6522
6292
|
* Creates a <b>BufferedReader</b> object that can be used to read files
|
6523
6293
|
* line-by-line as individual <b>String</b> objects. This is the complement
|
6524
6294
|
* to the <b>createWriter()</b> function.
|
6525
|
-
*
|
6295
|
+
*
|
6526
6296
|
* Starting with Processing release 0134, all files loaded and saved by the
|
6527
6297
|
* Processing API use UTF-8 encoding. In previous releases, the default
|
6528
6298
|
* encoding for your platform was used, which causes problems when files
|
@@ -6598,7 +6368,7 @@ public class PApplet implements PConstants {
|
|
6598
6368
|
* to write to it. For the file to be made correctly, it should be flushed
|
6599
6369
|
* and must be closed with its <b>flush()</b> and <b>close()</b> methods
|
6600
6370
|
* (see above example).
|
6601
|
-
*
|
6371
|
+
*
|
6602
6372
|
* Starting with Processing release 0134, all files loaded and saved by the
|
6603
6373
|
* Processing API use UTF-8 encoding. In previous releases, the default
|
6604
6374
|
* encoding for your platform was used, which causes problems when files
|
@@ -6730,7 +6500,23 @@ public class PApplet implements PConstants {
|
|
6730
6500
|
*
|
6731
6501
|
*/
|
6732
6502
|
public InputStream createInput(String filename) {
|
6733
|
-
|
6503
|
+
InputStream input = createInputRaw(filename);
|
6504
|
+
if (input != null) {
|
6505
|
+
// if it's gzip-encoded, automatically decode
|
6506
|
+
final String lower = filename.toLowerCase();
|
6507
|
+
if (lower.endsWith(".gz") || lower.endsWith(".svgz")) {
|
6508
|
+
try {
|
6509
|
+
// buffered has to go *around* the GZ, otherwise 25x slower
|
6510
|
+
return new BufferedInputStream(new GZIPInputStream(input));
|
6511
|
+
|
6512
|
+
} catch (IOException e) {
|
6513
|
+
printStackTrace(e);
|
6514
|
+
}
|
6515
|
+
} else {
|
6516
|
+
return new BufferedInputStream(input);
|
6517
|
+
}
|
6518
|
+
}
|
6519
|
+
return null;
|
6734
6520
|
}
|
6735
6521
|
|
6736
6522
|
|
@@ -6738,7 +6524,154 @@ public class PApplet implements PConstants {
|
|
6738
6524
|
* Call openStream() without automatic gzip decompression.
|
6739
6525
|
*/
|
6740
6526
|
public InputStream createInputRaw(String filename) {
|
6741
|
-
|
6527
|
+
if (filename == null) return null;
|
6528
|
+
|
6529
|
+
if (sketchPath == null) {
|
6530
|
+
System.err.println("The sketch path is not set.");
|
6531
|
+
throw new RuntimeException("Files must be loaded inside setup() or after it has been called.");
|
6532
|
+
}
|
6533
|
+
|
6534
|
+
if (filename.length() == 0) {
|
6535
|
+
// an error will be called by the parent function
|
6536
|
+
//System.err.println("The filename passed to openStream() was empty.");
|
6537
|
+
return null;
|
6538
|
+
}
|
6539
|
+
|
6540
|
+
// First check whether this looks like a URL
|
6541
|
+
if (filename.contains(":")) { // at least smells like URL
|
6542
|
+
try {
|
6543
|
+
URL url = new URL(filename);
|
6544
|
+
URLConnection conn = url.openConnection();
|
6545
|
+
|
6546
|
+
if (conn instanceof HttpURLConnection) {
|
6547
|
+
HttpURLConnection httpConn = (HttpURLConnection) conn;
|
6548
|
+
// Will not handle a protocol change (see below)
|
6549
|
+
httpConn.setInstanceFollowRedirects(true);
|
6550
|
+
int response = httpConn.getResponseCode();
|
6551
|
+
// Default won't follow HTTP -> HTTPS redirects for security reasons
|
6552
|
+
// http://stackoverflow.com/a/1884427
|
6553
|
+
if (response >= 300 && response < 400) {
|
6554
|
+
String newLocation = httpConn.getHeaderField("Location");
|
6555
|
+
return createInputRaw(newLocation);
|
6556
|
+
}
|
6557
|
+
return conn.getInputStream();
|
6558
|
+
} else if (conn instanceof JarURLConnection) {
|
6559
|
+
return url.openStream();
|
6560
|
+
}
|
6561
|
+
} catch (MalformedURLException mfue) {
|
6562
|
+
// not a url, that's fine
|
6563
|
+
|
6564
|
+
} catch (FileNotFoundException fnfe) {
|
6565
|
+
// Added in 0119 b/c Java 1.5 throws FNFE when URL not available.
|
6566
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=403
|
6567
|
+
|
6568
|
+
} catch (IOException e) {
|
6569
|
+
// changed for 0117, shouldn't be throwing exception
|
6570
|
+
printStackTrace(e);
|
6571
|
+
//System.err.println("Error downloading from URL " + filename);
|
6572
|
+
return null;
|
6573
|
+
//throw new RuntimeException("Error downloading from URL " + filename);
|
6574
|
+
}
|
6575
|
+
}
|
6576
|
+
|
6577
|
+
InputStream stream;
|
6578
|
+
|
6579
|
+
// Moved this earlier than the getResourceAsStream() checks, because
|
6580
|
+
// calling getResourceAsStream() on a directory lists its contents.
|
6581
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=716
|
6582
|
+
try {
|
6583
|
+
// First see if it's in a data folder. This may fail by throwing
|
6584
|
+
// a SecurityException. If so, this whole block will be skipped.
|
6585
|
+
File file = new File(dataPath(filename));
|
6586
|
+
if (!file.exists()) {
|
6587
|
+
// next see if it's just in the sketch folder
|
6588
|
+
file = sketchFile(filename);
|
6589
|
+
}
|
6590
|
+
|
6591
|
+
if (file.isDirectory()) {
|
6592
|
+
return null;
|
6593
|
+
}
|
6594
|
+
if (file.exists()) {
|
6595
|
+
try {
|
6596
|
+
// handle case sensitivity check
|
6597
|
+
String filePath = file.getCanonicalPath();
|
6598
|
+
String filenameActual = new File(filePath).getName();
|
6599
|
+
// make sure there isn't a subfolder prepended to the name
|
6600
|
+
String filenameShort = new File(filename).getName();
|
6601
|
+
// if the actual filename is the same, but capitalized
|
6602
|
+
// differently, warn the user.
|
6603
|
+
//if (filenameActual.equalsIgnoreCase(filenameShort) &&
|
6604
|
+
//!filenameActual.equals(filenameShort)) {
|
6605
|
+
if (!filenameActual.equals(filenameShort)) {
|
6606
|
+
throw new RuntimeException("This file is named " +
|
6607
|
+
filenameActual + " not " +
|
6608
|
+
filename + ". Rename the file " +
|
6609
|
+
"or change your code.");
|
6610
|
+
}
|
6611
|
+
} catch (IOException ignored) { }
|
6612
|
+
}
|
6613
|
+
|
6614
|
+
// if this file is ok, may as well just load it
|
6615
|
+
return new FileInputStream(file);
|
6616
|
+
|
6617
|
+
// have to break these out because a general Exception might
|
6618
|
+
// catch the RuntimeException being thrown above
|
6619
|
+
} catch (IOException | SecurityException ignored) { }
|
6620
|
+
|
6621
|
+
// Using getClassLoader() prevents java from converting dots
|
6622
|
+
// to slashes or requiring a slash at the beginning.
|
6623
|
+
// (a slash as a prefix means that it'll load from the root of
|
6624
|
+
// the jar, rather than trying to dig into the package location)
|
6625
|
+
ClassLoader cl = getClass().getClassLoader();
|
6626
|
+
|
6627
|
+
// by default, data files are exported to the root path of the jar.
|
6628
|
+
// (not the data folder) so check there first.
|
6629
|
+
stream = cl.getResourceAsStream("data/" + filename);
|
6630
|
+
if (stream != null) {
|
6631
|
+
String cn = stream.getClass().getName();
|
6632
|
+
// this is an irritation of sun's java plug-in, which will return
|
6633
|
+
// a non-null stream for an object that doesn't exist. like all good
|
6634
|
+
// things, this is probably introduced in java 1.5. awesome!
|
6635
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=359
|
6636
|
+
if (!cn.equals("sun.plugin.cache.EmptyInputStream")) {
|
6637
|
+
return stream;
|
6638
|
+
}
|
6639
|
+
}
|
6640
|
+
|
6641
|
+
// When used with an online script, also need to check without the
|
6642
|
+
// data folder, in case it's not in a subfolder called 'data'.
|
6643
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=389
|
6644
|
+
stream = cl.getResourceAsStream(filename);
|
6645
|
+
if (stream != null) {
|
6646
|
+
String cn = stream.getClass().getName();
|
6647
|
+
if (!cn.equals("sun.plugin.cache.EmptyInputStream")) {
|
6648
|
+
return stream;
|
6649
|
+
}
|
6650
|
+
}
|
6651
|
+
|
6652
|
+
try {
|
6653
|
+
// attempt to load from a local file, used when running as
|
6654
|
+
// an application, or as a signed applet
|
6655
|
+
try { // first try to catch any security exceptions
|
6656
|
+
try {
|
6657
|
+
return new FileInputStream(dataPath(filename));
|
6658
|
+
} catch (IOException ignored) { }
|
6659
|
+
|
6660
|
+
try {
|
6661
|
+
return new FileInputStream(sketchPath(filename));
|
6662
|
+
} catch (Exception ignored) { }
|
6663
|
+
|
6664
|
+
try {
|
6665
|
+
return new FileInputStream(filename);
|
6666
|
+
} catch (IOException ignored) { }
|
6667
|
+
|
6668
|
+
} catch (SecurityException ignored) { } // online, whups
|
6669
|
+
|
6670
|
+
} catch (Exception e) {
|
6671
|
+
printStackTrace(e);
|
6672
|
+
}
|
6673
|
+
|
6674
|
+
return null;
|
6742
6675
|
}
|
6743
6676
|
|
6744
6677
|
|
@@ -6746,7 +6679,26 @@ public class PApplet implements PConstants {
|
|
6746
6679
|
* @nowebref
|
6747
6680
|
*/
|
6748
6681
|
static public InputStream createInput(File file) {
|
6749
|
-
|
6682
|
+
if (file == null) {
|
6683
|
+
throw new IllegalArgumentException("File passed to createInput() was null");
|
6684
|
+
}
|
6685
|
+
if (!file.exists()) {
|
6686
|
+
System.err.println(file + " does not exist, createInput() will return null");
|
6687
|
+
return null;
|
6688
|
+
}
|
6689
|
+
try {
|
6690
|
+
InputStream input = new FileInputStream(file);
|
6691
|
+
final String lower = file.getName().toLowerCase();
|
6692
|
+
if (lower.endsWith(".gz") || lower.endsWith(".svgz")) {
|
6693
|
+
return new BufferedInputStream(new GZIPInputStream(input));
|
6694
|
+
}
|
6695
|
+
return new BufferedInputStream(input);
|
6696
|
+
|
6697
|
+
} catch (IOException e) {
|
6698
|
+
System.err.println("Could not createInput() for " + file);
|
6699
|
+
e.printStackTrace();
|
6700
|
+
return null;
|
6701
|
+
}
|
6750
6702
|
}
|
6751
6703
|
|
6752
6704
|
|
@@ -6805,7 +6757,7 @@ public class PApplet implements PConstants {
|
|
6805
6757
|
}
|
6806
6758
|
|
6807
6759
|
if (input != null) {
|
6808
|
-
byte[] buffer
|
6760
|
+
byte[] buffer;
|
6809
6761
|
if (length != -1) {
|
6810
6762
|
buffer = new byte[length];
|
6811
6763
|
int count;
|
@@ -6979,7 +6931,7 @@ public class PApplet implements PConstants {
|
|
6979
6931
|
* message does not halt the program, however the null value may cause a
|
6980
6932
|
* NullPointerException if your code does not check whether the value
|
6981
6933
|
* returned is null.
|
6982
|
-
*
|
6934
|
+
*
|
6983
6935
|
* Starting with Processing release 0134, all files loaded and saved by the
|
6984
6936
|
* Processing API use UTF-8 encoding. In previous releases, the default
|
6985
6937
|
* encoding for your platform was used, which causes problems when files
|
@@ -7028,25 +6980,20 @@ public class PApplet implements PConstants {
|
|
7028
6980
|
* @nowebref
|
7029
6981
|
*/
|
7030
6982
|
static public String[] loadStrings(InputStream input) {
|
7031
|
-
|
7032
|
-
BufferedReader
|
7033
|
-
|
7034
|
-
return loadStrings(reader);
|
7035
|
-
} catch (IOException e) {
|
7036
|
-
e.printStackTrace();
|
7037
|
-
}
|
7038
|
-
return null;
|
6983
|
+
BufferedReader reader =
|
6984
|
+
new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
6985
|
+
return loadStrings(reader);
|
7039
6986
|
}
|
7040
6987
|
|
7041
6988
|
|
7042
6989
|
static public String[] loadStrings(BufferedReader reader) {
|
7043
6990
|
try {
|
7044
|
-
String
|
6991
|
+
String[] lines = new String[100];
|
7045
6992
|
int lineCount = 0;
|
7046
|
-
String line
|
6993
|
+
String line;
|
7047
6994
|
while ((line = reader.readLine()) != null) {
|
7048
6995
|
if (lineCount == lines.length) {
|
7049
|
-
String
|
6996
|
+
String[] temp = new String[lineCount << 1];
|
7050
6997
|
System.arraycopy(lines, 0, temp, 0, lineCount);
|
7051
6998
|
lines = temp;
|
7052
6999
|
}
|
@@ -7059,7 +7006,7 @@ public class PApplet implements PConstants {
|
|
7059
7006
|
}
|
7060
7007
|
|
7061
7008
|
// resize array to appropriate amount for these lines
|
7062
|
-
String
|
7009
|
+
String[] output = new String[lineCount];
|
7063
7010
|
System.arraycopy(lines, 0, output, 0, lineCount);
|
7064
7011
|
return output;
|
7065
7012
|
|
@@ -7179,24 +7126,23 @@ public class PApplet implements PConstants {
|
|
7179
7126
|
|
7180
7127
|
saveStream(targetStream, source);
|
7181
7128
|
targetStream.close();
|
7182
|
-
targetStream = null;
|
7183
7129
|
|
7184
7130
|
if (target.exists()) {
|
7185
7131
|
if (!target.delete()) {
|
7186
|
-
System.err.println("Could not replace " +
|
7187
|
-
target.getAbsolutePath() + ".");
|
7132
|
+
System.err.println("Could not replace " + target);
|
7188
7133
|
}
|
7189
7134
|
}
|
7190
7135
|
if (!tempFile.renameTo(target)) {
|
7191
|
-
System.err.println("Could not rename temporary file " +
|
7192
|
-
tempFile.getAbsolutePath());
|
7136
|
+
System.err.println("Could not rename temporary file " + tempFile);
|
7193
7137
|
return false;
|
7194
7138
|
}
|
7195
7139
|
return true;
|
7196
7140
|
|
7197
7141
|
} catch (IOException e) {
|
7198
7142
|
if (tempFile != null) {
|
7199
|
-
tempFile.delete()
|
7143
|
+
if (!tempFile.delete()) {
|
7144
|
+
System.err.println("Could not rename temporary file " + tempFile);
|
7145
|
+
}
|
7200
7146
|
}
|
7201
7147
|
e.printStackTrace();
|
7202
7148
|
return false;
|
@@ -7260,7 +7206,9 @@ public class PApplet implements PConstants {
|
|
7260
7206
|
static private File createTempFile(File file) throws IOException {
|
7261
7207
|
File parentDir = file.getParentFile();
|
7262
7208
|
if (!parentDir.exists()) {
|
7263
|
-
parentDir.mkdirs()
|
7209
|
+
if (!parentDir.mkdirs()) {
|
7210
|
+
throw new IOException("Could not make directories for " + parentDir);
|
7211
|
+
}
|
7264
7212
|
}
|
7265
7213
|
String name = file.getName();
|
7266
7214
|
String prefix;
|
@@ -7291,25 +7239,29 @@ public class PApplet implements PConstants {
|
|
7291
7239
|
tempFile = createTempFile(file);
|
7292
7240
|
|
7293
7241
|
OutputStream output = createOutput(tempFile);
|
7294
|
-
|
7295
|
-
|
7296
|
-
|
7242
|
+
if (output != null) {
|
7243
|
+
saveBytes(output, data);
|
7244
|
+
output.close();
|
7245
|
+
} else {
|
7246
|
+
System.err.println("Could not write to " + tempFile);
|
7247
|
+
}
|
7297
7248
|
|
7298
7249
|
if (file.exists()) {
|
7299
7250
|
if (!file.delete()) {
|
7300
|
-
System.err.println("Could not replace " + file
|
7251
|
+
System.err.println("Could not replace " + file);
|
7301
7252
|
}
|
7302
7253
|
}
|
7303
7254
|
|
7304
7255
|
if (!tempFile.renameTo(file)) {
|
7305
|
-
System.err.println("Could not rename temporary file " +
|
7306
|
-
tempFile.getAbsolutePath());
|
7256
|
+
System.err.println("Could not rename temporary file " + tempFile);
|
7307
7257
|
}
|
7308
7258
|
|
7309
7259
|
} catch (IOException e) {
|
7310
7260
|
System.err.println("error saving bytes to " + file);
|
7311
7261
|
if (tempFile != null) {
|
7312
|
-
tempFile.delete()
|
7262
|
+
if (!tempFile.delete()) {
|
7263
|
+
System.err.println("Could not delete temporary file " + tempFile);
|
7264
|
+
}
|
7313
7265
|
}
|
7314
7266
|
e.printStackTrace();
|
7315
7267
|
}
|
@@ -7345,7 +7297,7 @@ public class PApplet implements PConstants {
|
|
7345
7297
|
* href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To
|
7346
7298
|
* save a file back to a server, see the <a
|
7347
7299
|
* href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to
|
7348
|
-
* web</A> code snippet on the Processing Wiki
|
7300
|
+
* web</A> code snippet on the Processing Wiki.
|
7349
7301
|
* <br/ >
|
7350
7302
|
* Starting with Processing 1.0, all files loaded and saved by the
|
7351
7303
|
* Processing API use UTF-8 encoding. In previous releases, the default
|
@@ -7360,7 +7312,7 @@ public class PApplet implements PConstants {
|
|
7360
7312
|
* @see PApplet#loadBytes(String)
|
7361
7313
|
* @see PApplet#saveBytes(String, byte[])
|
7362
7314
|
*/
|
7363
|
-
public void saveStrings(String filename, String data
|
7315
|
+
public void saveStrings(String filename, String[] data) {
|
7364
7316
|
saveStrings(saveFile(filename), data);
|
7365
7317
|
}
|
7366
7318
|
|
@@ -7368,7 +7320,7 @@ public class PApplet implements PConstants {
|
|
7368
7320
|
/**
|
7369
7321
|
* @nowebref
|
7370
7322
|
*/
|
7371
|
-
static public void saveStrings(File file, String data
|
7323
|
+
static public void saveStrings(File file, String[] data) {
|
7372
7324
|
saveStrings(createOutput(file), data);
|
7373
7325
|
}
|
7374
7326
|
|
@@ -7404,7 +7356,7 @@ public class PApplet implements PConstants {
|
|
7404
7356
|
|
7405
7357
|
// Workaround for bug in Java for OS X from Oracle (7u51)
|
7406
7358
|
// https://github.com/processing/processing/issues/2181
|
7407
|
-
if (platform ==
|
7359
|
+
if (platform == MACOS) {
|
7408
7360
|
if (jarPath.contains("Contents/Java/")) {
|
7409
7361
|
String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4);
|
7410
7362
|
File containingFolder = new File(appPath).getParentFile();
|
@@ -7498,17 +7450,15 @@ public class PApplet implements PConstants {
|
|
7498
7450
|
|
7499
7451
|
static File desktopFolder;
|
7500
7452
|
|
7501
|
-
/** Not a supported function. For testing use only. */
|
7502
7453
|
static public File desktopFile(String what) {
|
7503
7454
|
if (desktopFolder == null) {
|
7504
7455
|
// Should work on Linux and OS X (on OS X, even with the localized version).
|
7505
7456
|
desktopFolder = new File(System.getProperty("user.home"), "Desktop");
|
7506
7457
|
if (!desktopFolder.exists()) {
|
7507
|
-
if (platform == WINDOWS) {
|
7508
|
-
|
7509
|
-
desktopFolder = filesys.getHomeDirectory();
|
7458
|
+
if (platform == WINDOWS && !disableAWT) {
|
7459
|
+
desktopFolder = ShimAWT.getWindowsDesktop();
|
7510
7460
|
} else {
|
7511
|
-
throw new UnsupportedOperationException("Could not find a suitable
|
7461
|
+
throw new UnsupportedOperationException("Could not find a suitable Desktop foldder");
|
7512
7462
|
}
|
7513
7463
|
}
|
7514
7464
|
}
|
@@ -7516,7 +7466,6 @@ public class PApplet implements PConstants {
|
|
7516
7466
|
}
|
7517
7467
|
|
7518
7468
|
|
7519
|
-
/** Not a supported function. For testing use only. */
|
7520
7469
|
static public String desktopPath(String what) {
|
7521
7470
|
return desktopFile(what).getAbsolutePath();
|
7522
7471
|
}
|
@@ -7593,17 +7542,42 @@ public class PApplet implements PConstants {
|
|
7593
7542
|
* may not actually exist.
|
7594
7543
|
*/
|
7595
7544
|
static public void createPath(String path) {
|
7596
|
-
|
7545
|
+
createPath(new File(path));
|
7597
7546
|
}
|
7598
7547
|
|
7599
7548
|
|
7600
7549
|
static public void createPath(File file) {
|
7601
|
-
|
7550
|
+
try {
|
7551
|
+
String parent = file.getParent();
|
7552
|
+
if (parent != null) {
|
7553
|
+
File unit = new File(parent);
|
7554
|
+
if (!unit.exists()) unit.mkdirs();
|
7555
|
+
}
|
7556
|
+
} catch (SecurityException se) {
|
7557
|
+
System.err.println("You don't have permissions to create " +
|
7558
|
+
file.getAbsolutePath());
|
7559
|
+
}
|
7602
7560
|
}
|
7603
7561
|
|
7604
7562
|
|
7605
7563
|
static public String getExtension(String filename) {
|
7606
|
-
|
7564
|
+
String extension;
|
7565
|
+
|
7566
|
+
String lower = filename.toLowerCase();
|
7567
|
+
int dot = filename.lastIndexOf('.');
|
7568
|
+
if (dot == -1) {
|
7569
|
+
return ""; // no extension found
|
7570
|
+
}
|
7571
|
+
extension = lower.substring(dot + 1);
|
7572
|
+
|
7573
|
+
// check for, and strip any parameters on the url, i.e.
|
7574
|
+
// filename.jpg?blah=blah&something=that
|
7575
|
+
int question = extension.indexOf('?');
|
7576
|
+
if (question != -1) {
|
7577
|
+
extension = extension.substring(0, question);
|
7578
|
+
}
|
7579
|
+
|
7580
|
+
return extension;
|
7607
7581
|
}
|
7608
7582
|
|
7609
7583
|
|
@@ -7627,11 +7601,7 @@ public class PApplet implements PConstants {
|
|
7627
7601
|
// using toURI() and URI.toURL()."
|
7628
7602
|
// https://docs.oracle.com/javase/8/docs/api/java/net/URL.html
|
7629
7603
|
static public String urlDecode(String str) {
|
7630
|
-
|
7631
|
-
return URLDecoder.decode(str, "UTF-8");
|
7632
|
-
} catch (UnsupportedEncodingException e) { // safe per the JDK source
|
7633
|
-
return null;
|
7634
|
-
}
|
7604
|
+
return URLDecoder.decode(str, StandardCharsets.UTF_8);
|
7635
7605
|
}
|
7636
7606
|
|
7637
7607
|
|
@@ -7657,7 +7627,7 @@ public class PApplet implements PConstants {
|
|
7657
7627
|
* @param list array to sort
|
7658
7628
|
* @see PApplet#reverse(boolean[])
|
7659
7629
|
*/
|
7660
|
-
static public byte[] sort(byte list
|
7630
|
+
static public byte[] sort(byte[] list) {
|
7661
7631
|
return sort(list, list.length);
|
7662
7632
|
}
|
7663
7633
|
|
@@ -7671,7 +7641,7 @@ public class PApplet implements PConstants {
|
|
7671
7641
|
return outgoing;
|
7672
7642
|
}
|
7673
7643
|
|
7674
|
-
static public char[] sort(char list
|
7644
|
+
static public char[] sort(char[] list) {
|
7675
7645
|
return sort(list, list.length);
|
7676
7646
|
}
|
7677
7647
|
|
@@ -7682,7 +7652,7 @@ public class PApplet implements PConstants {
|
|
7682
7652
|
return outgoing;
|
7683
7653
|
}
|
7684
7654
|
|
7685
|
-
static public int[] sort(int list
|
7655
|
+
static public int[] sort(int[] list) {
|
7686
7656
|
return sort(list, list.length);
|
7687
7657
|
}
|
7688
7658
|
|
@@ -7693,7 +7663,7 @@ public class PApplet implements PConstants {
|
|
7693
7663
|
return outgoing;
|
7694
7664
|
}
|
7695
7665
|
|
7696
|
-
static public float[] sort(float list
|
7666
|
+
static public float[] sort(float[] list) {
|
7697
7667
|
return sort(list, list.length);
|
7698
7668
|
}
|
7699
7669
|
|
@@ -7704,7 +7674,7 @@ public class PApplet implements PConstants {
|
|
7704
7674
|
return outgoing;
|
7705
7675
|
}
|
7706
7676
|
|
7707
|
-
static public String[] sort(String list
|
7677
|
+
static public String[] sort(String[] list) {
|
7708
7678
|
return sort(list, list.length);
|
7709
7679
|
}
|
7710
7680
|
|
@@ -7800,7 +7770,7 @@ public class PApplet implements PConstants {
|
|
7800
7770
|
* Increases the size of an array. By default, this function doubles the
|
7801
7771
|
* size of the array, but the optional <b>newSize</b> parameter provides
|
7802
7772
|
* precise control over the increase in size.
|
7803
|
-
*
|
7773
|
+
*
|
7804
7774
|
* When using an array of objects, the data returned from the function must
|
7805
7775
|
* be cast to the object array's data type. For example: <em>SomeClass[]
|
7806
7776
|
* items = (SomeClass[]) expand(originalArray)</em>.
|
@@ -7811,85 +7781,85 @@ public class PApplet implements PConstants {
|
|
7811
7781
|
* @param list the array to expand
|
7812
7782
|
* @see PApplet#shorten(boolean[])
|
7813
7783
|
*/
|
7814
|
-
static public boolean[] expand(boolean list
|
7784
|
+
static public boolean[] expand(boolean[] list) {
|
7815
7785
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7816
7786
|
}
|
7817
7787
|
|
7818
7788
|
/**
|
7819
7789
|
* @param newSize new size for the array
|
7820
7790
|
*/
|
7821
|
-
static public boolean[] expand(boolean list
|
7822
|
-
boolean
|
7791
|
+
static public boolean[] expand(boolean[] list, int newSize) {
|
7792
|
+
boolean[] temp = new boolean[newSize];
|
7823
7793
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7824
7794
|
return temp;
|
7825
7795
|
}
|
7826
7796
|
|
7827
|
-
static public byte[] expand(byte list
|
7797
|
+
static public byte[] expand(byte[] list) {
|
7828
7798
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7829
7799
|
}
|
7830
7800
|
|
7831
|
-
static public byte[] expand(byte list
|
7832
|
-
byte
|
7801
|
+
static public byte[] expand(byte[] list, int newSize) {
|
7802
|
+
byte[] temp = new byte[newSize];
|
7833
7803
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7834
7804
|
return temp;
|
7835
7805
|
}
|
7836
7806
|
|
7837
|
-
static public char[] expand(char list
|
7807
|
+
static public char[] expand(char[] list) {
|
7838
7808
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7839
7809
|
}
|
7840
7810
|
|
7841
|
-
static public char[] expand(char list
|
7842
|
-
char
|
7811
|
+
static public char[] expand(char[] list, int newSize) {
|
7812
|
+
char[] temp = new char[newSize];
|
7843
7813
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7844
7814
|
return temp;
|
7845
7815
|
}
|
7846
7816
|
|
7847
|
-
static public int[] expand(int list
|
7817
|
+
static public int[] expand(int[] list) {
|
7848
7818
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7849
7819
|
}
|
7850
7820
|
|
7851
|
-
static public int[] expand(int list
|
7852
|
-
int
|
7821
|
+
static public int[] expand(int[] list, int newSize) {
|
7822
|
+
int[] temp = new int[newSize];
|
7853
7823
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7854
7824
|
return temp;
|
7855
7825
|
}
|
7856
7826
|
|
7857
|
-
static public long[] expand(long list
|
7827
|
+
static public long[] expand(long[] list) {
|
7858
7828
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7859
7829
|
}
|
7860
7830
|
|
7861
|
-
static public long[] expand(long list
|
7862
|
-
long
|
7831
|
+
static public long[] expand(long[] list, int newSize) {
|
7832
|
+
long[] temp = new long[newSize];
|
7863
7833
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7864
7834
|
return temp;
|
7865
7835
|
}
|
7866
7836
|
|
7867
|
-
static public float[] expand(float list
|
7837
|
+
static public float[] expand(float[] list) {
|
7868
7838
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7869
7839
|
}
|
7870
7840
|
|
7871
|
-
static public float[] expand(float list
|
7872
|
-
float
|
7841
|
+
static public float[] expand(float[] list, int newSize) {
|
7842
|
+
float[] temp = new float[newSize];
|
7873
7843
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7874
7844
|
return temp;
|
7875
7845
|
}
|
7876
7846
|
|
7877
|
-
static public double[] expand(double list
|
7847
|
+
static public double[] expand(double[] list) {
|
7878
7848
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7879
7849
|
}
|
7880
7850
|
|
7881
|
-
static public double[] expand(double list
|
7882
|
-
double
|
7851
|
+
static public double[] expand(double[] list, int newSize) {
|
7852
|
+
double[] temp = new double[newSize];
|
7883
7853
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7884
7854
|
return temp;
|
7885
7855
|
}
|
7886
7856
|
|
7887
|
-
static public String[] expand(String list
|
7857
|
+
static public String[] expand(String[] list) {
|
7888
7858
|
return expand(list, list.length > 0 ? list.length << 1 : 1);
|
7889
7859
|
}
|
7890
7860
|
|
7891
|
-
static public String[] expand(String list
|
7892
|
-
String
|
7861
|
+
static public String[] expand(String[] list, int newSize) {
|
7862
|
+
String[] temp = new String[newSize];
|
7893
7863
|
// in case the new size is smaller than list.length
|
7894
7864
|
System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
|
7895
7865
|
return temp;
|
@@ -7920,7 +7890,7 @@ public class PApplet implements PConstants {
|
|
7920
7890
|
* Expands an array by one element and adds data to the new position. The
|
7921
7891
|
* datatype of the <b>element</b> parameter must be the same as the
|
7922
7892
|
* datatype of the array.
|
7923
|
-
*
|
7893
|
+
*
|
7924
7894
|
* When using an array of objects, the data returned from the function must
|
7925
7895
|
* be cast to the object array's data type. For example: <em>SomeClass[]
|
7926
7896
|
* items = (SomeClass[]) append(originalArray, element)</em>.
|
@@ -7933,31 +7903,31 @@ public class PApplet implements PConstants {
|
|
7933
7903
|
* @see PApplet#shorten(boolean[])
|
7934
7904
|
* @see PApplet#expand(boolean[])
|
7935
7905
|
*/
|
7936
|
-
static public byte[] append(byte array
|
7906
|
+
static public byte[] append(byte[] array, byte value) {
|
7937
7907
|
array = expand(array, array.length + 1);
|
7938
7908
|
array[array.length-1] = value;
|
7939
7909
|
return array;
|
7940
7910
|
}
|
7941
7911
|
|
7942
|
-
static public char[] append(char array
|
7912
|
+
static public char[] append(char[] array, char value) {
|
7943
7913
|
array = expand(array, array.length + 1);
|
7944
7914
|
array[array.length-1] = value;
|
7945
7915
|
return array;
|
7946
7916
|
}
|
7947
7917
|
|
7948
|
-
static public int[] append(int array
|
7918
|
+
static public int[] append(int[] array, int value) {
|
7949
7919
|
array = expand(array, array.length + 1);
|
7950
7920
|
array[array.length-1] = value;
|
7951
7921
|
return array;
|
7952
7922
|
}
|
7953
7923
|
|
7954
|
-
static public float[] append(float array
|
7924
|
+
static public float[] append(float[] array, float value) {
|
7955
7925
|
array = expand(array, array.length + 1);
|
7956
7926
|
array[array.length-1] = value;
|
7957
7927
|
return array;
|
7958
7928
|
}
|
7959
7929
|
|
7960
|
-
static public String[] append(String array
|
7930
|
+
static public String[] append(String[] array, String value) {
|
7961
7931
|
array = expand(array, array.length + 1);
|
7962
7932
|
array[array.length-1] = value;
|
7963
7933
|
return array;
|
@@ -7975,7 +7945,7 @@ public class PApplet implements PConstants {
|
|
7975
7945
|
* ( begin auto-generated from shorten.xml )
|
7976
7946
|
*
|
7977
7947
|
* Decreases an array by one element and returns the shortened array.
|
7978
|
-
*
|
7948
|
+
*
|
7979
7949
|
* When using an array of objects, the data returned from the function must
|
7980
7950
|
* be cast to the object array's data type. For example: <em>SomeClass[]
|
7981
7951
|
* items = (SomeClass[]) shorten(originalArray)</em>.
|
@@ -7987,27 +7957,27 @@ public class PApplet implements PConstants {
|
|
7987
7957
|
* @see PApplet#append(byte[], byte)
|
7988
7958
|
* @see PApplet#expand(boolean[])
|
7989
7959
|
*/
|
7990
|
-
static public boolean[] shorten(boolean list
|
7960
|
+
static public boolean[] shorten(boolean[] list) {
|
7991
7961
|
return subset(list, 0, list.length-1);
|
7992
7962
|
}
|
7993
7963
|
|
7994
|
-
static public byte[] shorten(byte list
|
7964
|
+
static public byte[] shorten(byte[] list) {
|
7995
7965
|
return subset(list, 0, list.length-1);
|
7996
7966
|
}
|
7997
7967
|
|
7998
|
-
static public char[] shorten(char list
|
7968
|
+
static public char[] shorten(char[] list) {
|
7999
7969
|
return subset(list, 0, list.length-1);
|
8000
7970
|
}
|
8001
7971
|
|
8002
|
-
static public int[] shorten(int list
|
7972
|
+
static public int[] shorten(int[] list) {
|
8003
7973
|
return subset(list, 0, list.length-1);
|
8004
7974
|
}
|
8005
7975
|
|
8006
|
-
static public float[] shorten(float list
|
7976
|
+
static public float[] shorten(float[] list) {
|
8007
7977
|
return subset(list, 0, list.length-1);
|
8008
7978
|
}
|
8009
7979
|
|
8010
|
-
static public String[] shorten(String list
|
7980
|
+
static public String[] shorten(String[] list) {
|
8011
7981
|
return subset(list, 0, list.length-1);
|
8012
7982
|
}
|
8013
7983
|
|
@@ -8024,7 +7994,7 @@ public class PApplet implements PConstants {
|
|
8024
7994
|
* parameters must be of the same datatype. The <b>array</b> parameter
|
8025
7995
|
* defines the array which will be modified and the second parameter
|
8026
7996
|
* defines the data which will be inserted.
|
8027
|
-
*
|
7997
|
+
*
|
8028
7998
|
* When using an array of objects, the data returned from the function must
|
8029
7999
|
* be cast to the object array's data type. For example: <em>SomeClass[]
|
8030
8000
|
* items = (SomeClass[]) splice(array1, array2, index)</em>.
|
@@ -8037,9 +8007,9 @@ public class PApplet implements PConstants {
|
|
8037
8007
|
* @see PApplet#concat(boolean[], boolean[])
|
8038
8008
|
* @see PApplet#subset(boolean[], int, int)
|
8039
8009
|
*/
|
8040
|
-
static final public boolean[] splice(boolean list
|
8010
|
+
static final public boolean[] splice(boolean[] list,
|
8041
8011
|
boolean value, int index) {
|
8042
|
-
boolean
|
8012
|
+
boolean[] outgoing = new boolean[list.length + 1];
|
8043
8013
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8044
8014
|
outgoing[index] = value;
|
8045
8015
|
System.arraycopy(list, index, outgoing, index + 1,
|
@@ -8047,9 +8017,9 @@ public class PApplet implements PConstants {
|
|
8047
8017
|
return outgoing;
|
8048
8018
|
}
|
8049
8019
|
|
8050
|
-
static final public boolean[] splice(boolean list
|
8051
|
-
boolean value
|
8052
|
-
boolean
|
8020
|
+
static final public boolean[] splice(boolean[] list,
|
8021
|
+
boolean[] value, int index) {
|
8022
|
+
boolean[] outgoing = new boolean[list.length + value.length];
|
8053
8023
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8054
8024
|
System.arraycopy(value, 0, outgoing, index, value.length);
|
8055
8025
|
System.arraycopy(list, index, outgoing, index + value.length,
|
@@ -8057,9 +8027,9 @@ public class PApplet implements PConstants {
|
|
8057
8027
|
return outgoing;
|
8058
8028
|
}
|
8059
8029
|
|
8060
|
-
static final public byte[] splice(byte list
|
8030
|
+
static final public byte[] splice(byte[] list,
|
8061
8031
|
byte value, int index) {
|
8062
|
-
byte
|
8032
|
+
byte[] outgoing = new byte[list.length + 1];
|
8063
8033
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8064
8034
|
outgoing[index] = value;
|
8065
8035
|
System.arraycopy(list, index, outgoing, index + 1,
|
@@ -8067,9 +8037,9 @@ public class PApplet implements PConstants {
|
|
8067
8037
|
return outgoing;
|
8068
8038
|
}
|
8069
8039
|
|
8070
|
-
static final public byte[] splice(byte list
|
8071
|
-
byte value
|
8072
|
-
byte
|
8040
|
+
static final public byte[] splice(byte[] list,
|
8041
|
+
byte[] value, int index) {
|
8042
|
+
byte[] outgoing = new byte[list.length + value.length];
|
8073
8043
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8074
8044
|
System.arraycopy(value, 0, outgoing, index, value.length);
|
8075
8045
|
System.arraycopy(list, index, outgoing, index + value.length,
|
@@ -8078,9 +8048,9 @@ public class PApplet implements PConstants {
|
|
8078
8048
|
}
|
8079
8049
|
|
8080
8050
|
|
8081
|
-
static final public char[] splice(char list
|
8051
|
+
static final public char[] splice(char[] list,
|
8082
8052
|
char value, int index) {
|
8083
|
-
char
|
8053
|
+
char[] outgoing = new char[list.length + 1];
|
8084
8054
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8085
8055
|
outgoing[index] = value;
|
8086
8056
|
System.arraycopy(list, index, outgoing, index + 1,
|
@@ -8088,9 +8058,9 @@ public class PApplet implements PConstants {
|
|
8088
8058
|
return outgoing;
|
8089
8059
|
}
|
8090
8060
|
|
8091
|
-
static final public char[] splice(char list
|
8092
|
-
char value
|
8093
|
-
char
|
8061
|
+
static final public char[] splice(char[] list,
|
8062
|
+
char[] value, int index) {
|
8063
|
+
char[] outgoing = new char[list.length + value.length];
|
8094
8064
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8095
8065
|
System.arraycopy(value, 0, outgoing, index, value.length);
|
8096
8066
|
System.arraycopy(list, index, outgoing, index + value.length,
|
@@ -8098,9 +8068,9 @@ public class PApplet implements PConstants {
|
|
8098
8068
|
return outgoing;
|
8099
8069
|
}
|
8100
8070
|
|
8101
|
-
static final public int[] splice(int list
|
8071
|
+
static final public int[] splice(int[] list,
|
8102
8072
|
int value, int index) {
|
8103
|
-
int
|
8073
|
+
int[] outgoing = new int[list.length + 1];
|
8104
8074
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8105
8075
|
outgoing[index] = value;
|
8106
8076
|
System.arraycopy(list, index, outgoing, index + 1,
|
@@ -8108,9 +8078,9 @@ public class PApplet implements PConstants {
|
|
8108
8078
|
return outgoing;
|
8109
8079
|
}
|
8110
8080
|
|
8111
|
-
static final public int[] splice(int list
|
8112
|
-
int value
|
8113
|
-
int
|
8081
|
+
static final public int[] splice(int[] list,
|
8082
|
+
int[] value, int index) {
|
8083
|
+
int[] outgoing = new int[list.length + value.length];
|
8114
8084
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8115
8085
|
System.arraycopy(value, 0, outgoing, index, value.length);
|
8116
8086
|
System.arraycopy(list, index, outgoing, index + value.length,
|
@@ -8118,9 +8088,9 @@ public class PApplet implements PConstants {
|
|
8118
8088
|
return outgoing;
|
8119
8089
|
}
|
8120
8090
|
|
8121
|
-
static final public float[] splice(float list
|
8091
|
+
static final public float[] splice(float[] list,
|
8122
8092
|
float value, int index) {
|
8123
|
-
float
|
8093
|
+
float[] outgoing = new float[list.length + 1];
|
8124
8094
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8125
8095
|
outgoing[index] = value;
|
8126
8096
|
System.arraycopy(list, index, outgoing, index + 1,
|
@@ -8128,9 +8098,9 @@ public class PApplet implements PConstants {
|
|
8128
8098
|
return outgoing;
|
8129
8099
|
}
|
8130
8100
|
|
8131
|
-
static final public float[] splice(float list
|
8132
|
-
float value
|
8133
|
-
float
|
8101
|
+
static final public float[] splice(float[] list,
|
8102
|
+
float[] value, int index) {
|
8103
|
+
float[] outgoing = new float[list.length + value.length];
|
8134
8104
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8135
8105
|
System.arraycopy(value, 0, outgoing, index, value.length);
|
8136
8106
|
System.arraycopy(list, index, outgoing, index + value.length,
|
@@ -8138,9 +8108,9 @@ public class PApplet implements PConstants {
|
|
8138
8108
|
return outgoing;
|
8139
8109
|
}
|
8140
8110
|
|
8141
|
-
static final public String[] splice(String list
|
8111
|
+
static final public String[] splice(String[] list,
|
8142
8112
|
String value, int index) {
|
8143
|
-
String
|
8113
|
+
String[] outgoing = new String[list.length + 1];
|
8144
8114
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8145
8115
|
outgoing[index] = value;
|
8146
8116
|
System.arraycopy(list, index, outgoing, index + 1,
|
@@ -8148,9 +8118,9 @@ public class PApplet implements PConstants {
|
|
8148
8118
|
return outgoing;
|
8149
8119
|
}
|
8150
8120
|
|
8151
|
-
static final public String[] splice(String list
|
8152
|
-
String value
|
8153
|
-
String
|
8121
|
+
static final public String[] splice(String[] list,
|
8122
|
+
String[] value, int index) {
|
8123
|
+
String[] outgoing = new String[list.length + value.length];
|
8154
8124
|
System.arraycopy(list, 0, outgoing, 0, index);
|
8155
8125
|
System.arraycopy(value, 0, outgoing, index, value.length);
|
8156
8126
|
System.arraycopy(list, index, outgoing, index + value.length,
|
@@ -8196,7 +8166,7 @@ public class PApplet implements PConstants {
|
|
8196
8166
|
* from the <b>offset</b> to the end of the array. When specifying the
|
8197
8167
|
* <b>offset</b> remember the first array element is 0. This function does
|
8198
8168
|
* not change the source array.
|
8199
|
-
*
|
8169
|
+
*
|
8200
8170
|
* When using an array of objects, the data returned from the function must
|
8201
8171
|
* be cast to the object array's data type. For example: <em>SomeClass[]
|
8202
8172
|
* items = (SomeClass[]) subset(originalArray, 0, 4)</em>.
|
@@ -8319,7 +8289,7 @@ public class PApplet implements PConstants {
|
|
8319
8289
|
* Concatenates two arrays. For example, concatenating the array { 1, 2, 3
|
8320
8290
|
* } and the array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters
|
8321
8291
|
* must be arrays of the same datatype.
|
8322
|
-
*
|
8292
|
+
*
|
8323
8293
|
* When using an array of objects, the data returned from the function must
|
8324
8294
|
* be cast to the object array's data type. For example: <em>SomeClass[]
|
8325
8295
|
* items = (SomeClass[]) concat(array1, array2)</em>.
|
@@ -8331,43 +8301,43 @@ public class PApplet implements PConstants {
|
|
8331
8301
|
* @see PApplet#splice(boolean[], boolean, int)
|
8332
8302
|
* @see PApplet#arrayCopy(Object, int, Object, int, int)
|
8333
8303
|
*/
|
8334
|
-
static public boolean[] concat(boolean a
|
8335
|
-
boolean
|
8304
|
+
static public boolean[] concat(boolean[] a, boolean[] b) {
|
8305
|
+
boolean[] c = new boolean[a.length + b.length];
|
8336
8306
|
System.arraycopy(a, 0, c, 0, a.length);
|
8337
8307
|
System.arraycopy(b, 0, c, a.length, b.length);
|
8338
8308
|
return c;
|
8339
8309
|
}
|
8340
8310
|
|
8341
|
-
static public byte[] concat(byte a
|
8342
|
-
byte
|
8311
|
+
static public byte[] concat(byte[] a, byte[] b) {
|
8312
|
+
byte[] c = new byte[a.length + b.length];
|
8343
8313
|
System.arraycopy(a, 0, c, 0, a.length);
|
8344
8314
|
System.arraycopy(b, 0, c, a.length, b.length);
|
8345
8315
|
return c;
|
8346
8316
|
}
|
8347
8317
|
|
8348
|
-
static public char[] concat(char a
|
8349
|
-
char
|
8318
|
+
static public char[] concat(char[] a, char[] b) {
|
8319
|
+
char[] c = new char[a.length + b.length];
|
8350
8320
|
System.arraycopy(a, 0, c, 0, a.length);
|
8351
8321
|
System.arraycopy(b, 0, c, a.length, b.length);
|
8352
8322
|
return c;
|
8353
8323
|
}
|
8354
8324
|
|
8355
|
-
static public int[] concat(int a
|
8356
|
-
int
|
8325
|
+
static public int[] concat(int[] a, int[] b) {
|
8326
|
+
int[] c = new int[a.length + b.length];
|
8357
8327
|
System.arraycopy(a, 0, c, 0, a.length);
|
8358
8328
|
System.arraycopy(b, 0, c, a.length, b.length);
|
8359
8329
|
return c;
|
8360
8330
|
}
|
8361
8331
|
|
8362
|
-
static public float[] concat(float a
|
8363
|
-
float
|
8332
|
+
static public float[] concat(float[] a, float[] b) {
|
8333
|
+
float[] c = new float[a.length + b.length];
|
8364
8334
|
System.arraycopy(a, 0, c, 0, a.length);
|
8365
8335
|
System.arraycopy(b, 0, c, a.length, b.length);
|
8366
8336
|
return c;
|
8367
8337
|
}
|
8368
8338
|
|
8369
|
-
static public String[] concat(String a
|
8370
|
-
String
|
8339
|
+
static public String[] concat(String[] a, String[] b) {
|
8340
|
+
String[] c = new String[a.length + b.length];
|
8371
8341
|
System.arraycopy(a, 0, c, 0, a.length);
|
8372
8342
|
System.arraycopy(b, 0, c, a.length, b.length);
|
8373
8343
|
return c;
|
@@ -8396,8 +8366,8 @@ public class PApplet implements PConstants {
|
|
8396
8366
|
* @param list booleans[], bytes[], chars[], ints[], floats[], or Strings[]
|
8397
8367
|
* @see PApplet#sort(String[], int)
|
8398
8368
|
*/
|
8399
|
-
static public boolean[] reverse(boolean list
|
8400
|
-
boolean
|
8369
|
+
static public boolean[] reverse(boolean[] list) {
|
8370
|
+
boolean[] outgoing = new boolean[list.length];
|
8401
8371
|
int length1 = list.length - 1;
|
8402
8372
|
for (int i = 0; i < list.length; i++) {
|
8403
8373
|
outgoing[i] = list[length1 - i];
|
@@ -8405,8 +8375,8 @@ public class PApplet implements PConstants {
|
|
8405
8375
|
return outgoing;
|
8406
8376
|
}
|
8407
8377
|
|
8408
|
-
static public byte[] reverse(byte list
|
8409
|
-
byte
|
8378
|
+
static public byte[] reverse(byte[] list) {
|
8379
|
+
byte[] outgoing = new byte[list.length];
|
8410
8380
|
int length1 = list.length - 1;
|
8411
8381
|
for (int i = 0; i < list.length; i++) {
|
8412
8382
|
outgoing[i] = list[length1 - i];
|
@@ -8414,8 +8384,8 @@ public class PApplet implements PConstants {
|
|
8414
8384
|
return outgoing;
|
8415
8385
|
}
|
8416
8386
|
|
8417
|
-
static public char[] reverse(char list
|
8418
|
-
char
|
8387
|
+
static public char[] reverse(char[] list) {
|
8388
|
+
char[] outgoing = new char[list.length];
|
8419
8389
|
int length1 = list.length - 1;
|
8420
8390
|
for (int i = 0; i < list.length; i++) {
|
8421
8391
|
outgoing[i] = list[length1 - i];
|
@@ -8423,8 +8393,8 @@ public class PApplet implements PConstants {
|
|
8423
8393
|
return outgoing;
|
8424
8394
|
}
|
8425
8395
|
|
8426
|
-
static public int[] reverse(int list
|
8427
|
-
int
|
8396
|
+
static public int[] reverse(int[] list) {
|
8397
|
+
int[] outgoing = new int[list.length];
|
8428
8398
|
int length1 = list.length - 1;
|
8429
8399
|
for (int i = 0; i < list.length; i++) {
|
8430
8400
|
outgoing[i] = list[length1 - i];
|
@@ -8432,8 +8402,8 @@ public class PApplet implements PConstants {
|
|
8432
8402
|
return outgoing;
|
8433
8403
|
}
|
8434
8404
|
|
8435
|
-
static public float[] reverse(float list
|
8436
|
-
float
|
8405
|
+
static public float[] reverse(float[] list) {
|
8406
|
+
float[] outgoing = new float[list.length];
|
8437
8407
|
int length1 = list.length - 1;
|
8438
8408
|
for (int i = 0; i < list.length; i++) {
|
8439
8409
|
outgoing[i] = list[length1 - i];
|
@@ -8441,8 +8411,8 @@ public class PApplet implements PConstants {
|
|
8441
8411
|
return outgoing;
|
8442
8412
|
}
|
8443
8413
|
|
8444
|
-
static public String[] reverse(String list
|
8445
|
-
String
|
8414
|
+
static public String[] reverse(String[] list) {
|
8415
|
+
String[] outgoing = new String[list.length];
|
8446
8416
|
int length1 = list.length - 1;
|
8447
8417
|
for (int i = 0; i < list.length; i++) {
|
8448
8418
|
outgoing[i] = list[length1 - i];
|
@@ -8548,7 +8518,7 @@ public class PApplet implements PConstants {
|
|
8548
8518
|
* The splitTokens() function splits a String at one or many character
|
8549
8519
|
* "tokens." The <b>tokens</b> parameter specifies the character or
|
8550
8520
|
* characters to be used as a boundary.
|
8551
|
-
*
|
8521
|
+
*
|
8552
8522
|
* If no <b>tokens</b> character is specified, any whitespace character is
|
8553
8523
|
* used to split. Whitespace characters include tab (\\t), line feed (\\n),
|
8554
8524
|
* carriage return (\\r), form feed (\\f), and space. To convert a String
|
@@ -8565,7 +8535,7 @@ public class PApplet implements PConstants {
|
|
8565
8535
|
*/
|
8566
8536
|
static public String[] splitTokens(String value, String delim) {
|
8567
8537
|
StringTokenizer toker = new StringTokenizer(value, delim);
|
8568
|
-
String
|
8538
|
+
String[] pieces = new String[toker.countTokens()];
|
8569
8539
|
|
8570
8540
|
int index = 0;
|
8571
8541
|
while (toker.hasMoreTokens()) {
|
@@ -8582,11 +8552,11 @@ public class PApplet implements PConstants {
|
|
8582
8552
|
* string as the divider. The <b>delim</b> parameter specifies the
|
8583
8553
|
* character or characters that mark the boundaries between each piece. A
|
8584
8554
|
* String[] array is returned that contains each of the pieces.
|
8585
|
-
*
|
8555
|
+
*
|
8586
8556
|
* If the result is a set of numbers, you can convert the String[] array to
|
8587
8557
|
* to a float[] or int[] array using the datatype conversion functions
|
8588
8558
|
* <b>int()</b> and <b>float()</b> (see example above).
|
8589
|
-
*
|
8559
|
+
*
|
8590
8560
|
* The <b>splitTokens()</b> function works in a similar fashion, except
|
8591
8561
|
* that it splits using a range of characters instead of a specific
|
8592
8562
|
* character or sequence.
|
@@ -8615,10 +8585,10 @@ public class PApplet implements PConstants {
|
|
8615
8585
|
if (value == null) return null;
|
8616
8586
|
//return split(what, String.valueOf(delim)); // huh
|
8617
8587
|
|
8618
|
-
char
|
8588
|
+
char[] chars = value.toCharArray();
|
8619
8589
|
int splitCount = 0; //1;
|
8620
|
-
for (
|
8621
|
-
if (
|
8590
|
+
for (char ch : chars) {
|
8591
|
+
if (ch == delim) splitCount++;
|
8622
8592
|
}
|
8623
8593
|
// make sure that there is something in the input string
|
8624
8594
|
//if (chars.length > 0) {
|
@@ -8627,12 +8597,12 @@ public class PApplet implements PConstants {
|
|
8627
8597
|
// on second thought, i don't agree with this, will disable
|
8628
8598
|
//}
|
8629
8599
|
if (splitCount == 0) {
|
8630
|
-
String
|
8600
|
+
String[] splits = new String[1];
|
8631
8601
|
splits[0] = value;
|
8632
8602
|
return splits;
|
8633
8603
|
}
|
8634
8604
|
//int pieceCount = splitCount + 1;
|
8635
|
-
String
|
8605
|
+
String[] splits = new String[splitCount + 1];
|
8636
8606
|
int splitIndex = 0;
|
8637
8607
|
int startIndex = 0;
|
8638
8608
|
for (int i = 0; i < chars.length; i++) {
|
@@ -8670,7 +8640,7 @@ public class PApplet implements PConstants {
|
|
8670
8640
|
static Pattern matchPattern(String regexp) {
|
8671
8641
|
Pattern p = null;
|
8672
8642
|
if (matchPatterns == null) {
|
8673
|
-
matchPatterns = new LinkedHashMap
|
8643
|
+
matchPatterns = new LinkedHashMap<>(16, 0.75f, true) {
|
8674
8644
|
@Override
|
8675
8645
|
protected boolean removeEldestEntry(Map.Entry<String, Pattern> eldest) {
|
8676
8646
|
// Limit the number of match patterns at 10 most recently used
|
@@ -8873,8 +8843,8 @@ public class PApplet implements PConstants {
|
|
8873
8843
|
* to zero will return false, and any other value will return true.
|
8874
8844
|
* @return array of boolean elements
|
8875
8845
|
*/
|
8876
|
-
static final public boolean[] parseBoolean(int what
|
8877
|
-
boolean
|
8846
|
+
static final public boolean[] parseBoolean(int[] what) {
|
8847
|
+
boolean[] outgoing = new boolean[what.length];
|
8878
8848
|
for (int i = 0; i < what.length; i++) {
|
8879
8849
|
outgoing[i] = (what[i] != 0);
|
8880
8850
|
}
|
@@ -8892,8 +8862,8 @@ public class PApplet implements PConstants {
|
|
8892
8862
|
}
|
8893
8863
|
*/
|
8894
8864
|
|
8895
|
-
static final public boolean[] parseBoolean(String what
|
8896
|
-
boolean
|
8865
|
+
static final public boolean[] parseBoolean(String[] what) {
|
8866
|
+
boolean[] outgoing = new boolean[what.length];
|
8897
8867
|
for (int i = 0; i < what.length; i++) {
|
8898
8868
|
outgoing[i] = Boolean.parseBoolean(what[i]);
|
8899
8869
|
}
|
@@ -8927,32 +8897,32 @@ public class PApplet implements PConstants {
|
|
8927
8897
|
|
8928
8898
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
8929
8899
|
|
8930
|
-
static final public byte[] parseByte(boolean what
|
8931
|
-
byte
|
8900
|
+
static final public byte[] parseByte(boolean[] what) {
|
8901
|
+
byte[] outgoing = new byte[what.length];
|
8932
8902
|
for (int i = 0; i < what.length; i++) {
|
8933
8903
|
outgoing[i] = what[i] ? (byte)1 : 0;
|
8934
8904
|
}
|
8935
8905
|
return outgoing;
|
8936
8906
|
}
|
8937
8907
|
|
8938
|
-
static final public byte[] parseByte(char what
|
8939
|
-
byte
|
8908
|
+
static final public byte[] parseByte(char[] what) {
|
8909
|
+
byte[] outgoing = new byte[what.length];
|
8940
8910
|
for (int i = 0; i < what.length; i++) {
|
8941
8911
|
outgoing[i] = (byte) what[i];
|
8942
8912
|
}
|
8943
8913
|
return outgoing;
|
8944
8914
|
}
|
8945
8915
|
|
8946
|
-
static final public byte[] parseByte(int what
|
8947
|
-
byte
|
8916
|
+
static final public byte[] parseByte(int[] what) {
|
8917
|
+
byte[] outgoing = new byte[what.length];
|
8948
8918
|
for (int i = 0; i < what.length; i++) {
|
8949
8919
|
outgoing[i] = (byte) what[i];
|
8950
8920
|
}
|
8951
8921
|
return outgoing;
|
8952
8922
|
}
|
8953
8923
|
|
8954
|
-
static final public byte[] parseByte(float what
|
8955
|
-
byte
|
8924
|
+
static final public byte[] parseByte(float[] what) {
|
8925
|
+
byte[] outgoing = new byte[what.length];
|
8956
8926
|
for (int i = 0; i < what.length; i++) {
|
8957
8927
|
outgoing[i] = (byte) what[i];
|
8958
8928
|
}
|
@@ -9007,8 +8977,8 @@ public class PApplet implements PConstants {
|
|
9007
8977
|
}
|
9008
8978
|
*/
|
9009
8979
|
|
9010
|
-
static final public char[] parseChar(byte what
|
9011
|
-
char
|
8980
|
+
static final public char[] parseChar(byte[] what) {
|
8981
|
+
char[] outgoing = new char[what.length];
|
9012
8982
|
for (int i = 0; i < what.length; i++) {
|
9013
8983
|
outgoing[i] = (char) (what[i] & 0xff);
|
9014
8984
|
}
|
@@ -9024,8 +8994,8 @@ public class PApplet implements PConstants {
|
|
9024
8994
|
}
|
9025
8995
|
|
9026
8996
|
/*
|
9027
|
-
static final public char[] parseChar(
|
9028
|
-
char
|
8997
|
+
static final public char[] parseChar(int[] what) {
|
8998
|
+
char[] outgoing = new char[what.length];
|
9029
8999
|
for (int i = 0; i < what.length; i++) {
|
9030
9000
|
outgoing[i] = (char) what[i];
|
9031
9001
|
}
|
@@ -9095,32 +9065,32 @@ public class PApplet implements PConstants {
|
|
9095
9065
|
|
9096
9066
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
9097
9067
|
|
9098
|
-
static final public int[] parseInt(boolean what
|
9099
|
-
int
|
9068
|
+
static final public int[] parseInt(boolean[] what) {
|
9069
|
+
int[] list = new int[what.length];
|
9100
9070
|
for (int i = 0; i < what.length; i++) {
|
9101
9071
|
list[i] = what[i] ? 1 : 0;
|
9102
9072
|
}
|
9103
9073
|
return list;
|
9104
9074
|
}
|
9105
9075
|
|
9106
|
-
static final public int[] parseInt(byte what
|
9107
|
-
int
|
9076
|
+
static final public int[] parseInt(byte[] what) { // note this unsigns
|
9077
|
+
int[] list = new int[what.length];
|
9108
9078
|
for (int i = 0; i < what.length; i++) {
|
9109
9079
|
list[i] = (what[i] & 0xff);
|
9110
9080
|
}
|
9111
9081
|
return list;
|
9112
9082
|
}
|
9113
9083
|
|
9114
|
-
static final public int[] parseInt(char what
|
9115
|
-
int
|
9084
|
+
static final public int[] parseInt(char[] what) {
|
9085
|
+
int[] list = new int[what.length];
|
9116
9086
|
for (int i = 0; i < what.length; i++) {
|
9117
9087
|
list[i] = what[i];
|
9118
9088
|
}
|
9119
9089
|
return list;
|
9120
9090
|
}
|
9121
9091
|
|
9122
|
-
static public int[] parseInt(float what
|
9123
|
-
int
|
9092
|
+
static public int[] parseInt(float[] what) {
|
9093
|
+
int[] inties = new int[what.length];
|
9124
9094
|
for (int i = 0; i < what.length; i++) {
|
9125
9095
|
inties[i] = (int)what[i];
|
9126
9096
|
}
|
@@ -9136,7 +9106,7 @@ public class PApplet implements PConstants {
|
|
9136
9106
|
*
|
9137
9107
|
* numbers will contain { 1, 300, 44 }
|
9138
9108
|
*/
|
9139
|
-
static public int[] parseInt(String what
|
9109
|
+
static public int[] parseInt(String[] what) {
|
9140
9110
|
return parseInt(what, 0);
|
9141
9111
|
}
|
9142
9112
|
|
@@ -9150,8 +9120,8 @@ public class PApplet implements PConstants {
|
|
9150
9120
|
*
|
9151
9121
|
* numbers will contain { 1, 300, 9999, 44 }
|
9152
9122
|
*/
|
9153
|
-
static public int[] parseInt(String what
|
9154
|
-
int
|
9123
|
+
static public int[] parseInt(String[] what, int missing) {
|
9124
|
+
int[] output = new int[what.length];
|
9155
9125
|
for (int i = 0; i < what.length; i++) {
|
9156
9126
|
try {
|
9157
9127
|
output[i] = Integer.parseInt(what[i]);
|
@@ -9192,46 +9162,28 @@ public class PApplet implements PConstants {
|
|
9192
9162
|
|
9193
9163
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
9194
9164
|
|
9195
|
-
|
9196
|
-
|
9197
|
-
float floaties[] = new float[what.length];
|
9198
|
-
for (int i = 0; i < what.length; i++) {
|
9199
|
-
floaties[i] = what[i] ? 1 : 0;
|
9200
|
-
}
|
9201
|
-
return floaties;
|
9202
|
-
}
|
9203
|
-
|
9204
|
-
static final public float[] parseFloat(char what[]) {
|
9205
|
-
float floaties[] = new float[what.length];
|
9206
|
-
for (int i = 0; i < what.length; i++) {
|
9207
|
-
floaties[i] = (char) what[i];
|
9208
|
-
}
|
9209
|
-
return floaties;
|
9210
|
-
}
|
9211
|
-
*/
|
9212
|
-
|
9213
|
-
static final public float[] parseFloat(byte what[]) {
|
9214
|
-
float floaties[] = new float[what.length];
|
9165
|
+
static final public float[] parseFloat(byte[] what) {
|
9166
|
+
float[] floaties = new float[what.length];
|
9215
9167
|
for (int i = 0; i < what.length; i++) {
|
9216
9168
|
floaties[i] = what[i];
|
9217
9169
|
}
|
9218
9170
|
return floaties;
|
9219
9171
|
}
|
9220
9172
|
|
9221
|
-
static final public float[] parseFloat(int what
|
9222
|
-
float
|
9173
|
+
static final public float[] parseFloat(int[] what) {
|
9174
|
+
float[] floaties = new float[what.length];
|
9223
9175
|
for (int i = 0; i < what.length; i++) {
|
9224
9176
|
floaties[i] = what[i];
|
9225
9177
|
}
|
9226
9178
|
return floaties;
|
9227
9179
|
}
|
9228
9180
|
|
9229
|
-
static final public float[] parseFloat(String what
|
9181
|
+
static final public float[] parseFloat(String[] what) {
|
9230
9182
|
return parseFloat(what, Float.NaN);
|
9231
9183
|
}
|
9232
9184
|
|
9233
|
-
static final public float[] parseFloat(String what
|
9234
|
-
float
|
9185
|
+
static final public float[] parseFloat(String[] what, float missing) {
|
9186
|
+
float[] output = new float[what.length];
|
9235
9187
|
for (int i = 0; i < what.length; i++) {
|
9236
9188
|
try {
|
9237
9189
|
output[i] = Float.parseFloat(what[i]);
|
@@ -9266,32 +9218,32 @@ public class PApplet implements PConstants {
|
|
9266
9218
|
|
9267
9219
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
9268
9220
|
|
9269
|
-
static final public String[] str(boolean x
|
9270
|
-
String
|
9221
|
+
static final public String[] str(boolean[] x) {
|
9222
|
+
String[] s = new String[x.length];
|
9271
9223
|
for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
|
9272
9224
|
return s;
|
9273
9225
|
}
|
9274
9226
|
|
9275
|
-
static final public String[] str(byte x
|
9276
|
-
String
|
9227
|
+
static final public String[] str(byte[] x) {
|
9228
|
+
String[] s = new String[x.length];
|
9277
9229
|
for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
|
9278
9230
|
return s;
|
9279
9231
|
}
|
9280
9232
|
|
9281
|
-
static final public String[] str(char x
|
9282
|
-
String
|
9233
|
+
static final public String[] str(char[] x) {
|
9234
|
+
String[] s = new String[x.length];
|
9283
9235
|
for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
|
9284
9236
|
return s;
|
9285
9237
|
}
|
9286
9238
|
|
9287
|
-
static final public String[] str(int x
|
9288
|
-
String
|
9239
|
+
static final public String[] str(int[] x) {
|
9240
|
+
String[] s = new String[x.length];
|
9289
9241
|
for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
|
9290
9242
|
return s;
|
9291
9243
|
}
|
9292
9244
|
|
9293
|
-
static final public String[] str(float x
|
9294
|
-
String
|
9245
|
+
static final public String[] str(float[] x) {
|
9246
|
+
String[] s = new String[x.length];
|
9295
9247
|
for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
|
9296
9248
|
return s;
|
9297
9249
|
}
|
@@ -9348,8 +9300,8 @@ public class PApplet implements PConstants {
|
|
9348
9300
|
* @see <a href="https://processing.org/reference/intconvert_.html">int(float)</a>
|
9349
9301
|
*/
|
9350
9302
|
|
9351
|
-
static public String[] nf(int nums
|
9352
|
-
String
|
9303
|
+
static public String[] nf(int[] nums, int digits) {
|
9304
|
+
String[] formatted = new String[nums.length];
|
9353
9305
|
for (int i = 0; i < formatted.length; i++) {
|
9354
9306
|
formatted[i] = nf(nums[i], digits);
|
9355
9307
|
}
|
@@ -9381,7 +9333,7 @@ public class PApplet implements PConstants {
|
|
9381
9333
|
* appropriate commas to mark units of 1000. There are two versions, one
|
9382
9334
|
* for formatting ints and one for formatting an array of ints. The value
|
9383
9335
|
* for the <b>digits</b> parameter should always be a positive integer.
|
9384
|
-
*
|
9336
|
+
*
|
9385
9337
|
* For a non-US locale, this will insert periods instead of commas, or
|
9386
9338
|
* whatever is apprioriate for that region.
|
9387
9339
|
*
|
@@ -9392,8 +9344,8 @@ public class PApplet implements PConstants {
|
|
9392
9344
|
* @see PApplet#nfp(float, int, int)
|
9393
9345
|
* @see PApplet#nfs(float, int, int)
|
9394
9346
|
*/
|
9395
|
-
static public String[] nfc(int nums
|
9396
|
-
String
|
9347
|
+
static public String[] nfc(int[] nums) {
|
9348
|
+
String[] formatted = new String[nums.length];
|
9397
9349
|
for (int i = 0; i < formatted.length; i++) {
|
9398
9350
|
formatted[i] = nfc(nums[i]);
|
9399
9351
|
}
|
@@ -9452,8 +9404,8 @@ public class PApplet implements PConstants {
|
|
9452
9404
|
/**
|
9453
9405
|
* @param nums the numbers to format
|
9454
9406
|
*/
|
9455
|
-
static public String[] nfs(int nums
|
9456
|
-
String
|
9407
|
+
static public String[] nfs(int[] nums, int digits) {
|
9408
|
+
String[] formatted = new String[nums.length];
|
9457
9409
|
for (int i = 0; i < formatted.length; i++) {
|
9458
9410
|
formatted[i] = nfs(nums[i], digits);
|
9459
9411
|
}
|
@@ -9490,8 +9442,8 @@ public class PApplet implements PConstants {
|
|
9490
9442
|
/**
|
9491
9443
|
* @param nums the numbers to format
|
9492
9444
|
*/
|
9493
|
-
static public String[] nfp(int nums
|
9494
|
-
String
|
9445
|
+
static public String[] nfp(int[] nums, int digits) {
|
9446
|
+
String[] formatted = new String[nums.length];
|
9495
9447
|
for (int i = 0; i < formatted.length; i++) {
|
9496
9448
|
formatted[i] = nfp(nums[i], digits);
|
9497
9449
|
}
|
@@ -9512,8 +9464,8 @@ public class PApplet implements PConstants {
|
|
9512
9464
|
* @param left number of digits to the left of the decimal point
|
9513
9465
|
* @param right number of digits to the right of the decimal point
|
9514
9466
|
*/
|
9515
|
-
static public String[] nf(float nums
|
9516
|
-
String
|
9467
|
+
static public String[] nf(float[] nums, int left, int right) {
|
9468
|
+
String[] formatted = new String[nums.length];
|
9517
9469
|
for (int i = 0; i < formatted.length; i++) {
|
9518
9470
|
formatted[i] = nf(nums[i], left, right);
|
9519
9471
|
}
|
@@ -9545,8 +9497,8 @@ public class PApplet implements PConstants {
|
|
9545
9497
|
/**
|
9546
9498
|
* @param right number of digits to the right of the decimal point
|
9547
9499
|
*/
|
9548
|
-
static public String[] nfc(float nums
|
9549
|
-
String
|
9500
|
+
static public String[] nfc(float[] nums, int right) {
|
9501
|
+
String[] formatted = new String[nums.length];
|
9550
9502
|
for (int i = 0; i < formatted.length; i++) {
|
9551
9503
|
formatted[i] = nfc(nums[i], right);
|
9552
9504
|
}
|
@@ -9579,8 +9531,8 @@ public class PApplet implements PConstants {
|
|
9579
9531
|
* @param left the number of digits to the left of the decimal point
|
9580
9532
|
* @param right the number of digits to the right of the decimal point
|
9581
9533
|
*/
|
9582
|
-
static public String[] nfs(float nums
|
9583
|
-
String
|
9534
|
+
static public String[] nfs(float[] nums, int left, int right) {
|
9535
|
+
String[] formatted = new String[nums.length];
|
9584
9536
|
for (int i = 0; i < formatted.length; i++) {
|
9585
9537
|
formatted[i] = nfs(nums[i], left, right);
|
9586
9538
|
}
|
@@ -9595,8 +9547,8 @@ public class PApplet implements PConstants {
|
|
9595
9547
|
* @param left the number of digits to the left of the decimal point
|
9596
9548
|
* @param right the number of digits to the right of the decimal point
|
9597
9549
|
*/
|
9598
|
-
static public String[] nfp(float nums
|
9599
|
-
String
|
9550
|
+
static public String[] nfp(float[] nums, int left, int right) {
|
9551
|
+
String[] formatted = new String[nums.length];
|
9600
9552
|
for (int i = 0; i < formatted.length; i++) {
|
9601
9553
|
formatted[i] = nfp(nums[i], left, right);
|
9602
9554
|
}
|
@@ -9621,7 +9573,7 @@ public class PApplet implements PConstants {
|
|
9621
9573
|
* equivalent hexadecimal notation. For example color(0, 102, 153) will
|
9622
9574
|
* convert to the String "FF006699". This function can help make your geeky
|
9623
9575
|
* debugging sessions much happier.
|
9624
|
-
*
|
9576
|
+
*
|
9625
9577
|
* Note that the maximum number of digits is 8, because an int value can
|
9626
9578
|
* only represent up to 32 bits. Specifying more than eight digits will
|
9627
9579
|
* simply shorten the string to eight anyway.
|
@@ -9722,7 +9674,7 @@ public class PApplet implements PConstants {
|
|
9722
9674
|
* equivalent binary notation. For example color(0, 102, 153, 255) will
|
9723
9675
|
* convert to the String "11111111000000000110011010011001". This function
|
9724
9676
|
* can help make your geeky debugging sessions much happier.
|
9725
|
-
*
|
9677
|
+
*
|
9726
9678
|
* Note that the maximum number of digits is 32, because an int value can
|
9727
9679
|
* only represent up to 32 bits. Specifying more than 32 digits will simply
|
9728
9680
|
* shorten the string to 32 anyway.
|
@@ -10074,36 +10026,12 @@ public class PApplet implements PConstants {
|
|
10074
10026
|
}
|
10075
10027
|
|
10076
10028
|
|
10077
|
-
// Moving this back off the EDT for alpha 10. Not sure if we're helping
|
10078
|
-
// hurting, but unless we do, errors inside settings() are never passed
|
10029
|
+
// Moving this back off the EDT for 3.0 alpha 10. Not sure if we're helping
|
10030
|
+
// or hurting, but unless we do, errors inside settings() are never passed
|
10079
10031
|
// through to the PDE. There are other ways around that, no doubt, but I'm
|
10080
10032
|
// also suspecting that these "not showing up" bugs might be EDT issues.
|
10081
10033
|
static public void runSketch(final String[] args,
|
10082
10034
|
final PApplet constructedSketch) {
|
10083
|
-
// EventQueue.invokeLater(new Runnable() {
|
10084
|
-
// public void run() {
|
10085
|
-
// runSketchEDT(args, constructedSketch);
|
10086
|
-
// }
|
10087
|
-
// });
|
10088
|
-
// }
|
10089
|
-
//
|
10090
|
-
//
|
10091
|
-
// /**
|
10092
|
-
// * Moving this to the EDT for 3.0a6 because that's the proper thing to do
|
10093
|
-
// * when messing with Swing components. But mostly we're AWT, so who knows.
|
10094
|
-
// */
|
10095
|
-
// static protected void runSketchEDT(final String[] args,
|
10096
|
-
// final PApplet constructedSketch) {
|
10097
|
-
// Supposed to help with flicker, but no effect on OS X.
|
10098
|
-
// TODO IIRC this helped on Windows, but need to double check.
|
10099
|
-
System.setProperty("sun.awt.noerasebackground", "true");
|
10100
|
-
|
10101
|
-
// Remove 60fps limit on the JavaFX "pulse" timer
|
10102
|
-
System.setProperty("javafx.animation.fullspeed", "true");
|
10103
|
-
|
10104
|
-
// Doesn't seem to do anything helpful here (that can't be done via Runner)
|
10105
|
-
//System.setProperty("com.apple.mrj.application.apple.menu.about.name", "potato");
|
10106
|
-
|
10107
10035
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
10108
10036
|
public void uncaughtException(Thread t, Throwable e) {
|
10109
10037
|
e.printStackTrace();
|
@@ -10132,16 +10060,6 @@ public class PApplet implements PConstants {
|
|
10132
10060
|
}
|
10133
10061
|
*/
|
10134
10062
|
|
10135
|
-
// Catch any HeadlessException to provide more useful feedback
|
10136
|
-
try {
|
10137
|
-
// Call validate() while resize events are in progress
|
10138
|
-
Toolkit.getDefaultToolkit().setDynamicLayout(true);
|
10139
|
-
} catch (HeadlessException e) {
|
10140
|
-
System.err.println("Cannot run sketch without a display. Read this for possible solutions:");
|
10141
|
-
System.err.println("https://github.com/processing/processing/wiki/Running-without-a-Display");
|
10142
|
-
System.exit(1);
|
10143
|
-
}
|
10144
|
-
|
10145
10063
|
// So that the system proxy setting are used by default
|
10146
10064
|
System.setProperty("java.net.useSystemProxies", "true");
|
10147
10065
|
|
@@ -10188,6 +10106,9 @@ public class PApplet implements PConstants {
|
|
10188
10106
|
displayNum = -1; // use the default
|
10189
10107
|
}
|
10190
10108
|
|
10109
|
+
} else if (param.equals(ARGS_DISABLE_AWT)) {
|
10110
|
+
disableAWT = true;
|
10111
|
+
|
10191
10112
|
} else if (param.equals(ARGS_WINDOW_COLOR)) {
|
10192
10113
|
if (value.charAt(0) == '#' && value.length() == 7) {
|
10193
10114
|
value = value.substring(1);
|
@@ -10241,16 +10162,9 @@ public class PApplet implements PConstants {
|
|
10241
10162
|
argIndex++;
|
10242
10163
|
}
|
10243
10164
|
|
10244
|
-
|
10245
|
-
|
10246
|
-
|
10247
|
-
// // https://github.com/processing/processing/commit/0a14835e6f5f4766b022e73a8fe562318636727c
|
10248
|
-
// // TODO this is a hack added for PDE X and needs to be removed [fry 141104]
|
10249
|
-
// for (int i = 0; i < args.length; i++) {
|
10250
|
-
// if (args[i].startsWith(ARGS_SKETCH_FOLDER)){
|
10251
|
-
// folder = args[i].substring(args[i].indexOf('=') + 1);
|
10252
|
-
// }
|
10253
|
-
// }
|
10165
|
+
if (!disableAWT) {
|
10166
|
+
ShimAWT.initRun();
|
10167
|
+
}
|
10254
10168
|
|
10255
10169
|
final PApplet sketch;
|
10256
10170
|
if (constructedSketch != null) {
|
@@ -10269,14 +10183,16 @@ public class PApplet implements PConstants {
|
|
10269
10183
|
}
|
10270
10184
|
}
|
10271
10185
|
|
10272
|
-
|
10186
|
+
// TODO When disabling AWT for LWJGL or others, we need to figure out
|
10187
|
+
// how to make Cmd-Q and the rest of this still work properly.
|
10188
|
+
if (platform == MACOS && !disableAWT) {
|
10273
10189
|
try {
|
10274
10190
|
final String td = "processing.core.ThinkDifferent";
|
10275
10191
|
Class<?> thinkDifferent =
|
10276
10192
|
Thread.currentThread().getContextClassLoader().loadClass(td);
|
10277
10193
|
Method method =
|
10278
|
-
thinkDifferent.getMethod("init",
|
10279
|
-
method.invoke(null,
|
10194
|
+
thinkDifferent.getMethod("init", PApplet.class);
|
10195
|
+
method.invoke(null, sketch);
|
10280
10196
|
} catch (Exception e) {
|
10281
10197
|
e.printStackTrace(); // That's unfortunate
|
10282
10198
|
}
|
@@ -10309,25 +10225,7 @@ public class PApplet implements PConstants {
|
|
10309
10225
|
}
|
10310
10226
|
|
10311
10227
|
// Call the settings() method which will give us our size() call
|
10312
|
-
// try {
|
10313
10228
|
sketch.handleSettings();
|
10314
|
-
// } catch (Throwable t) {
|
10315
|
-
// System.err.println("I think I'm gonna hurl");
|
10316
|
-
// }
|
10317
|
-
|
10318
|
-
//// sketch.spanDisplays = spanDisplays;
|
10319
|
-
// // If spanning screens, that means we're also full screen.
|
10320
|
-
//// fullScreen |= spanDisplays;
|
10321
|
-
// if (spanDisplays) {
|
10322
|
-
// displayIndex = SPAN;
|
10323
|
-
//// fullScreen = true;
|
10324
|
-
// }
|
10325
|
-
|
10326
|
-
// // If the applet doesn't call for full screen, but the command line does,
|
10327
|
-
// // enable it. Conversely, if the command line does not, don't disable it.
|
10328
|
-
// // Query the applet to see if it wants to be full screen all the time.
|
10329
|
-
// //fullScreen |= sketch.sketchFullScreen();
|
10330
|
-
// sketch.fullScreen |= fullScreen;
|
10331
10229
|
|
10332
10230
|
sketch.external = external;
|
10333
10231
|
|
@@ -10336,22 +10234,6 @@ public class PApplet implements PConstants {
|
|
10336
10234
|
}
|
10337
10235
|
|
10338
10236
|
final PSurface surface = sketch.initSurface();
|
10339
|
-
// sketch.initSurface(windowColor, displayIndex, fullScreen, spanDisplays);
|
10340
|
-
|
10341
|
-
/*
|
10342
|
-
// Wait until the applet has figured out its width. In a static mode app,
|
10343
|
-
// everything happens inside setup(), so this will be after setup() has
|
10344
|
-
// completed, and the empty draw() has set "finished" to true.
|
10345
|
-
while (sketch.defaultSize && !sketch.finished) {
|
10346
|
-
//System.out.println("default size");
|
10347
|
-
try {
|
10348
|
-
Thread.sleep(5);
|
10349
|
-
|
10350
|
-
} catch (InterruptedException e) {
|
10351
|
-
//System.out.println("interrupt");
|
10352
|
-
}
|
10353
|
-
}
|
10354
|
-
*/
|
10355
10237
|
|
10356
10238
|
if (present) {
|
10357
10239
|
if (hideStop) {
|
@@ -10370,14 +10252,6 @@ public class PApplet implements PConstants {
|
|
10370
10252
|
|
10371
10253
|
sketch.showSurface();
|
10372
10254
|
sketch.startSurface();
|
10373
|
-
/*
|
10374
|
-
if (sketch.getGraphics().displayable()) {
|
10375
|
-
surface.setVisible(true);
|
10376
|
-
}
|
10377
|
-
|
10378
|
-
//sketch.init();
|
10379
|
-
surface.startThread();
|
10380
|
-
*/
|
10381
10255
|
}
|
10382
10256
|
|
10383
10257
|
|
@@ -10401,61 +10275,63 @@ public class PApplet implements PConstants {
|
|
10401
10275
|
|
10402
10276
|
// Create fake Frame object to warn user about the changes
|
10403
10277
|
if (g.displayable()) {
|
10404
|
-
|
10405
|
-
|
10406
|
-
|
10407
|
-
|
10408
|
-
|
10409
|
-
|
10410
|
-
|
10411
|
-
|
10412
|
-
public void setVisible(boolean visible) {
|
10413
|
-
deprecationWarning("setVisible");
|
10414
|
-
surface.setVisible(visible);
|
10415
|
-
}
|
10416
|
-
|
10417
|
-
@Override
|
10418
|
-
public void setTitle(String title) {
|
10419
|
-
deprecationWarning("setTitle");
|
10420
|
-
surface.setTitle(title);
|
10421
|
-
}
|
10422
|
-
|
10423
|
-
@Override
|
10424
|
-
public void setUndecorated(boolean ignored) {
|
10425
|
-
throw new RuntimeException("'frame' has been removed from Processing 3, " +
|
10426
|
-
"use fullScreen() to get an undecorated full screen frame");
|
10427
|
-
}
|
10278
|
+
/*
|
10279
|
+
if (!disableAWT) {
|
10280
|
+
frame = new Frame() {
|
10281
|
+
@Override
|
10282
|
+
public void setResizable(boolean resizable) {
|
10283
|
+
deprecationWarning("setResizable");
|
10284
|
+
surface.setResizable(resizable);
|
10285
|
+
}
|
10428
10286
|
|
10429
|
-
|
10430
|
-
|
10431
|
-
|
10432
|
-
|
10433
|
-
|
10434
|
-
surface.setLocation(x, y);
|
10435
|
-
}
|
10436
|
-
*/
|
10287
|
+
@Override
|
10288
|
+
public void setVisible(boolean visible) {
|
10289
|
+
deprecationWarning("setVisible");
|
10290
|
+
surface.setVisible(visible);
|
10291
|
+
}
|
10437
10292
|
|
10438
|
-
|
10439
|
-
|
10440
|
-
|
10441
|
-
|
10442
|
-
|
10293
|
+
@Override
|
10294
|
+
public void setTitle(String title) {
|
10295
|
+
deprecationWarning("setTitle");
|
10296
|
+
surface.setTitle(title);
|
10297
|
+
}
|
10443
10298
|
|
10444
|
-
|
10445
|
-
|
10446
|
-
|
10447
|
-
|
10448
|
-
|
10449
|
-
|
10299
|
+
@Override
|
10300
|
+
public void setUndecorated(boolean ignored) {
|
10301
|
+
throw new RuntimeException("'frame' has been removed from Processing 3, " +
|
10302
|
+
"use fullScreen() to get an undecorated full screen frame");
|
10303
|
+
}
|
10304
|
+
*/
|
10305
|
+
/*
|
10306
|
+
// Can't override this one because it's called by Window's constructor
|
10307
|
+
@Override
|
10308
|
+
public void setLocation(int x, int y) {
|
10309
|
+
deprecationWarning("setLocation");
|
10310
|
+
surface.setLocation(x, y);
|
10311
|
+
}
|
10312
|
+
*/
|
10313
|
+
/*
|
10314
|
+
@Override
|
10315
|
+
public void setSize(int w, int h) {
|
10316
|
+
deprecationWarning("setSize");
|
10317
|
+
surface.setSize(w, h);
|
10318
|
+
}
|
10450
10319
|
|
10451
|
-
|
10320
|
+
private void deprecationWarning(String method) {
|
10321
|
+
PGraphics.showWarning("Use surface." + method + "() instead of " +
|
10322
|
+
"frame." + method + " in Processing 3");
|
10323
|
+
//new Exception(method).printStackTrace(System.out);
|
10324
|
+
}
|
10325
|
+
};
|
10326
|
+
}
|
10327
|
+
*/
|
10328
|
+
surface.initFrame(this);
|
10452
10329
|
surface.setTitle(getClass().getSimpleName());
|
10453
10330
|
|
10454
10331
|
} else {
|
10455
10332
|
surface.initOffscreen(this); // for PDF/PSurfaceNone and friends
|
10456
10333
|
}
|
10457
10334
|
|
10458
|
-
// init();
|
10459
10335
|
return surface;
|
10460
10336
|
}
|
10461
10337
|
|
@@ -10489,7 +10365,7 @@ public class PApplet implements PConstants {
|
|
10489
10365
|
|
10490
10366
|
/** Convenience method, should only be called by PSurface subclasses. */
|
10491
10367
|
static public void hideMenuBar() {
|
10492
|
-
if (PApplet.platform == PConstants.
|
10368
|
+
if (PApplet.platform == PConstants.MACOS) {
|
10493
10369
|
// Call some native code to remove the menu bar on OS X. Not necessary
|
10494
10370
|
// on Linux and Windows, who are happy to make full screen windows.
|
10495
10371
|
japplemenubar.JAppleMenuBar.hide();
|
@@ -10498,11 +10374,13 @@ public class PApplet implements PConstants {
|
|
10498
10374
|
|
10499
10375
|
|
10500
10376
|
/**
|
10501
|
-
* Convenience method for Python Mode to run an already-constructed sketch.
|
10377
|
+
* Convenience method for Python Mode to run an already-constructed sketch.
|
10378
|
+
* This makes it makes it easy to launch a sketch in Jython:
|
10379
|
+
*
|
10380
|
+
* <pre>class MySketch(PApplet):
|
10502
10381
|
* pass
|
10503
10382
|
*
|
10504
10383
|
*MySketch().runSketch();</pre>
|
10505
|
-
* @param args
|
10506
10384
|
*/
|
10507
10385
|
protected void runSketch(final String[] args) {
|
10508
10386
|
final String[] argsWithSketchName = new String[args.length + 1];
|
@@ -10515,17 +10393,12 @@ public class PApplet implements PConstants {
|
|
10515
10393
|
}
|
10516
10394
|
|
10517
10395
|
|
10518
|
-
|
10519
|
-
|
10396
|
+
/*
|
10397
|
+
* Convenience method for propane with jdk9
|
10398
|
+
*/
|
10399
|
+
public void runPropane() {
|
10520
10400
|
runSketch(new String[0]);
|
10521
10401
|
}
|
10522
|
-
|
10523
|
-
/**
|
10524
|
-
* Convenience method for propane with jdk9
|
10525
|
-
*/
|
10526
|
-
public void runPropane() {
|
10527
|
-
runSketch(new String[0]);
|
10528
|
-
}
|
10529
10402
|
|
10530
10403
|
|
10531
10404
|
//////////////////////////////////////////////////////////////
|
@@ -10685,7 +10558,7 @@ public class PApplet implements PConstants {
|
|
10685
10558
|
* Loads the pixel data for the display window into the <b>pixels[]</b>
|
10686
10559
|
* array. This function must always be called before reading from or
|
10687
10560
|
* writing to <b>pixels[]</b>.
|
10688
|
-
*
|
10561
|
+
* renderers may or may not seem to require <b>loadPixels()</b>
|
10689
10562
|
* or <b>updatePixels()</b>. However, the rule is that any time you want to
|
10690
10563
|
* manipulate the <b>pixels[]</b> array, you must first call
|
10691
10564
|
* <b>loadPixels()</b>, and after changes have been made, call
|
@@ -10715,14 +10588,14 @@ public class PApplet implements PConstants {
|
|
10715
10588
|
* Use in conjunction with <b>loadPixels()</b>. If you're only reading
|
10716
10589
|
* pixels from the array, there's no need to call <b>updatePixels()</b>
|
10717
10590
|
* unless there are changes.
|
10718
|
-
*
|
10591
|
+
* renderers may or may not seem to require <b>loadPixels()</b>
|
10719
10592
|
* or <b>updatePixels()</b>. However, the rule is that any time you want to
|
10720
10593
|
* manipulate the <b>pixels[]</b> array, you must first call
|
10721
10594
|
* <b>loadPixels()</b>, and after changes have been made, call
|
10722
10595
|
* <b>updatePixels()</b>. Even if the renderer may not seem to use this
|
10723
10596
|
* function in the current Processing release, this will always be subject
|
10724
10597
|
* to change.
|
10725
|
-
*
|
10598
|
+
*
|
10726
10599
|
* Currently, none of the renderers use the additional parameters to
|
10727
10600
|
* <b>updatePixels()</b>, however this may be implemented in the future.
|
10728
10601
|
*
|
@@ -10804,12 +10677,12 @@ public class PApplet implements PConstants {
|
|
10804
10677
|
* specifies a position in 2D and the <b>vertex()</b> function with three
|
10805
10678
|
* parameters specifies a position in 3D. Each shape will be outlined with
|
10806
10679
|
* the current stroke color and filled with the fill color.
|
10807
|
-
*
|
10680
|
+
*
|
10808
10681
|
* Transformations such as <b>translate()</b>, <b>rotate()</b>, and
|
10809
10682
|
* <b>scale()</b> do not work within <b>beginShape()</b>. It is also not
|
10810
10683
|
* possible to use other shapes, such as <b>ellipse()</b> or <b>rect()</b>
|
10811
10684
|
* within <b>beginShape()</b>.
|
10812
|
-
*
|
10685
|
+
*
|
10813
10686
|
* The P3D renderer settings allow <b>stroke()</b> and <b>fill()</b>
|
10814
10687
|
* settings to be altered per-vertex, however the default P2D renderer does
|
10815
10688
|
* not. Settings such as <b>strokeWeight()</b>, <b>strokeCap()</b>, and
|
@@ -10949,7 +10822,7 @@ public class PApplet implements PConstants {
|
|
10949
10822
|
* Sets a texture to be applied to vertex points. The <b>texture()</b>
|
10950
10823
|
* function must be called between <b>beginShape()</b> and
|
10951
10824
|
* <b>endShape()</b> and before any calls to <b>vertex()</b>.
|
10952
|
-
*
|
10825
|
+
*
|
10953
10826
|
* When textures are in use, the fill color is ignored. Instead, use tint()
|
10954
10827
|
* to specify the color of the texture as it is applied to the shape.
|
10955
10828
|
*
|
@@ -11587,6 +11460,29 @@ public class PApplet implements PConstants {
|
|
11587
11460
|
}
|
11588
11461
|
|
11589
11462
|
|
11463
|
+
/**
|
11464
|
+
* ( begin auto-generated from square.xml )
|
11465
|
+
*
|
11466
|
+
* Draws a square to the screen. A square is a four-sided shape with
|
11467
|
+
* every angle at ninety degrees and each side is the same length.
|
11468
|
+
* By default, the first two parameters set the location of the
|
11469
|
+
* upper-left corner, the third sets the width and height. The way
|
11470
|
+
* these parameters are interpreted, however, may be changed with the
|
11471
|
+
* <b>rectMode()</b> function.
|
11472
|
+
*
|
11473
|
+
* ( end auto-generated )
|
11474
|
+
*
|
11475
|
+
* @webref shape:2d_primitives
|
11476
|
+
* @param x x-coordinate of the rectangle by default
|
11477
|
+
* @param y y-coordinate of the rectangle by default
|
11478
|
+
* @param extent width and height of the rectangle by default
|
11479
|
+
* @see PGraphics#rect(float, float, float, float)
|
11480
|
+
* @see PGraphics#rectMode(int)
|
11481
|
+
*/
|
11482
|
+
public void square(float x, float y, float extent) {
|
11483
|
+
if (recorder != null) recorder.square(x, y, extent);
|
11484
|
+
g.square(x, y, extent);
|
11485
|
+
}
|
11590
11486
|
|
11591
11487
|
|
11592
11488
|
/**
|
@@ -11677,6 +11573,27 @@ public class PApplet implements PConstants {
|
|
11677
11573
|
}
|
11678
11574
|
|
11679
11575
|
|
11576
|
+
/**
|
11577
|
+
* ( begin auto-generated from circle.xml )
|
11578
|
+
*
|
11579
|
+
* Draws a circle to the screen. By default, the first two parameters
|
11580
|
+
* set the location of the center, and the third sets the shape's width
|
11581
|
+
* and height. The origin may be changed with the <b>ellipseMode()</b>
|
11582
|
+
* function.
|
11583
|
+
*
|
11584
|
+
* ( end auto-generated )
|
11585
|
+
* @webref shape:2d_primitives
|
11586
|
+
* @param x x-coordinate of the ellipse
|
11587
|
+
* @param y y-coordinate of the ellipse
|
11588
|
+
* @param extent width and height of the ellipse by default
|
11589
|
+
* @see PApplet#ellipse(float, float, float, float)
|
11590
|
+
* @see PApplet#ellipseMode(int)
|
11591
|
+
*/
|
11592
|
+
public void circle(float x, float y, float extent) {
|
11593
|
+
if (recorder != null) recorder.circle(x, y, extent);
|
11594
|
+
g.circle(x, y, extent);
|
11595
|
+
}
|
11596
|
+
|
11680
11597
|
|
11681
11598
|
/**
|
11682
11599
|
* ( begin auto-generated from box.xml )
|
@@ -11957,17 +11874,17 @@ public class PApplet implements PConstants {
|
|
11957
11874
|
* ( begin auto-generated from curvePoint.xml )
|
11958
11875
|
*
|
11959
11876
|
* Evalutes the curve at point t for points a, b, c, d. The parameter t
|
11960
|
-
* varies between 0 and 1, a and d are
|
11961
|
-
* the
|
11877
|
+
* varies between 0 and 1, a and d are the control points, and b and c are
|
11878
|
+
* the points on the curve. This can be done once with the x coordinates and a
|
11962
11879
|
* second time with the y coordinates to get the location of a curve at t.
|
11963
11880
|
*
|
11964
11881
|
* ( end auto-generated )
|
11965
11882
|
*
|
11966
11883
|
* @webref shape:curves
|
11967
|
-
* @param a coordinate of first point
|
11968
|
-
* @param b coordinate of
|
11969
|
-
* @param c coordinate of
|
11970
|
-
* @param d coordinate of
|
11884
|
+
* @param a coordinate of first control point
|
11885
|
+
* @param b coordinate of first point on the curve
|
11886
|
+
* @param c coordinate of second point on the curve
|
11887
|
+
* @param d coordinate of second control point
|
11971
11888
|
* @param t value between 0 and 1
|
11972
11889
|
* @see PGraphics#curve(float, float, float, float, float, float, float, float, float, float, float, float)
|
11973
11890
|
* @see PGraphics#curveVertex(float, float)
|
@@ -12312,7 +12229,7 @@ public class PApplet implements PConstants {
|
|
12312
12229
|
* CENTER, and RIGHT set the display characteristics of the letters in
|
12313
12230
|
* relation to the values for the <b>x</b> and <b>y</b> parameters of the
|
12314
12231
|
* <b>text()</b> function.
|
12315
|
-
*
|
12232
|
+
*
|
12316
12233
|
* In Processing 0125 and later, an optional second parameter can be used
|
12317
12234
|
* to vertically align the text. BASELINE is the default, and the vertical
|
12318
12235
|
* alignment will be reset to BASELINE if the second parameter is not used.
|
@@ -12320,12 +12237,12 @@ public class PApplet implements PConstants {
|
|
12320
12237
|
* offsets the line based on the current <b>textDescent()</b>. For multiple
|
12321
12238
|
* lines, the final line will be aligned to the bottom, with the previous
|
12322
12239
|
* lines appearing above it.
|
12323
|
-
*
|
12240
|
+
*
|
12324
12241
|
* When using <b>text()</b> with width and height parameters, BASELINE is
|
12325
12242
|
* ignored, and treated as TOP. (Otherwise, text would by default draw
|
12326
12243
|
* outside the box, since BASELINE is the default setting. BASELINE is not
|
12327
12244
|
* a useful drawing mode for text drawn in a rectangle.)
|
12328
|
-
*
|
12245
|
+
*
|
12329
12246
|
* The vertical alignment is based on the value of <b>textAscent()</b>,
|
12330
12247
|
* which many fonts do not specify correctly. It may be necessary to use a
|
12331
12248
|
* hack and offset by a few pixels by hand so that the offset looks
|
@@ -12699,6 +12616,83 @@ public class PApplet implements PConstants {
|
|
12699
12616
|
g.text(num, x, y, z);
|
12700
12617
|
}
|
12701
12618
|
|
12619
|
+
|
12620
|
+
/**
|
12621
|
+
* ( begin auto-generated from push.xml )
|
12622
|
+
*
|
12623
|
+
* The <b>push()</b> function saves the current drawing style
|
12624
|
+
* settings and transformations, while <b>pop()</b> restores these
|
12625
|
+
* settings. Note that these functions are always used together.
|
12626
|
+
* They allow you to change the style and transformation settings
|
12627
|
+
* and later return to what you had. When a new state is started
|
12628
|
+
* with push(), it builds on the current style and transform
|
12629
|
+
* information.
|
12630
|
+
*
|
12631
|
+
* <b>push()</b> stores information related to the current
|
12632
|
+
* transformation state and style settings controlled by the
|
12633
|
+
* following functions: <b>rotate()</b>, <b>translate()</b>,
|
12634
|
+
* <b>scale()</b>, <b>fill()</b>, <b>stroke()</b>, <b>tint()</b>,
|
12635
|
+
* <b>strokeWeight()</b>, <b>strokeCap()</b>, <b>strokeJoin()</b>,
|
12636
|
+
* <b>imageMode()</b>, <b>rectMode()</b>, <b>ellipseMode()</b>,
|
12637
|
+
* <b>colorMode()</b>, <b>textAlign()</b>, <b>textFont()</b>,
|
12638
|
+
* <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.
|
12639
|
+
*
|
12640
|
+
* The <b>push()</b> and <b>pop()</b> functions were added with
|
12641
|
+
* Processing 3.5. They can be used in place of <b>pushMatrix()</b>,
|
12642
|
+
* <b>popMatrix()</b>, <b>pushStyles()</b>, and <b>popStyles()</b>.
|
12643
|
+
* The difference is that push() and pop() control both the
|
12644
|
+
* transformations (rotate, scale, translate) and the drawing styles
|
12645
|
+
* at the same time.
|
12646
|
+
*
|
12647
|
+
* ( end auto-generated )
|
12648
|
+
*
|
12649
|
+
* @webref structure
|
12650
|
+
* @see PGraphics#pop()
|
12651
|
+
*/
|
12652
|
+
public void push() {
|
12653
|
+
if (recorder != null) recorder.push();
|
12654
|
+
g.push();
|
12655
|
+
}
|
12656
|
+
|
12657
|
+
|
12658
|
+
/**
|
12659
|
+
* ( begin auto-generated from pop.xml )
|
12660
|
+
*
|
12661
|
+
* The <b>pop()</b> function restores the previous drawing style
|
12662
|
+
* settings and transformations after <b>push()</b> has changed them.
|
12663
|
+
* Note that these functions are always used together. They allow
|
12664
|
+
* you to change the style and transformation settings and later
|
12665
|
+
* return to what you had. When a new state is started with push(),
|
12666
|
+
* it builds on the current style and transform information.
|
12667
|
+
*
|
12668
|
+
*
|
12669
|
+
* <b>push()</b> stores information related to the current
|
12670
|
+
* transformation state and style settings controlled by the
|
12671
|
+
* following functions: <b>rotate()</b>, <b>translate()</b>,
|
12672
|
+
* <b>scale()</b>, <b>fill()</b>, <b>stroke()</b>, <b>tint()</b>,
|
12673
|
+
* <b>strokeWeight()</b>, <b>strokeCap()</b>, <b>strokeJoin()</b>,
|
12674
|
+
* <b>imageMode()</b>, <b>rectMode()</b>, <b>ellipseMode()</b>,
|
12675
|
+
* <b>colorMode()</b>, <b>textAlign()</b>, <b>textFont()</b>,
|
12676
|
+
* <b>textMode()</b>, <b>textSize()</b>, <b>textLeading()</b>.
|
12677
|
+
*
|
12678
|
+
* The <b>push()</b> and <b>pop()</b> functions were added with
|
12679
|
+
* Processing 3.5. They can be used in place of <b>pushMatrix()</b>,
|
12680
|
+
* <b>popMatrix()</b>, <b>pushStyles()</b>, and <b>popStyles()</b>.
|
12681
|
+
* The difference is that push() and pop() control both the
|
12682
|
+
* transformations (rotate, scale, translate) and the drawing styles
|
12683
|
+
* at the same time.
|
12684
|
+
*
|
12685
|
+
* ( end auto-generated )
|
12686
|
+
*
|
12687
|
+
* @webref structure
|
12688
|
+
* @see PGraphics#push()
|
12689
|
+
*/
|
12690
|
+
public void pop() {
|
12691
|
+
if (recorder != null) recorder.pop();
|
12692
|
+
g.pop();
|
12693
|
+
}
|
12694
|
+
|
12695
|
+
|
12702
12696
|
/**
|
12703
12697
|
* ( begin auto-generated from pushMatrix.xml )
|
12704
12698
|
*
|
@@ -12800,7 +12794,7 @@ public class PApplet implements PConstants {
|
|
12800
12794
|
* Rotates a shape the amount specified by the <b>angle</b> parameter.
|
12801
12795
|
* Angles should be specified in radians (values from 0 to TWO_PI) or
|
12802
12796
|
* converted to radians with the <b>radians()</b> function.
|
12803
|
-
*
|
12797
|
+
*
|
12804
12798
|
* Objects are always rotated around their relative position to the origin
|
12805
12799
|
* and positive numbers rotate objects in a clockwise direction.
|
12806
12800
|
* Transformations apply to everything that happens after and subsequent
|
@@ -12808,7 +12802,7 @@ public class PApplet implements PConstants {
|
|
12808
12802
|
* <b>rotate(HALF_PI)</b> and then <b>rotate(HALF_PI)</b> is the same as
|
12809
12803
|
* <b>rotate(PI)</b>. All tranformations are reset when <b>draw()</b>
|
12810
12804
|
* begins again.
|
12811
|
-
*
|
12805
|
+
*
|
12812
12806
|
* Technically, <b>rotate()</b> multiplies the current transformation
|
12813
12807
|
* matrix by a rotation matrix. This function can be further controlled by
|
12814
12808
|
* the <b>pushMatrix()</b> and <b>popMatrix()</b>.
|
@@ -13019,7 +13013,7 @@ public class PApplet implements PConstants {
|
|
13019
13013
|
* <b>shearX(PI/2)</b> and then <b>shearX(PI/2)</b> is the same as
|
13020
13014
|
* <b>shearX(PI)</b>. If <b>shearX()</b> is called within the
|
13021
13015
|
* <b>draw()</b>, the transformation is reset when the loop begins again.
|
13022
|
-
*
|
13016
|
+
*
|
13023
13017
|
* Technically, <b>shearX()</b> multiplies the current transformation
|
13024
13018
|
* matrix by a rotation matrix. This function can be further controlled by
|
13025
13019
|
* the <b>pushMatrix()</b> and <b>popMatrix()</b> functions.
|
@@ -13054,7 +13048,7 @@ public class PApplet implements PConstants {
|
|
13054
13048
|
* <b>shearY(PI/2)</b> and then <b>shearY(PI/2)</b> is the same as
|
13055
13049
|
* <b>shearY(PI)</b>. If <b>shearY()</b> is called within the
|
13056
13050
|
* <b>draw()</b>, the transformation is reset when the loop begins again.
|
13057
|
-
*
|
13051
|
+
*
|
13058
13052
|
* Technically, <b>shearY()</b> multiplies the current transformation
|
13059
13053
|
* matrix by a rotation matrix. This function can be further controlled by
|
13060
13054
|
* the <b>pushMatrix()</b> and <b>popMatrix()</b> functions.
|
@@ -13564,7 +13558,7 @@ public class PApplet implements PConstants {
|
|
13564
13558
|
* transformations (scale, rotate, translate, etc.) The X value can be used
|
13565
13559
|
* to place an object in space relative to the location of the original
|
13566
13560
|
* point once the transformations are no longer in use.
|
13567
|
-
*
|
13561
|
+
*
|
13568
13562
|
* In the example, the <b>modelX()</b>, <b>modelY()</b>, and
|
13569
13563
|
* <b>modelZ()</b> functions record the location of a box in space after
|
13570
13564
|
* being placed using a series of translate and rotate commands. After
|
@@ -13708,7 +13702,7 @@ public class PApplet implements PConstants {
|
|
13708
13702
|
*
|
13709
13703
|
* Sets the width of the stroke used for lines, points, and the border
|
13710
13704
|
* around shapes. All widths are set in units of pixels.
|
13711
|
-
*
|
13705
|
+
*
|
13712
13706
|
* When drawing with P3D, series of connected lines (such as the stroke
|
13713
13707
|
* around a polygon, triangle, or ellipse) produce unattractive results
|
13714
13708
|
* when a thick stroke weight is set (<a
|
@@ -13739,7 +13733,7 @@ public class PApplet implements PConstants {
|
|
13739
13733
|
* are either mitered, beveled, or rounded and specified with the
|
13740
13734
|
* corresponding parameters MITER, BEVEL, and ROUND. The default joint is
|
13741
13735
|
* MITER.
|
13742
|
-
*
|
13736
|
+
*
|
13743
13737
|
* This function is not available with the P3D renderer, (<a
|
13744
13738
|
* href="http://code.google.com/p/processing/issues/detail?id=123">see
|
13745
13739
|
* Issue 123</a>). More information about the renderers can be found in the
|
@@ -13765,7 +13759,7 @@ public class PApplet implements PConstants {
|
|
13765
13759
|
* Sets the style for rendering line endings. These ends are either
|
13766
13760
|
* squared, extended, or rounded and specified with the corresponding
|
13767
13761
|
* parameters SQUARE, PROJECT, and ROUND. The default cap is ROUND.
|
13768
|
-
*
|
13762
|
+
*
|
13769
13763
|
* This function is not available with the P3D renderer (<a
|
13770
13764
|
* href="http://code.google.com/p/processing/issues/detail?id=123">see
|
13771
13765
|
* Issue 123</a>). More information about the renderers can be found in the
|
@@ -13812,7 +13806,7 @@ public class PApplet implements PConstants {
|
|
13812
13806
|
* is either specified in terms of the RGB or HSB color depending on the
|
13813
13807
|
* current <b>colorMode()</b> (the default color space is RGB, with each
|
13814
13808
|
* value in the range from 0 to 255).
|
13815
|
-
*
|
13809
|
+
*
|
13816
13810
|
* When using hexadecimal notation to specify a color, use "#" or "0x"
|
13817
13811
|
* before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six
|
13818
13812
|
* digits to specify a color (the way colors are specified in HTML and
|
@@ -13820,7 +13814,7 @@ public class PApplet implements PConstants {
|
|
13820
13814
|
* hexadecimal value must be specified with eight characters; the first two
|
13821
13815
|
* characters define the alpha component and the remainder the red, green,
|
13822
13816
|
* and blue components.
|
13823
|
-
*
|
13817
|
+
*
|
13824
13818
|
* The value for the parameter "gray" must be less than or equal to the
|
13825
13819
|
* current maximum value as specified by <b>colorMode()</b>. The default
|
13826
13820
|
* maximum value is 255.
|
@@ -14014,7 +14008,7 @@ public class PApplet implements PConstants {
|
|
14014
14008
|
* color is either specified in terms of the RGB or HSB color depending on
|
14015
14009
|
* the current <b>colorMode()</b> (the default color space is RGB, with
|
14016
14010
|
* each value in the range from 0 to 255).
|
14017
|
-
*
|
14011
|
+
*
|
14018
14012
|
* When using hexadecimal notation to specify a color, use "#" or "0x"
|
14019
14013
|
* before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six
|
14020
14014
|
* digits to specify a color (the way colors are specified in HTML and
|
@@ -14022,11 +14016,11 @@ public class PApplet implements PConstants {
|
|
14022
14016
|
* hexadecimal value must be specified with eight characters; the first two
|
14023
14017
|
* characters define the alpha component and the remainder the red, green,
|
14024
14018
|
* and blue components.
|
14025
|
-
*
|
14019
|
+
*
|
14026
14020
|
* The value for the parameter "gray" must be less than or equal to the
|
14027
14021
|
* current maximum value as specified by <b>colorMode()</b>. The default
|
14028
14022
|
* maximum value is 255.
|
14029
|
-
*
|
14023
|
+
*
|
14030
14024
|
* To change the color of an image (or a texture), use tint().
|
14031
14025
|
*
|
14032
14026
|
* ( end auto-generated )
|
@@ -14162,6 +14156,8 @@ public class PApplet implements PConstants {
|
|
14162
14156
|
|
14163
14157
|
/**
|
14164
14158
|
* gray number specifying value between white and black
|
14159
|
+
*
|
14160
|
+
* @param gray value between black and white, by default 0 to 255
|
14165
14161
|
*/
|
14166
14162
|
public void specular(float gray) {
|
14167
14163
|
if (recorder != null) recorder.specular(gray);
|
@@ -14227,6 +14223,8 @@ public class PApplet implements PConstants {
|
|
14227
14223
|
|
14228
14224
|
/**
|
14229
14225
|
* gray number specifying value between white and black
|
14226
|
+
*
|
14227
|
+
* @param gray value between black and white, by default 0 to 255
|
14230
14228
|
*/
|
14231
14229
|
public void emissive(float gray) {
|
14232
14230
|
if (recorder != null) recorder.emissive(gray);
|
@@ -14518,13 +14516,13 @@ public class PApplet implements PConstants {
|
|
14518
14516
|
* of the Processing window. The default background is light gray. In the
|
14519
14517
|
* <b>draw()</b> function, the background color is used to clear the
|
14520
14518
|
* display window at the beginning of each frame.
|
14521
|
-
*
|
14519
|
+
*
|
14522
14520
|
* An image can also be used as the background for a sketch, however its
|
14523
14521
|
* width and height must be the same size as the sketch window. To resize
|
14524
14522
|
* an image 'b' to the size of the sketch window, use b.resize(width, height).
|
14525
|
-
*
|
14523
|
+
*
|
14526
14524
|
* Images used as background will ignore the current <b>tint()</b> setting.
|
14527
|
-
*
|
14525
|
+
*
|
14528
14526
|
* It is not possible to use transparency (alpha) in background colors with
|
14529
14527
|
* the main drawing surface, however they will work properly with <b>createGraphics()</b>.
|
14530
14528
|
*
|
@@ -14607,13 +14605,13 @@ public class PApplet implements PConstants {
|
|
14607
14605
|
/**
|
14608
14606
|
* Takes an RGB or ARGB image and sets it as the background.
|
14609
14607
|
* The width and height of the image must be the same size as the sketch.
|
14610
|
-
* Use image.resize(width, height) to make short work of such a task
|
14611
|
-
*
|
14608
|
+
* Use image.resize(width, height) to make short work of such a task.
|
14609
|
+
*
|
14612
14610
|
* Note that even if the image is set as RGB, the high 8 bits of each pixel
|
14613
14611
|
* should be set opaque (0xFF000000) because the image data will be copied
|
14614
14612
|
* directly to the screen, and non-opaque background images may have strange
|
14615
|
-
* behavior. Use image.filter(OPAQUE) to handle this easily
|
14616
|
-
*
|
14613
|
+
* behavior. Use image.filter(OPAQUE) to handle this easily.
|
14614
|
+
*
|
14617
14615
|
* When using 3D, this will also clear the zbuffer (if it exists).
|
14618
14616
|
*
|
14619
14617
|
* @param image PImage to set as background (must be same size as the sketch window)
|
@@ -14916,6 +14914,15 @@ public class PApplet implements PConstants {
|
|
14916
14914
|
}
|
14917
14915
|
|
14918
14916
|
|
14917
|
+
/**
|
14918
|
+
* Check the alpha on an image, using a really primitive loop.
|
14919
|
+
*/
|
14920
|
+
public void checkAlpha() {
|
14921
|
+
if (recorder != null) recorder.checkAlpha();
|
14922
|
+
g.checkAlpha();
|
14923
|
+
}
|
14924
|
+
|
14925
|
+
|
14919
14926
|
/**
|
14920
14927
|
* ( begin auto-generated from PImage_get.xml )
|
14921
14928
|
*
|
@@ -15096,8 +15103,8 @@ public class PApplet implements PConstants {
|
|
15096
15103
|
/**
|
15097
15104
|
* ( begin auto-generated from PImage_filter.xml )
|
15098
15105
|
*
|
15099
|
-
* Filters an image as defined by one of the following modes
|
15100
|
-
*
|
15106
|
+
* Filters an image as defined by one of the following modes:
|
15107
|
+
* THRESHOLD - converts the image to black and white pixels depending if
|
15101
15108
|
* they are above or below the threshold defined by the level parameter.
|
15102
15109
|
* The level must be between 0.0 (black) and 1.0(white). If no level is
|
15103
15110
|
* specified, 0.5 is used.
|