propane 3.6.0-java → 3.10.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 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/README.md +6 -13
- data/Rakefile +7 -6
- data/lib/java/japplemenubar/JAppleMenuBar.java +88 -0
- data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/lib/java/monkstone/ColorUtil.java +127 -0
- data/lib/java/monkstone/MathToolModule.java +287 -0
- data/lib/java/monkstone/PropaneLibrary.java +46 -0
- data/lib/java/monkstone/core/LibraryProxy.java +136 -0
- data/lib/java/monkstone/fastmath/DegLutTables.java +111 -0
- data/lib/java/monkstone/fastmath/Deglut.java +71 -0
- data/lib/java/monkstone/fastmath/package-info.java +6 -0
- data/lib/java/monkstone/filechooser/Chooser.java +39 -0
- data/lib/java/monkstone/noise/FastTerrain.java +874 -0
- data/lib/java/monkstone/noise/Noise.java +90 -0
- data/lib/java/monkstone/noise/NoiseGenerator.java +75 -0
- data/lib/java/monkstone/noise/NoiseMode.java +28 -0
- data/lib/java/monkstone/noise/OpenSimplex2F.java +881 -0
- data/lib/java/monkstone/noise/OpenSimplex2S.java +1106 -0
- data/lib/java/monkstone/noise/SmoothTerrain.java +1099 -0
- data/lib/java/monkstone/slider/CustomHorizontalSlider.java +164 -0
- data/lib/java/monkstone/slider/CustomVerticalSlider.java +178 -0
- data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +145 -0
- data/lib/java/monkstone/slider/SimpleSlider.java +166 -0
- data/lib/java/monkstone/slider/SimpleVerticalSlider.java +157 -0
- data/lib/java/monkstone/slider/Slider.java +61 -0
- data/lib/java/monkstone/slider/SliderBar.java +245 -0
- data/lib/java/monkstone/slider/SliderGroup.java +56 -0
- data/lib/java/monkstone/slider/WheelHandler.java +35 -0
- data/lib/java/monkstone/vecmath/GfxRender.java +86 -0
- data/lib/java/monkstone/vecmath/JRender.java +56 -0
- data/lib/java/monkstone/vecmath/ShapeRender.java +87 -0
- data/lib/java/monkstone/vecmath/package-info.java +20 -0
- data/lib/java/monkstone/vecmath/vec2/Vec2.java +802 -0
- data/lib/java/monkstone/vecmath/vec2/package-info.java +6 -0
- data/lib/java/monkstone/vecmath/vec3/Vec3.java +727 -0
- data/lib/java/monkstone/vecmath/vec3/package-info.java +6 -0
- data/lib/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/lib/java/monkstone/videoevent/MovieEvent.java +32 -0
- data/lib/java/monkstone/videoevent/package-info.java +20 -0
- data/lib/java/processing/awt/PGraphicsJava2D.java +3040 -0
- data/lib/java/processing/awt/PImageAWT.java +377 -0
- data/lib/java/processing/awt/PShapeJava2D.java +387 -0
- data/lib/java/processing/awt/PSurfaceAWT.java +1581 -0
- data/lib/java/processing/awt/ShimAWT.java +581 -0
- data/lib/java/processing/core/PApplet.java +15156 -0
- data/lib/java/processing/core/PConstants.java +523 -0
- data/lib/java/processing/core/PFont.java +1126 -0
- data/lib/java/processing/core/PGraphics.java +8600 -0
- data/lib/java/processing/core/PImage.java +3377 -0
- data/lib/java/processing/core/PMatrix.java +208 -0
- data/lib/java/processing/core/PMatrix2D.java +562 -0
- data/lib/java/processing/core/PMatrix3D.java +890 -0
- data/lib/java/processing/core/PShape.java +3561 -0
- data/lib/java/processing/core/PShapeOBJ.java +483 -0
- data/lib/java/processing/core/PShapeSVG.java +2016 -0
- data/lib/java/processing/core/PStyle.java +63 -0
- data/lib/java/processing/core/PSurface.java +198 -0
- data/lib/java/processing/core/PSurfaceNone.java +431 -0
- data/lib/java/processing/core/PVector.java +1066 -0
- data/lib/java/processing/core/ThinkDifferent.java +115 -0
- data/lib/java/processing/data/DoubleDict.java +850 -0
- data/lib/java/processing/data/DoubleList.java +928 -0
- data/lib/java/processing/data/FloatDict.java +847 -0
- data/lib/java/processing/data/FloatList.java +936 -0
- data/lib/java/processing/data/IntDict.java +807 -0
- data/lib/java/processing/data/IntList.java +936 -0
- data/lib/java/processing/data/JSONArray.java +1260 -0
- data/lib/java/processing/data/JSONObject.java +2282 -0
- data/lib/java/processing/data/JSONTokener.java +435 -0
- data/lib/java/processing/data/LongDict.java +802 -0
- data/lib/java/processing/data/LongList.java +937 -0
- data/lib/java/processing/data/Sort.java +46 -0
- data/lib/java/processing/data/StringDict.java +613 -0
- data/lib/java/processing/data/StringList.java +800 -0
- data/lib/java/processing/data/Table.java +4936 -0
- data/lib/java/processing/data/TableRow.java +198 -0
- data/lib/java/processing/data/XML.java +1156 -0
- data/lib/java/processing/dxf/RawDXF.java +404 -0
- data/lib/java/processing/event/Event.java +125 -0
- data/lib/java/processing/event/KeyEvent.java +70 -0
- data/lib/java/processing/event/MouseEvent.java +114 -0
- data/lib/java/processing/event/TouchEvent.java +57 -0
- data/lib/java/processing/javafx/PGraphicsFX2D.java +32 -0
- data/lib/java/processing/javafx/PSurfaceFX.java +173 -0
- data/lib/java/processing/net/Client.java +744 -0
- data/lib/java/processing/net/Server.java +388 -0
- data/lib/java/processing/opengl/FontTexture.java +378 -0
- data/lib/java/processing/opengl/FrameBuffer.java +513 -0
- data/lib/java/processing/opengl/LinePath.java +627 -0
- data/lib/java/processing/opengl/LineStroker.java +681 -0
- data/lib/java/processing/opengl/PGL.java +3483 -0
- data/lib/java/processing/opengl/PGraphics2D.java +615 -0
- data/lib/java/processing/opengl/PGraphics3D.java +281 -0
- data/lib/java/processing/opengl/PGraphicsOpenGL.java +13753 -0
- data/lib/java/processing/opengl/PJOGL.java +2008 -0
- data/lib/java/processing/opengl/PShader.java +1484 -0
- data/lib/java/processing/opengl/PShapeOpenGL.java +5269 -0
- data/lib/java/processing/opengl/PSurfaceJOGL.java +1385 -0
- data/lib/java/processing/opengl/Texture.java +1696 -0
- data/lib/java/processing/opengl/VertexBuffer.java +88 -0
- data/lib/java/processing/opengl/cursors/arrow.png +0 -0
- data/lib/java/processing/opengl/cursors/cross.png +0 -0
- data/lib/java/processing/opengl/cursors/hand.png +0 -0
- data/lib/java/processing/opengl/cursors/license.txt +27 -0
- data/lib/java/processing/opengl/cursors/move.png +0 -0
- data/lib/java/processing/opengl/cursors/text.png +0 -0
- data/lib/java/processing/opengl/cursors/wait.png +0 -0
- data/lib/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
- data/lib/java/processing/opengl/shaders/ColorVert.glsl +34 -0
- data/lib/java/processing/opengl/shaders/LightFrag.glsl +33 -0
- data/lib/java/processing/opengl/shaders/LightVert.glsl +151 -0
- data/lib/java/processing/opengl/shaders/LineFrag.glsl +32 -0
- data/lib/java/processing/opengl/shaders/LineVert.glsl +100 -0
- data/lib/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
- data/lib/java/processing/opengl/shaders/PointFrag.glsl +32 -0
- data/lib/java/processing/opengl/shaders/PointVert.glsl +56 -0
- data/lib/java/processing/opengl/shaders/TexFrag.glsl +37 -0
- data/lib/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
- data/lib/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
- data/lib/java/processing/opengl/shaders/TexVert.glsl +38 -0
- data/lib/java/processing/pdf/PGraphicsPDF.java +581 -0
- data/lib/java/processing/svg/PGraphicsSVG.java +378 -0
- data/lib/propane/app.rb +9 -10
- data/lib/propane/runner.rb +10 -12
- data/lib/propane/version.rb +1 -1
- data/library/pdf/pdf.rb +7 -0
- data/library/svg/svg.rb +7 -0
- data/mvnw +3 -3
- data/mvnw.cmd +2 -2
- data/pom.rb +30 -3
- data/pom.xml +54 -3
- data/propane.gemspec +7 -3
- data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
- data/src/main/java/monkstone/MathToolModule.java +30 -30
- data/src/main/java/monkstone/PropaneLibrary.java +2 -0
- data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
- data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +6 -56
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +813 -0
- data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -0
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/JRender.java +6 -6
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +20 -19
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +12 -12
- data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -3
- data/src/main/java/processing/core/PApplet.java +13242 -13374
- data/src/main/java/processing/core/PConstants.java +155 -163
- data/src/main/java/processing/core/PGraphics.java +118 -111
- data/src/main/java/processing/opengl/PJOGL.java +6 -5
- data/src/main/java/processing/pdf/PGraphicsPDF.java +581 -0
- data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
- data/test/deglut_spec_test.rb +2 -2
- data/vendors/Rakefile +1 -1
- metadata +146 -17
- data/library/simplex_noise/simplex_noise.rb +0 -5
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -436
@@ -0,0 +1,63 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
3
|
+
/*
|
4
|
+
Part of the Processing project - http://processing.org
|
5
|
+
|
6
|
+
Copyright (c) 2008 Ben Fry and Casey Reas
|
7
|
+
|
8
|
+
This library is free software; you can redistribute it and/or
|
9
|
+
modify it under the terms of the GNU Lesser General Public
|
10
|
+
License as published by the Free Software Foundation; either
|
11
|
+
version 2.1 of the License, or (at your option) any later version.
|
12
|
+
|
13
|
+
This library is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16
|
+
Lesser General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU Lesser General
|
19
|
+
Public License along with this library; if not, write to the
|
20
|
+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
21
|
+
Boston, MA 02111-1307 USA
|
22
|
+
*/
|
23
|
+
|
24
|
+
package processing.core;
|
25
|
+
|
26
|
+
|
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;
|
63
|
+
}
|
@@ -0,0 +1,198 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
3
|
+
/*
|
4
|
+
Part of the Processing project - http://processing.org
|
5
|
+
|
6
|
+
Copyright (c) 2014-15 The Processing Foundation
|
7
|
+
|
8
|
+
This library is free software; you can redistribute it and/or
|
9
|
+
modify it under the terms of the GNU Lesser General Public
|
10
|
+
License as published by the Free Software Foundation, version 2.1.
|
11
|
+
|
12
|
+
This library is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General
|
18
|
+
Public License along with this library; if not, write to the
|
19
|
+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
|
+
Boston, MA 02111-1307 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
package processing.core;
|
24
|
+
|
25
|
+
import java.io.File;
|
26
|
+
|
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);
|
41
|
+
|
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,
|
52
|
+
// public void initFrame(PApplet sketch, int backgroundColor,
|
53
|
+
// int deviceIndex, boolean fullScreen, boolean spanDisplays);
|
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
|
+
|
110
|
+
// public void placeWindow(int[] location);
|
111
|
+
|
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
|
+
//
|
121
|
+
|
122
|
+
// sets displayWidth/Height inside PApplet
|
123
|
+
//public void checkDisplaySize();
|
124
|
+
|
125
|
+
public void setLocation(int x, int y);
|
126
|
+
|
127
|
+
public void setSize(int width, int height);
|
128
|
+
|
129
|
+
// /**
|
130
|
+
// * Called by {@link PApplet#createGraphics} to initialize the
|
131
|
+
// * {@link PGraphics#image} object with an image that's compatible with this
|
132
|
+
// * drawing surface/display/hardware.
|
133
|
+
// * @param gr PGraphics object whose image will be set
|
134
|
+
// * @param wide
|
135
|
+
// * @param high
|
136
|
+
// */
|
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
|
140
|
+
// public void initImage(PGraphics gr);
|
141
|
+
|
142
|
+
//public Component getComponent();
|
143
|
+
|
144
|
+
// /**
|
145
|
+
// * Sometimes smoothing must be set at the drawing surface level
|
146
|
+
// * not just inside the renderer itself.
|
147
|
+
// */
|
148
|
+
// public void setSmooth(int level);
|
149
|
+
|
150
|
+
public void setFrameRate(float fps);
|
151
|
+
|
152
|
+
// // called on the first frame so that the now-visible drawing surface can
|
153
|
+
// // receive key and mouse events
|
154
|
+
// public void requestFocus();
|
155
|
+
|
156
|
+
// // finish rendering to the screen (called by PApplet)
|
157
|
+
// public void blit();
|
158
|
+
|
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
|
+
//
|
170
|
+
|
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);
|
176
|
+
|
177
|
+
//
|
178
|
+
|
179
|
+
/** Start the animation thread */
|
180
|
+
public void startThread();
|
181
|
+
|
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();
|
188
|
+
|
189
|
+
public void resumeThread();
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Stop the animation thread (set it null)
|
193
|
+
* @return false if already stopped
|
194
|
+
*/
|
195
|
+
public boolean stopThread();
|
196
|
+
|
197
|
+
public boolean isStopped();
|
198
|
+
}
|
@@ -0,0 +1,431 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
3
|
+
/*
|
4
|
+
Part of the Processing project - http://processing.org
|
5
|
+
|
6
|
+
Copyright (c) 2015 The Processing Foundation
|
7
|
+
|
8
|
+
This library is free software; you can redistribute it and/or
|
9
|
+
modify it under the terms of the GNU Lesser General Public
|
10
|
+
License as published by the Free Software Foundation, version 2.1.
|
11
|
+
|
12
|
+
This library is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General
|
18
|
+
Public License along with this library; if not, write to the
|
19
|
+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
|
+
Boston, MA 02111-1307 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
package processing.core;
|
24
|
+
|
25
|
+
import java.io.File;
|
26
|
+
|
27
|
+
import processing.awt.ShimAWT;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Surface that's not really visible. Used for PDF and friends, or as a base
|
31
|
+
* class for other drawing surfaces. It includes the standard rendering loop.
|
32
|
+
*/
|
33
|
+
public class PSurfaceNone implements PSurface {
|
34
|
+
protected PApplet sketch;
|
35
|
+
protected PGraphics graphics;
|
36
|
+
|
37
|
+
protected Thread thread;
|
38
|
+
protected boolean paused;
|
39
|
+
protected Object pauseObject = new Object();
|
40
|
+
|
41
|
+
protected float frameRateTarget = 60;
|
42
|
+
protected long frameRatePeriod = 1000000000L / 60L;
|
43
|
+
|
44
|
+
|
45
|
+
public PSurfaceNone(PGraphics graphics) {
|
46
|
+
this.graphics = graphics;
|
47
|
+
}
|
48
|
+
|
49
|
+
|
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
|
+
|
91
|
+
|
92
|
+
// public Component initComponent(PApplet sketch) {
|
93
|
+
// return null;
|
94
|
+
// }
|
95
|
+
|
96
|
+
|
97
|
+
@Override
|
98
|
+
public void initFrame(PApplet sketch) {
|
99
|
+
throw new IllegalStateException("initFrame() not available with " +
|
100
|
+
getClass().getSimpleName());
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
@Override
|
105
|
+
public Object getNative() {
|
106
|
+
return null;
|
107
|
+
}
|
108
|
+
|
109
|
+
|
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
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
@Override
|
119
|
+
public void setIcon(PImage image) {
|
120
|
+
// I ain't visible, man.
|
121
|
+
}
|
122
|
+
|
123
|
+
|
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
|
+
}
|
130
|
+
|
131
|
+
|
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
|
+
}
|
163
|
+
|
164
|
+
|
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);
|
170
|
+
}
|
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
|
+
|
189
|
+
// public void initImage(PGraphics graphics) {
|
190
|
+
// // TODO Auto-generated method stub
|
191
|
+
//
|
192
|
+
// }
|
193
|
+
|
194
|
+
// public Component getComponent() {
|
195
|
+
// return null;
|
196
|
+
// }
|
197
|
+
|
198
|
+
|
199
|
+
// public void setSmooth(int level) {
|
200
|
+
// // TODO Auto-generated method stub
|
201
|
+
// }
|
202
|
+
|
203
|
+
// void requestFocus() {
|
204
|
+
// }
|
205
|
+
|
206
|
+
// public void blit() {
|
207
|
+
// // TODO Auto-generated method stub
|
208
|
+
// }
|
209
|
+
|
210
|
+
@Override
|
211
|
+
public void setCursor(int kind) { }
|
212
|
+
|
213
|
+
@Override
|
214
|
+
public void setCursor(PImage image, int hotspotX, int hotspotY) { }
|
215
|
+
|
216
|
+
@Override
|
217
|
+
public void showCursor() { }
|
218
|
+
|
219
|
+
@Override
|
220
|
+
public void hideCursor() { }
|
221
|
+
|
222
|
+
|
223
|
+
//
|
224
|
+
|
225
|
+
|
226
|
+
@Override
|
227
|
+
public boolean openLink(String url) {
|
228
|
+
return false;
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
//
|
233
|
+
|
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());
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
@Override
|
253
|
+
public boolean stopThread() {
|
254
|
+
if (thread == null) {
|
255
|
+
return false;
|
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
|
+
}
|
274
|
+
|
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();
|
282
|
+
// PApplet.debug("out of wait");
|
283
|
+
} catch (InterruptedException e) {
|
284
|
+
// waiting for this interrupt on a start() (resume) call
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
// PApplet.debug("done with pause");
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
@Override
|
293
|
+
public void resumeThread() {
|
294
|
+
paused = false;
|
295
|
+
synchronized (pauseObject) {
|
296
|
+
pauseObject.notifyAll(); // wake up the animation thread
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
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");
|
313
|
+
}
|
314
|
+
|
315
|
+
// broken out so it can be overridden by Danger et al
|
316
|
+
public void callDraw() {
|
317
|
+
sketch.handleDraw();
|
318
|
+
}
|
319
|
+
|
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;
|
328
|
+
|
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;
|
333
|
+
|
334
|
+
/*
|
335
|
+
// If size un-initialized, might be a Canvas. Call setSize() here since
|
336
|
+
// we now have a parent object that this Canvas can use as a peer.
|
337
|
+
if (graphics.image == null) {
|
338
|
+
// System.out.format("it's null, sketchW/H already set to %d %d%n", sketchWidth, sketchHeight);
|
339
|
+
try {
|
340
|
+
EventQueue.invokeAndWait(new Runnable() {
|
341
|
+
public void run() {
|
342
|
+
setSize(sketchWidth, sketchHeight);
|
343
|
+
}
|
344
|
+
});
|
345
|
+
} catch (InterruptedException ie) {
|
346
|
+
ie.printStackTrace();
|
347
|
+
} catch (InvocationTargetException ite) {
|
348
|
+
ite.printStackTrace();
|
349
|
+
}
|
350
|
+
// System.out.format(" but now, sketchW/H changed to %d %d%n", sketchWidth, sketchHeight);
|
351
|
+
}
|
352
|
+
*/
|
353
|
+
|
354
|
+
// un-pause the sketch and get rolling
|
355
|
+
sketch.start();
|
356
|
+
|
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.
|
362
|
+
// Dimension currentSize = canvas.getSize();
|
363
|
+
// if (currentSize.width != sketchWidth || currentSize.height != sketchHeight) {
|
364
|
+
// System.err.format("need to resize from %s to %d, %d%n", currentSize, sketchWidth, sketchHeight);
|
365
|
+
// }
|
366
|
+
|
367
|
+
// render a single frame
|
368
|
+
// try {
|
369
|
+
// EventQueue.invokeAndWait(new Runnable() {
|
370
|
+
// public void run() {
|
371
|
+
// System.out.println("calling draw, finished = " + sketch.finished);
|
372
|
+
//System.out.println("calling draw, looping = " + sketch.looping + ", frameCount = " + sketch.frameCount);
|
373
|
+
callDraw();
|
374
|
+
|
375
|
+
// EventQueue.invokeLater(new Runnable() {
|
376
|
+
// public void run() {
|
377
|
+
// if (sketch.frameCount == 1) {
|
378
|
+
// requestFocus();
|
379
|
+
// }
|
380
|
+
// }
|
381
|
+
// });
|
382
|
+
|
383
|
+
// }
|
384
|
+
// });
|
385
|
+
// } catch (InterruptedException ie) {
|
386
|
+
// ie.printStackTrace();
|
387
|
+
// } catch (InvocationTargetException ite) {
|
388
|
+
// ite.getTargetException().printStackTrace();
|
389
|
+
// }
|
390
|
+
|
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
|
395
|
+
|
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
|
+
}
|
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
|
+
}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|