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
@@ -1,3 +1,5 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
1
3
|
/*
|
2
4
|
Part of the Processing project - http://processing.org
|
3
5
|
|
@@ -17,44 +19,45 @@
|
|
17
19
|
Public License along with this library; if not, write to the
|
18
20
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
19
21
|
Boston, MA 02111-1307 USA
|
20
|
-
|
22
|
+
*/
|
23
|
+
|
21
24
|
package processing.core;
|
22
25
|
|
23
|
-
public class PStyle implements PConstants {
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
27
|
+
public class PStyle implements PConstants {
|
28
|
+
public int imageMode;
|
29
|
+
public int rectMode;
|
30
|
+
public int ellipseMode;
|
31
|
+
public int shapeMode;
|
32
|
+
|
33
|
+
public int blendMode;
|
34
|
+
|
35
|
+
public int colorMode;
|
36
|
+
public float colorModeX;
|
37
|
+
public float colorModeY;
|
38
|
+
public float colorModeZ;
|
39
|
+
public float colorModeA;
|
40
|
+
|
41
|
+
public boolean tint;
|
42
|
+
public int tintColor;
|
43
|
+
public boolean fill;
|
44
|
+
public int fillColor;
|
45
|
+
public boolean stroke;
|
46
|
+
public int strokeColor;
|
47
|
+
public float strokeWeight;
|
48
|
+
public int strokeCap;
|
49
|
+
public int strokeJoin;
|
50
|
+
|
51
|
+
// TODO these fellas are inconsistent, and may need to go elsewhere
|
52
|
+
public float ambientR, ambientG, ambientB;
|
53
|
+
public float specularR, specularG, specularB;
|
54
|
+
public float emissiveR, emissiveG, emissiveB;
|
55
|
+
public float shininess;
|
56
|
+
|
57
|
+
public PFont textFont;
|
58
|
+
public int textAlign;
|
59
|
+
public int textAlignY;
|
60
|
+
public int textMode;
|
61
|
+
public float textSize;
|
62
|
+
public float textLeading;
|
60
63
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
1
3
|
/*
|
2
4
|
Part of the Processing project - http://processing.org
|
3
5
|
|
@@ -16,84 +18,113 @@
|
|
16
18
|
Public License along with this library; if not, write to the
|
17
19
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
20
|
Boston, MA 02111-1307 USA
|
19
|
-
|
21
|
+
*/
|
22
|
+
|
20
23
|
package processing.core;
|
21
24
|
|
25
|
+
import java.io.File;
|
26
|
+
|
22
27
|
public interface PSurface {
|
28
|
+
/**
|
29
|
+
* Minimum dimensions for the window holding an applet. This varies between
|
30
|
+
* platforms, Mac OS X 10.3 (confirmed with 10.7 and Java 6) can do any
|
31
|
+
* height but requires at least 128 pixels width. Windows XP has another
|
32
|
+
* set of limitations. And for all I know, Linux probably allows window
|
33
|
+
* sizes to be negative numbers.
|
34
|
+
*/
|
35
|
+
static public final int MIN_WINDOW_WIDTH = 128;
|
36
|
+
static public final int MIN_WINDOW_HEIGHT = 128;
|
37
|
+
|
38
|
+
//public int displayDensity();
|
39
|
+
|
40
|
+
//public int displayDensity(int display);
|
23
41
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
// renderer that doesn't draw to the screen
|
35
|
-
public void initOffscreen(PApplet sketch);
|
36
|
-
|
37
|
-
// considering removal in favor of separate Component classes for appropriate renderers
|
38
|
-
// (i.e. for Java2D or a generic Image surface, but not PDF, debatable for GL or )
|
39
|
-
//public Component initComponent(PApplet sketch);
|
40
|
-
//public Frame initFrame(PApplet sketch, Color backgroundColor,
|
42
|
+
//
|
43
|
+
|
44
|
+
// renderer that doesn't draw to the screen
|
45
|
+
public void initOffscreen(PApplet sketch);
|
46
|
+
|
47
|
+
// considering removal in favor of separate Component classes for appropriate renderers
|
48
|
+
// (i.e. for Java2D or a generic Image surface, but not PDF, debatable for GL or FX)
|
49
|
+
//public Component initComponent(PApplet sketch);
|
50
|
+
|
51
|
+
//public Frame initFrame(PApplet sketch, Color backgroundColor,
|
41
52
|
// public void initFrame(PApplet sketch, int backgroundColor,
|
42
53
|
// int deviceIndex, boolean fullScreen, boolean spanDisplays);
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
54
|
+
public void initFrame(PApplet sketch);
|
55
|
+
|
56
|
+
//
|
57
|
+
|
58
|
+
public PImage loadImage(String path, Object... args);
|
59
|
+
|
60
|
+
//
|
61
|
+
|
62
|
+
public void selectInput(String prompt, String callback,
|
63
|
+
File file, Object callbackObject);
|
64
|
+
|
65
|
+
public void selectOutput(String prompt, String callback,
|
66
|
+
File file, Object callbackObject);
|
67
|
+
|
68
|
+
public void selectFolder(String prompt, String callback,
|
69
|
+
File file, Object callbackObject);
|
70
|
+
|
71
|
+
//
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Get the native window object associated with this drawing surface.For Java2D, this will be an AWT Frame object.
|
75
|
+
* For OpenGL, the window.
|
76
|
+
The data returned here is subject to the whims of the renderer,
|
77
|
+
and using this method means you're willing to deal with underlying
|
78
|
+
implementation changes and that you won't throw a fit like a toddler
|
79
|
+
if your code breaks sometime in the future.
|
80
|
+
* @return
|
81
|
+
*/
|
82
|
+
public Object getNative();
|
83
|
+
|
84
|
+
//
|
85
|
+
|
86
|
+
// Just call these on an AWT Frame object stored in PApplet.
|
87
|
+
// Silly, but prevents a lot of rewrite and extra methods for little benefit.
|
88
|
+
// However, maybe prevents us from having to document the 'frame' variable?
|
89
|
+
|
90
|
+
/** Set the window (and dock, or whatever necessary) title.
|
91
|
+
* @param title */
|
92
|
+
public void setTitle(String title);
|
93
|
+
|
94
|
+
/** Show or hide the window.
|
95
|
+
* @param visible */
|
96
|
+
public void setVisible(boolean visible);
|
97
|
+
|
98
|
+
/** Set true if we want to resize things (default is not resizable)
|
99
|
+
* @param resizable */
|
100
|
+
public void setResizable(boolean resizable);
|
101
|
+
|
102
|
+
/** Dumb name, but inherited from Frame and no better ideas.
|
103
|
+
* @param always */
|
104
|
+
public void setAlwaysOnTop(boolean always);
|
105
|
+
|
106
|
+
public void setIcon(PImage icon);
|
107
|
+
|
108
|
+
//
|
109
|
+
|
82
110
|
// public void placeWindow(int[] location);
|
83
|
-
public void placeWindow(int[] location, int[] editorLocation);
|
84
111
|
|
85
|
-
|
86
|
-
|
112
|
+
public void placeWindow(int[] location, int[] editorLocation);
|
113
|
+
|
114
|
+
//public void placeFullScreen(boolean hideStop);
|
115
|
+
public void placePresent(int stopColor);
|
116
|
+
|
117
|
+
// Sketch is running from the PDE, set up messaging back to the PDE
|
118
|
+
public void setupExternalMessages();
|
119
|
+
|
120
|
+
//
|
87
121
|
|
88
|
-
|
89
|
-
|
122
|
+
// sets displayWidth/Height inside PApplet
|
123
|
+
//public void checkDisplaySize();
|
90
124
|
|
91
|
-
|
92
|
-
// sets displayWidth/Height inside PApplet
|
93
|
-
//public void checkDisplaySize();
|
94
|
-
public void setLocation(int x, int y);
|
125
|
+
public void setLocation(int x, int y);
|
95
126
|
|
96
|
-
|
127
|
+
public void setSize(int width, int height);
|
97
128
|
|
98
129
|
// /**
|
99
130
|
// * Called by {@link PApplet#createGraphics} to initialize the
|
@@ -103,54 +134,65 @@ public interface PSurface {
|
|
103
134
|
// * @param wide
|
104
135
|
// * @param high
|
105
136
|
// */
|
106
|
-
|
107
|
-
|
108
|
-
|
137
|
+
// create pixel buffer (pulled out for offscreen graphics)
|
138
|
+
//public void initImage(PGraphics gr, int wide, int high);
|
139
|
+
// create pixel buffer, called from allocate() to produce a compatible image for rendering efficiently
|
109
140
|
// public void initImage(PGraphics gr);
|
110
|
-
|
141
|
+
|
142
|
+
//public Component getComponent();
|
143
|
+
|
111
144
|
// /**
|
112
145
|
// * Sometimes smoothing must be set at the drawing surface level
|
113
146
|
// * not just inside the renderer itself.
|
114
147
|
// */
|
115
148
|
// public void setSmooth(int level);
|
116
|
-
|
149
|
+
|
150
|
+
public void setFrameRate(float fps);
|
117
151
|
|
118
152
|
// // called on the first frame so that the now-visible drawing surface can
|
119
153
|
// // receive key and mouse events
|
120
154
|
// public void requestFocus();
|
155
|
+
|
121
156
|
// // finish rendering to the screen (called by PApplet)
|
122
157
|
// public void blit();
|
123
|
-
//
|
124
|
-
public void setCursor(int kind);
|
125
158
|
|
126
|
-
|
159
|
+
//
|
160
|
+
|
161
|
+
public void setCursor(int kind);
|
162
|
+
|
163
|
+
public void setCursor(PImage image, int hotspotX, int hotspotY);
|
164
|
+
|
165
|
+
public void showCursor();
|
166
|
+
|
167
|
+
public void hideCursor();
|
168
|
+
|
169
|
+
//
|
127
170
|
|
128
|
-
|
171
|
+
/**
|
172
|
+
* @param url the link to open
|
173
|
+
* @return false if unable to find a viable way to open
|
174
|
+
*/
|
175
|
+
public boolean openLink(String url);
|
129
176
|
|
130
|
-
|
177
|
+
//
|
131
178
|
|
132
|
-
|
133
|
-
|
134
|
-
* Start the animation thread
|
135
|
-
*/
|
136
|
-
public void startThread();
|
179
|
+
/** Start the animation thread */
|
180
|
+
public void startThread();
|
137
181
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
public void pauseThread();
|
182
|
+
/**
|
183
|
+
* On the next trip through the animation thread, things should go sleepy-bye.
|
184
|
+
* Does not pause the thread immediately because that needs to happen on the
|
185
|
+
* animation thread itself, so fires on the next trip through draw().
|
186
|
+
*/
|
187
|
+
public void pauseThread();
|
145
188
|
|
146
|
-
|
189
|
+
public void resumeThread();
|
147
190
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
public boolean stopThread();
|
191
|
+
/**
|
192
|
+
* Stop the animation thread (set it null)
|
193
|
+
* @return false if already stopped
|
194
|
+
*/
|
195
|
+
public boolean stopThread();
|
154
196
|
|
155
|
-
|
197
|
+
public boolean isStopped();
|
156
198
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
1
3
|
/*
|
2
4
|
Part of the Processing project - http://processing.org
|
3
5
|
|
@@ -16,238 +18,320 @@
|
|
16
18
|
Public License along with this library; if not, write to the
|
17
19
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
20
|
Boston, MA 02111-1307 USA
|
19
|
-
|
21
|
+
*/
|
22
|
+
|
20
23
|
package processing.core;
|
21
24
|
|
25
|
+
import java.io.File;
|
26
|
+
|
27
|
+
import processing.awt.ShimAWT;
|
28
|
+
|
22
29
|
/**
|
23
30
|
* Surface that's not really visible. Used for PDF and friends, or as a base
|
24
31
|
* class for other drawing surfaces. It includes the standard rendering loop.
|
25
32
|
*/
|
26
33
|
public class PSurfaceNone implements PSurface {
|
34
|
+
protected PApplet sketch;
|
35
|
+
protected PGraphics graphics;
|
27
36
|
|
28
|
-
|
29
|
-
|
37
|
+
protected Thread thread;
|
38
|
+
protected boolean paused;
|
39
|
+
protected Object pauseObject = new Object();
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
protected Object pauseObject = new Object();
|
41
|
+
protected float frameRateTarget = 60;
|
42
|
+
protected long frameRatePeriod = 1000000000L / 60L;
|
34
43
|
|
35
|
-
protected float frameRateTarget = 60;
|
36
|
-
protected long frameRatePeriod = 1000000000L / 60L;
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
public PSurfaceNone(PGraphics graphics) {
|
46
|
+
this.graphics = graphics;
|
47
|
+
}
|
41
48
|
|
42
|
-
@Override
|
43
|
-
public void initOffscreen(PApplet sketch) {
|
44
|
-
this.sketch = sketch;
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
public int displayDensity() {
|
51
|
+
return 1;
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
public int displayDensity(int display) {
|
56
|
+
return 1;
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
@Override
|
61
|
+
public PImage loadImage(String path, Object... args) {
|
62
|
+
return ShimAWT.loadImage(sketch, path, args);
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
@Override
|
67
|
+
public void selectInput(String prompt, String callback, File file,
|
68
|
+
Object callbackObject) {
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
@Override
|
73
|
+
public void selectOutput(String prompt, String callback, File file,
|
74
|
+
Object callbackObject) {
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
@Override
|
79
|
+
public void selectFolder(String prompt, String callback, File file,
|
80
|
+
Object callbackObject) {
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
@Override
|
85
|
+
public void initOffscreen(PApplet sketch) {
|
86
|
+
this.sketch = sketch;
|
87
|
+
|
88
|
+
setSize(sketch.sketchWidth(), sketch.sketchHeight());
|
89
|
+
}
|
90
|
+
|
48
91
|
|
49
92
|
// public Component initComponent(PApplet sketch) {
|
50
93
|
// return null;
|
51
94
|
// }
|
52
|
-
@Override
|
53
|
-
public void initFrame(PApplet sketch) {
|
54
|
-
throw new IllegalStateException("initFrame() not available with "
|
55
|
-
+ getClass().getSimpleName());
|
56
|
-
}
|
57
95
|
|
58
|
-
public Object getNative() {
|
59
|
-
return null;
|
60
|
-
}
|
61
96
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
// You're in a utopian PSurface implementation where titles don't exist.
|
68
|
-
}
|
97
|
+
@Override
|
98
|
+
public void initFrame(PApplet sketch) {
|
99
|
+
throw new IllegalStateException("initFrame() not available with " +
|
100
|
+
getClass().getSimpleName());
|
101
|
+
}
|
69
102
|
|
70
|
-
@Override
|
71
|
-
public void setIcon(PImage image) {
|
72
|
-
// I ain't visible, man.
|
73
|
-
}
|
74
103
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
public void setVisible(boolean visible) {
|
80
|
-
// I'm always invisible. You can't catch me.
|
81
|
-
}
|
104
|
+
@Override
|
105
|
+
public Object getNative() {
|
106
|
+
return null;
|
107
|
+
}
|
82
108
|
|
83
|
-
/**
|
84
|
-
* Set true if we want to resize things (default is not resizable)
|
85
|
-
*/
|
86
|
-
@Override
|
87
|
-
public void setResizable(boolean resizable) {
|
88
|
-
// I don't need size to know my worth.
|
89
|
-
}
|
90
109
|
|
91
|
-
|
92
|
-
|
93
|
-
|
110
|
+
/** Set the window (and dock, or whatever necessary) title.
|
111
|
+
* @param title */
|
112
|
+
@Override
|
113
|
+
public void setTitle(String title) {
|
114
|
+
// You're in a utopian PSurface implementation where titles don't exist.
|
115
|
+
}
|
94
116
|
|
95
|
-
@Override
|
96
|
-
public void placePresent(int stopColor) {
|
97
|
-
}
|
98
117
|
|
99
|
-
|
100
|
-
|
101
|
-
|
118
|
+
@Override
|
119
|
+
public void setIcon(PImage image) {
|
120
|
+
// I ain't visible, man.
|
121
|
+
}
|
102
122
|
|
103
|
-
@Override
|
104
|
-
public void setAlwaysOnTop(boolean always) {
|
105
|
-
}
|
106
123
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
124
|
+
/** Show or hide the window.
|
125
|
+
* @param visible */
|
126
|
+
@Override
|
127
|
+
public void setVisible(boolean visible) {
|
128
|
+
// I'm always invisible. You can't catch me.
|
129
|
+
}
|
112
130
|
|
113
|
-
@Override
|
114
|
-
public void setSize(int wide, int high) {
|
115
|
-
if (PApplet.DEBUG) {
|
116
|
-
//System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
|
117
|
-
new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
|
118
|
-
}
|
119
131
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
132
|
+
/** Set true if we want to resize things (default is not resizable)
|
133
|
+
* @param resizable */
|
134
|
+
@Override
|
135
|
+
public void setResizable(boolean resizable) {
|
136
|
+
// I don't need size to know my worth.
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
@Override
|
141
|
+
public void placeWindow(int[] location, int[] editorLocation) { }
|
142
|
+
|
143
|
+
|
144
|
+
@Override
|
145
|
+
public void placePresent(int stopColor) { }
|
146
|
+
|
147
|
+
|
148
|
+
@Override
|
149
|
+
public void setupExternalMessages() { }
|
150
|
+
|
151
|
+
|
152
|
+
@Override
|
153
|
+
public void setAlwaysOnTop(boolean always) { }
|
154
|
+
|
155
|
+
|
156
|
+
//
|
157
|
+
|
158
|
+
|
159
|
+
@Override
|
160
|
+
public void setLocation(int x, int y) {
|
161
|
+
// I'm everywhere, because I'm nowhere.
|
162
|
+
}
|
127
163
|
|
128
|
-
//throw new RuntimeException("implement me, see readme.md");
|
129
|
-
sketch.width = wide;
|
130
|
-
sketch.height = high;
|
131
164
|
|
132
|
-
|
133
|
-
|
165
|
+
@Override
|
166
|
+
public void setSize(int wide, int high) {
|
167
|
+
if (PApplet.DEBUG) {
|
168
|
+
//System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
|
169
|
+
new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
|
134
170
|
}
|
135
171
|
|
172
|
+
//if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
|
173
|
+
if (wide == sketch.width && high == sketch.height) {
|
174
|
+
if (PApplet.DEBUG) {
|
175
|
+
new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
|
176
|
+
}
|
177
|
+
return; // unchanged, don't rebuild everything
|
178
|
+
}
|
179
|
+
|
180
|
+
//throw new RuntimeException("implement me, see readme.md");
|
181
|
+
sketch.width = wide;
|
182
|
+
sketch.height = high;
|
183
|
+
|
184
|
+
// set PGraphics variables for width/height/pixelWidth/pixelHeight
|
185
|
+
graphics.setSize(wide, high);
|
186
|
+
}
|
187
|
+
|
188
|
+
|
136
189
|
// public void initImage(PGraphics graphics) {
|
137
190
|
// // TODO Auto-generated method stub
|
138
191
|
//
|
139
192
|
// }
|
193
|
+
|
140
194
|
// public Component getComponent() {
|
141
195
|
// return null;
|
142
196
|
// }
|
197
|
+
|
198
|
+
|
143
199
|
// public void setSmooth(int level) {
|
144
200
|
// // TODO Auto-generated method stub
|
145
201
|
// }
|
202
|
+
|
146
203
|
// void requestFocus() {
|
147
204
|
// }
|
205
|
+
|
148
206
|
// public void blit() {
|
149
207
|
// // TODO Auto-generated method stub
|
150
208
|
// }
|
151
|
-
public void setCursor(int kind) {
|
152
|
-
}
|
153
209
|
|
154
|
-
|
155
|
-
|
210
|
+
@Override
|
211
|
+
public void setCursor(int kind) { }
|
156
212
|
|
157
|
-
|
158
|
-
|
213
|
+
@Override
|
214
|
+
public void setCursor(PImage image, int hotspotX, int hotspotY) { }
|
159
215
|
|
160
|
-
|
161
|
-
|
216
|
+
@Override
|
217
|
+
public void showCursor() { }
|
162
218
|
|
163
|
-
|
164
|
-
|
165
|
-
return new AnimationThread();
|
166
|
-
}
|
219
|
+
@Override
|
220
|
+
public void hideCursor() { }
|
167
221
|
|
168
|
-
public void startThread() {
|
169
|
-
if (thread == null) {
|
170
|
-
thread = createThread();
|
171
|
-
thread.start();
|
172
|
-
} else {
|
173
|
-
throw new IllegalStateException("Thread already started in "
|
174
|
-
+ getClass().getSimpleName());
|
175
|
-
}
|
176
|
-
}
|
177
222
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
223
|
+
//
|
224
|
+
|
225
|
+
|
226
|
+
@Override
|
227
|
+
public boolean openLink(String url) {
|
228
|
+
return false;
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
//
|
185
233
|
|
186
|
-
|
187
|
-
|
234
|
+
|
235
|
+
public Thread createThread() {
|
236
|
+
return new AnimationThread();
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
@Override
|
241
|
+
public void startThread() {
|
242
|
+
if (thread == null) {
|
243
|
+
thread = createThread();
|
244
|
+
thread.start();
|
245
|
+
} else {
|
246
|
+
throw new IllegalStateException("Thread already started in " +
|
247
|
+
getClass().getSimpleName());
|
188
248
|
}
|
249
|
+
}
|
250
|
+
|
189
251
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
252
|
+
@Override
|
253
|
+
public boolean stopThread() {
|
254
|
+
if (thread == null) {
|
255
|
+
return false;
|
194
256
|
}
|
257
|
+
thread = null;
|
258
|
+
return true;
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
@Override
|
263
|
+
public boolean isStopped() {
|
264
|
+
return thread == null || !thread.isAlive();
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
// sets a flag to pause the thread when ready
|
269
|
+
@Override
|
270
|
+
public void pauseThread() {
|
271
|
+
PApplet.debug("PApplet.run() paused, calling object wait...");
|
272
|
+
paused = true;
|
273
|
+
}
|
195
274
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
275
|
+
|
276
|
+
// halts the animation thread if the pause flag is set
|
277
|
+
protected void checkPause() {
|
278
|
+
if (paused) {
|
279
|
+
synchronized (pauseObject) {
|
280
|
+
try {
|
281
|
+
pauseObject.wait();
|
202
282
|
// PApplet.debug("out of wait");
|
203
|
-
|
204
|
-
|
205
|
-
}
|
206
|
-
}
|
283
|
+
} catch (InterruptedException e) {
|
284
|
+
// waiting for this interrupt on a start() (resume) call
|
207
285
|
}
|
208
|
-
|
286
|
+
}
|
209
287
|
}
|
288
|
+
// PApplet.debug("done with pause");
|
289
|
+
}
|
210
290
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
291
|
+
|
292
|
+
@Override
|
293
|
+
public void resumeThread() {
|
294
|
+
paused = false;
|
295
|
+
synchronized (pauseObject) {
|
296
|
+
pauseObject.notifyAll(); // wake up the animation thread
|
216
297
|
}
|
298
|
+
}
|
217
299
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
300
|
+
|
301
|
+
@Override
|
302
|
+
public void setFrameRate(float fps) {
|
303
|
+
frameRateTarget = fps;
|
304
|
+
frameRatePeriod = (long) (1000000000.0 / frameRateTarget);
|
305
|
+
//g.setFrameRate(fps);
|
306
|
+
}
|
307
|
+
|
308
|
+
|
309
|
+
public class AnimationThread extends Thread {
|
310
|
+
|
311
|
+
public AnimationThread() {
|
312
|
+
super("Animation Thread");
|
222
313
|
}
|
223
314
|
|
224
|
-
|
315
|
+
// broken out so it can be overridden by Danger et al
|
316
|
+
public void callDraw() {
|
317
|
+
sketch.handleDraw();
|
318
|
+
}
|
225
319
|
|
226
|
-
|
227
|
-
|
228
|
-
|
320
|
+
/**
|
321
|
+
* Main method for the primary animation thread.
|
322
|
+
* <A HREF="http://java.sun.com/products/jfc/tsc/articles/painting/">Painting in AWT and Swing</A>
|
323
|
+
*/
|
324
|
+
@Override
|
325
|
+
public void run() { // not good to make this synchronized, locks things up
|
326
|
+
long beforeTime = System.nanoTime();
|
327
|
+
long overSleepTime = 0L;
|
229
328
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
329
|
+
int noDelays = 0;
|
330
|
+
// Number of frames with a delay of 0 ms before the
|
331
|
+
// animation thread yields to other running threads.
|
332
|
+
final int NO_DELAYS_PER_YIELD = 15;
|
234
333
|
|
235
|
-
|
236
|
-
* Main method for the primary animation thread.
|
237
|
-
* <A HREF="http://java.sun.com/products/jfc/tsc/articles/painting/">Painting
|
238
|
-
* in AWT and Swing</A>
|
239
|
-
*/
|
240
|
-
@Override
|
241
|
-
public void run() { // not good to make this synchronized, locks things up
|
242
|
-
long beforeTime = System.nanoTime();
|
243
|
-
long overSleepTime = 0L;
|
244
|
-
|
245
|
-
int noDelays = 0;
|
246
|
-
// Number of frames with a delay of 0 ms before the
|
247
|
-
// animation thread yields to other running threads.
|
248
|
-
final int NO_DELAYS_PER_YIELD = 15;
|
249
|
-
|
250
|
-
/*
|
334
|
+
/*
|
251
335
|
// If size un-initialized, might be a Canvas. Call setSize() here since
|
252
336
|
// we now have a parent object that this Canvas can use as a peer.
|
253
337
|
if (graphics.image == null) {
|
@@ -265,26 +349,28 @@ public class PSurfaceNone implements PSurface {
|
|
265
349
|
}
|
266
350
|
// System.out.format(" but now, sketchW/H changed to %d %d%n", sketchWidth, sketchHeight);
|
267
351
|
}
|
268
|
-
|
269
|
-
// un-pause the sketch and get rolling
|
270
|
-
sketch.start();
|
352
|
+
*/
|
271
353
|
|
272
|
-
|
273
|
-
|
354
|
+
// un-pause the sketch and get rolling
|
355
|
+
sketch.start();
|
274
356
|
|
275
|
-
|
276
|
-
|
357
|
+
while ((Thread.currentThread() == thread) && !sketch.finished) {
|
358
|
+
checkPause();
|
359
|
+
|
360
|
+
// Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
|
361
|
+
// otherwise it may attempt a resize mid-render.
|
277
362
|
// Dimension currentSize = canvas.getSize();
|
278
363
|
// if (currentSize.width != sketchWidth || currentSize.height != sketchHeight) {
|
279
364
|
// System.err.format("need to resize from %s to %d, %d%n", currentSize, sketchWidth, sketchHeight);
|
280
365
|
// }
|
281
|
-
|
366
|
+
|
367
|
+
// render a single frame
|
282
368
|
// try {
|
283
369
|
// EventQueue.invokeAndWait(new Runnable() {
|
284
370
|
// public void run() {
|
285
371
|
// System.out.println("calling draw, finished = " + sketch.finished);
|
286
|
-
|
287
|
-
|
372
|
+
//System.out.println("calling draw, looping = " + sketch.looping + ", frameCount = " + sketch.frameCount);
|
373
|
+
callDraw();
|
288
374
|
|
289
375
|
// EventQueue.invokeLater(new Runnable() {
|
290
376
|
// public void run() {
|
@@ -293,6 +379,7 @@ public class PSurfaceNone implements PSurface {
|
|
293
379
|
// }
|
294
380
|
// }
|
295
381
|
// });
|
382
|
+
|
296
383
|
// }
|
297
384
|
// });
|
298
385
|
// } catch (InterruptedException ie) {
|
@@ -300,44 +387,45 @@ public class PSurfaceNone implements PSurface {
|
|
300
387
|
// } catch (InvocationTargetException ite) {
|
301
388
|
// ite.getTargetException().printStackTrace();
|
302
389
|
// }
|
303
|
-
// wait for update & paint to happen before drawing next frame
|
304
|
-
// this is necessary since the drawing is sometimes in a
|
305
|
-
// separate thread, meaning that the next frame will start
|
306
|
-
// before the update/paint is completed
|
307
|
-
long afterTime = System.nanoTime();
|
308
|
-
long timeDiff = afterTime - beforeTime;
|
309
|
-
//System.out.println("time diff is " + timeDiff);
|
310
|
-
long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
|
311
|
-
|
312
|
-
if (sleepTime > 0) { // some time left in this cycle
|
313
|
-
try {
|
314
|
-
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
|
315
|
-
noDelays = 0; // Got some sleep, not delaying anymore
|
316
|
-
} catch (InterruptedException ex) {
|
317
|
-
}
|
318
|
-
|
319
|
-
overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
|
320
|
-
|
321
|
-
} else { // sleepTime <= 0; the frame took longer than the period
|
322
|
-
overSleepTime = 0L;
|
323
|
-
noDelays++;
|
324
|
-
|
325
|
-
if (noDelays > NO_DELAYS_PER_YIELD) {
|
326
|
-
Thread.yield(); // give another thread a chance to run
|
327
|
-
noDelays = 0;
|
328
|
-
}
|
329
|
-
}
|
330
|
-
|
331
|
-
beforeTime = System.nanoTime();
|
332
|
-
}
|
333
390
|
|
334
|
-
|
391
|
+
// wait for update & paint to happen before drawing next frame
|
392
|
+
// this is necessary since the drawing is sometimes in a
|
393
|
+
// separate thread, meaning that the next frame will start
|
394
|
+
// before the update/paint is completed
|
335
395
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
396
|
+
long afterTime = System.nanoTime();
|
397
|
+
long timeDiff = afterTime - beforeTime;
|
398
|
+
//System.out.println("time diff is " + timeDiff);
|
399
|
+
long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
|
400
|
+
|
401
|
+
if (sleepTime > 0) { // some time left in this cycle
|
402
|
+
try {
|
403
|
+
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
|
404
|
+
noDelays = 0; // Got some sleep, not delaying anymore
|
405
|
+
} catch (InterruptedException ex) { }
|
406
|
+
|
407
|
+
overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
|
408
|
+
|
409
|
+
} else { // sleepTime <= 0; the frame took longer than the period
|
410
|
+
overSleepTime = 0L;
|
411
|
+
noDelays++;
|
412
|
+
|
413
|
+
if (noDelays > NO_DELAYS_PER_YIELD) {
|
414
|
+
Thread.yield(); // give another thread a chance to run
|
415
|
+
noDelays = 0;
|
416
|
+
}
|
341
417
|
}
|
418
|
+
|
419
|
+
beforeTime = System.nanoTime();
|
420
|
+
}
|
421
|
+
|
422
|
+
sketch.dispose(); // call to shutdown libs?
|
423
|
+
|
424
|
+
// If the user called the exit() function, the window should close,
|
425
|
+
// rather than the sketch just halting.
|
426
|
+
if (sketch.exitCalled) {
|
427
|
+
sketch.exitActual();
|
428
|
+
}
|
342
429
|
}
|
430
|
+
}
|
343
431
|
}
|