propane 2.7.2-java → 2.8.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/CHANGELOG.md +1 -1
- data/README.md +10 -8
- data/Rakefile +1 -1
- data/lib/propane/app.rb +3 -3
- data/lib/propane/version.rb +1 -1
- data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
- data/library/control_panel/control_panel.rb +3 -2
- data/pom.rb +89 -88
- data/pom.xml +75 -46
- data/propane.gemspec +1 -2
- data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
- data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
- data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
- data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
- data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
- data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
- data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
- data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
- data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
- data/src/main/java/processing/core/PApplet.java +15709 -0
- data/src/main/java/processing/core/PConstants.java +527 -0
- data/src/main/java/processing/core/PFont.java +1098 -0
- data/src/main/java/processing/core/PGraphics.java +8467 -0
- data/src/main/java/processing/core/PImage.java +3438 -0
- data/src/main/java/processing/core/PMatrix.java +208 -0
- data/src/main/java/processing/core/PMatrix2D.java +534 -0
- data/src/main/java/processing/core/PMatrix3D.java +877 -0
- data/src/main/java/processing/core/PShape.java +3445 -0
- data/src/main/java/processing/core/PShapeOBJ.java +469 -0
- data/src/main/java/processing/core/PShapeSVG.java +1787 -0
- data/src/main/java/processing/core/PStyle.java +63 -0
- data/src/main/java/processing/core/PSurface.java +161 -0
- data/src/main/java/processing/core/PSurfaceNone.java +374 -0
- data/src/main/java/processing/core/PVector.java +1063 -0
- data/src/main/java/processing/data/FloatDict.java +829 -0
- data/src/main/java/processing/data/FloatList.java +912 -0
- data/src/main/java/processing/data/IntDict.java +796 -0
- data/src/main/java/processing/data/IntList.java +913 -0
- data/src/main/java/processing/data/JSONArray.java +1260 -0
- data/src/main/java/processing/data/JSONObject.java +2282 -0
- data/src/main/java/processing/data/JSONTokener.java +435 -0
- data/src/main/java/processing/data/Sort.java +46 -0
- data/src/main/java/processing/data/StringDict.java +601 -0
- data/src/main/java/processing/data/StringList.java +775 -0
- data/src/main/java/processing/data/Table.java +4923 -0
- data/src/main/java/processing/data/TableRow.java +198 -0
- data/src/main/java/processing/data/XML.java +1149 -0
- data/src/main/java/processing/event/Event.java +125 -0
- data/src/main/java/processing/event/KeyEvent.java +70 -0
- data/src/main/java/processing/event/MouseEvent.java +149 -0
- data/src/main/java/processing/event/TouchEvent.java +57 -0
- data/src/main/java/processing/opengl/FontTexture.java +379 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
- data/src/main/java/processing/opengl/LinePath.java +623 -0
- data/src/main/java/processing/opengl/LineStroker.java +685 -0
- data/src/main/java/processing/opengl/PGL.java +3366 -0
- data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
- data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
- data/src/main/java/processing/opengl/PJOGL.java +1966 -0
- data/src/main/java/processing/opengl/PShader.java +1478 -0
- data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
- data/src/main/java/processing/opengl/Texture.java +1670 -0
- data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
- data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
- data/src/main/java/processing/opengl/cursors/cross.png +0 -0
- data/src/main/java/processing/opengl/cursors/hand.png +0 -0
- data/src/main/java/processing/opengl/cursors/license.txt +27 -0
- data/src/main/java/processing/opengl/cursors/move.png +0 -0
- data/src/main/java/processing/opengl/cursors/text.png +0 -0
- data/src/main/java/processing/opengl/cursors/wait.png +0 -0
- data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
- data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
- data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
- data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
- data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
- data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
- data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
- data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
- data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/src/main/resources/license.txt +508 -0
- data/vendors/Rakefile +5 -20
- metadata +115 -33
- data/lib/propane.jar +0 -0
@@ -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,161 @@
|
|
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
|
+
|
26
|
+
public interface PSurface {
|
27
|
+
/**
|
28
|
+
* Minimum dimensions for the window holding an applet. This varies between
|
29
|
+
* platforms, Mac OS X 10.3 (confirmed with 10.7 and Java 6) can do any
|
30
|
+
* height but requires at least 128 pixels width. Windows XP has another
|
31
|
+
* set of limitations. And for all I know, Linux probably allows window
|
32
|
+
* sizes to be negative numbers.
|
33
|
+
*/
|
34
|
+
static public final int MIN_WINDOW_WIDTH = 128;
|
35
|
+
static public final int MIN_WINDOW_HEIGHT = 128;
|
36
|
+
|
37
|
+
// renderer that doesn't draw to the screen
|
38
|
+
public void initOffscreen(PApplet sketch);
|
39
|
+
|
40
|
+
// considering removal in favor of separate Component classes for appropriate renderers
|
41
|
+
// (i.e. for Java2D or a generic Image surface, but not PDF, debatable for GL or FX)
|
42
|
+
//public Component initComponent(PApplet sketch);
|
43
|
+
|
44
|
+
//public Frame initFrame(PApplet sketch, Color backgroundColor,
|
45
|
+
// public void initFrame(PApplet sketch, int backgroundColor,
|
46
|
+
// int deviceIndex, boolean fullScreen, boolean spanDisplays);
|
47
|
+
public void initFrame(PApplet sketch);
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Get the native window object associated with this drawing surface.
|
51
|
+
* For Java2D, this will be an AWT Frame object. For OpenGL, the window.
|
52
|
+
* The data returned here is subject to the whims of the renderer,
|
53
|
+
* and using this method means you're willing to deal with underlying
|
54
|
+
* implementation changes and that you won't throw a fit like a toddler
|
55
|
+
* if your code breaks sometime in the future.
|
56
|
+
*/
|
57
|
+
public Object getNative();
|
58
|
+
|
59
|
+
//
|
60
|
+
|
61
|
+
// Just call these on an AWT Frame object stored in PApplet.
|
62
|
+
// Silly, but prevents a lot of rewrite and extra methods for little benefit.
|
63
|
+
// However, maybe prevents us from having to document the 'frame' variable?
|
64
|
+
|
65
|
+
/** Set the window (and dock, or whatever necessary) title. */
|
66
|
+
public void setTitle(String title);
|
67
|
+
|
68
|
+
/** Show or hide the window. */
|
69
|
+
public void setVisible(boolean visible);
|
70
|
+
|
71
|
+
/** Set true if we want to resize things (default is not resizable) */
|
72
|
+
public void setResizable(boolean resizable);
|
73
|
+
|
74
|
+
/** Dumb name, but inherited from Frame and no better ideas. */
|
75
|
+
public void setAlwaysOnTop(boolean always);
|
76
|
+
|
77
|
+
public void setIcon(PImage icon);
|
78
|
+
|
79
|
+
//
|
80
|
+
|
81
|
+
// public void placeWindow(int[] location);
|
82
|
+
|
83
|
+
public void placeWindow(int[] location, int[] editorLocation);
|
84
|
+
|
85
|
+
//public void placeFullScreen(boolean hideStop);
|
86
|
+
public void placePresent(int stopColor);
|
87
|
+
|
88
|
+
// Sketch is running from the PDE, set up messaging back to the PDE
|
89
|
+
public void setupExternalMessages();
|
90
|
+
|
91
|
+
//
|
92
|
+
|
93
|
+
// sets displayWidth/Height inside PApplet
|
94
|
+
//public void checkDisplaySize();
|
95
|
+
|
96
|
+
public void setLocation(int x, int y);
|
97
|
+
|
98
|
+
public void setSize(int width, int height);
|
99
|
+
|
100
|
+
// /**
|
101
|
+
// * Called by {@link PApplet#createGraphics} to initialize the
|
102
|
+
// * {@link PGraphics#image} object with an image that's compatible with this
|
103
|
+
// * drawing surface/display/hardware.
|
104
|
+
// * @param gr PGraphics object whose image will be set
|
105
|
+
// * @param wide
|
106
|
+
// * @param high
|
107
|
+
// */
|
108
|
+
// create pixel buffer (pulled out for offscreen graphics)
|
109
|
+
//public void initImage(PGraphics gr, int wide, int high);
|
110
|
+
// create pixel buffer, called from allocate() to produce a compatible image for rendering efficiently
|
111
|
+
// public void initImage(PGraphics gr);
|
112
|
+
|
113
|
+
//public Component getComponent();
|
114
|
+
|
115
|
+
// /**
|
116
|
+
// * Sometimes smoothing must be set at the drawing surface level
|
117
|
+
// * not just inside the renderer itself.
|
118
|
+
// */
|
119
|
+
// public void setSmooth(int level);
|
120
|
+
|
121
|
+
public void setFrameRate(float fps);
|
122
|
+
|
123
|
+
// // called on the first frame so that the now-visible drawing surface can
|
124
|
+
// // receive key and mouse events
|
125
|
+
// public void requestFocus();
|
126
|
+
|
127
|
+
// // finish rendering to the screen (called by PApplet)
|
128
|
+
// public void blit();
|
129
|
+
|
130
|
+
//
|
131
|
+
|
132
|
+
public void setCursor(int kind);
|
133
|
+
|
134
|
+
public void setCursor(PImage image, int hotspotX, int hotspotY);
|
135
|
+
|
136
|
+
public void showCursor();
|
137
|
+
|
138
|
+
public void hideCursor();
|
139
|
+
|
140
|
+
//
|
141
|
+
|
142
|
+
/** Start the animation thread */
|
143
|
+
public void startThread();
|
144
|
+
|
145
|
+
/**
|
146
|
+
* On the next trip through the animation thread, things should go sleepy-bye.
|
147
|
+
* Does not pause the thread immediately because that needs to happen on the
|
148
|
+
* animation thread itself, so fires on the next trip through draw().
|
149
|
+
*/
|
150
|
+
public void pauseThread();
|
151
|
+
|
152
|
+
public void resumeThread();
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Stop the animation thread (set it null)
|
156
|
+
* @return false if already stopped
|
157
|
+
*/
|
158
|
+
public boolean stopThread();
|
159
|
+
|
160
|
+
public boolean isStopped();
|
161
|
+
}
|
@@ -0,0 +1,374 @@
|
|
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
|
+
|
26
|
+
/**
|
27
|
+
* Surface that's not really visible. Used for PDF and friends, or as a base
|
28
|
+
* class for other drawing surfaces. It includes the standard rendering loop.
|
29
|
+
*/
|
30
|
+
public class PSurfaceNone implements PSurface {
|
31
|
+
protected PApplet sketch;
|
32
|
+
protected PGraphics graphics;
|
33
|
+
|
34
|
+
protected Thread thread;
|
35
|
+
protected boolean paused;
|
36
|
+
protected Object pauseObject = new Object();
|
37
|
+
|
38
|
+
protected float frameRateTarget = 60;
|
39
|
+
protected long frameRatePeriod = 1000000000L / 60L;
|
40
|
+
|
41
|
+
|
42
|
+
public PSurfaceNone(PGraphics graphics) {
|
43
|
+
this.graphics = graphics;
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
@Override
|
48
|
+
public void initOffscreen(PApplet sketch) {
|
49
|
+
this.sketch = sketch;
|
50
|
+
|
51
|
+
setSize(sketch.sketchWidth(), sketch.sketchHeight());
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
// public Component initComponent(PApplet sketch) {
|
56
|
+
// return null;
|
57
|
+
// }
|
58
|
+
|
59
|
+
|
60
|
+
@Override
|
61
|
+
public void initFrame(PApplet sketch) {/*, int backgroundColor,
|
62
|
+
int deviceIndex, boolean fullScreen,
|
63
|
+
boolean spanDisplays) {*/
|
64
|
+
//this.sketch = sketch;
|
65
|
+
throw new IllegalStateException("initFrame() not available with " +
|
66
|
+
getClass().getSimpleName());
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
public Object getNative() {
|
71
|
+
return null;
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
/** Set the window (and dock, or whatever necessary) title. */
|
76
|
+
@Override
|
77
|
+
public void setTitle(String title) {
|
78
|
+
// You're in a utopian PSurface implementation where titles don't exist.
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
@Override
|
83
|
+
public void setIcon(PImage image) {
|
84
|
+
// I ain't visible, man.
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
/** Show or hide the window. */
|
89
|
+
@Override
|
90
|
+
public void setVisible(boolean visible) {
|
91
|
+
// I'm always invisible. You can't catch me.
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
/** Set true if we want to resize things (default is not resizable) */
|
96
|
+
@Override
|
97
|
+
public void setResizable(boolean resizable) {
|
98
|
+
// I don't need size to know my worth.
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
@Override
|
103
|
+
public void placeWindow(int[] location, int[] editorLocation) { }
|
104
|
+
|
105
|
+
|
106
|
+
@Override
|
107
|
+
public void placePresent(int stopColor) { }
|
108
|
+
|
109
|
+
|
110
|
+
@Override
|
111
|
+
public void setupExternalMessages() { }
|
112
|
+
|
113
|
+
|
114
|
+
@Override
|
115
|
+
public void setAlwaysOnTop(boolean always) { }
|
116
|
+
|
117
|
+
|
118
|
+
//
|
119
|
+
|
120
|
+
|
121
|
+
@Override
|
122
|
+
public void setLocation(int x, int y) {
|
123
|
+
// I'm everywhere, because I'm nowhere.
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
@Override
|
128
|
+
public void setSize(int wide, int high) {
|
129
|
+
if (PApplet.DEBUG) {
|
130
|
+
//System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
|
131
|
+
new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
|
132
|
+
}
|
133
|
+
|
134
|
+
//if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
|
135
|
+
if (wide == sketch.width && high == sketch.height) {
|
136
|
+
if (PApplet.DEBUG) {
|
137
|
+
new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
|
138
|
+
}
|
139
|
+
return; // unchanged, don't rebuild everything
|
140
|
+
}
|
141
|
+
|
142
|
+
//throw new RuntimeException("implement me, see readme.md");
|
143
|
+
sketch.width = wide;
|
144
|
+
sketch.height = high;
|
145
|
+
|
146
|
+
// set PGraphics variables for width/height/pixelWidth/pixelHeight
|
147
|
+
graphics.setSize(wide, high);
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
// public void initImage(PGraphics graphics) {
|
152
|
+
// // TODO Auto-generated method stub
|
153
|
+
//
|
154
|
+
// }
|
155
|
+
|
156
|
+
// public Component getComponent() {
|
157
|
+
// return null;
|
158
|
+
// }
|
159
|
+
|
160
|
+
|
161
|
+
// public void setSmooth(int level) {
|
162
|
+
// // TODO Auto-generated method stub
|
163
|
+
// }
|
164
|
+
|
165
|
+
// void requestFocus() {
|
166
|
+
// }
|
167
|
+
|
168
|
+
// public void blit() {
|
169
|
+
// // TODO Auto-generated method stub
|
170
|
+
// }
|
171
|
+
|
172
|
+
public void setCursor(int kind) { }
|
173
|
+
|
174
|
+
public void setCursor(PImage image, int hotspotX, int hotspotY) { }
|
175
|
+
|
176
|
+
public void showCursor() { }
|
177
|
+
|
178
|
+
public void hideCursor() { }
|
179
|
+
|
180
|
+
|
181
|
+
//
|
182
|
+
|
183
|
+
|
184
|
+
public Thread createThread() {
|
185
|
+
return new AnimationThread();
|
186
|
+
}
|
187
|
+
|
188
|
+
|
189
|
+
public void startThread() {
|
190
|
+
if (thread == null) {
|
191
|
+
thread = createThread();
|
192
|
+
thread.start();
|
193
|
+
} else {
|
194
|
+
throw new IllegalStateException("Thread already started in " +
|
195
|
+
getClass().getSimpleName());
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
public boolean stopThread() {
|
201
|
+
if (thread == null) {
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
thread = null;
|
205
|
+
return true;
|
206
|
+
}
|
207
|
+
|
208
|
+
|
209
|
+
public boolean isStopped() {
|
210
|
+
return thread == null || !thread.isAlive();
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
// sets a flag to pause the thread when ready
|
215
|
+
public void pauseThread() {
|
216
|
+
PApplet.debug("PApplet.run() paused, calling object wait...");
|
217
|
+
paused = true;
|
218
|
+
}
|
219
|
+
|
220
|
+
|
221
|
+
// halts the animation thread if the pause flag is set
|
222
|
+
protected void checkPause() {
|
223
|
+
if (paused) {
|
224
|
+
synchronized (pauseObject) {
|
225
|
+
try {
|
226
|
+
pauseObject.wait();
|
227
|
+
// PApplet.debug("out of wait");
|
228
|
+
} catch (InterruptedException e) {
|
229
|
+
// waiting for this interrupt on a start() (resume) call
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
// PApplet.debug("done with pause");
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
public void resumeThread() {
|
238
|
+
paused = false;
|
239
|
+
synchronized (pauseObject) {
|
240
|
+
pauseObject.notifyAll(); // wake up the animation thread
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
public void setFrameRate(float fps) {
|
246
|
+
frameRateTarget = fps;
|
247
|
+
frameRatePeriod = (long) (1000000000.0 / frameRateTarget);
|
248
|
+
//g.setFrameRate(fps);
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
public class AnimationThread extends Thread {
|
253
|
+
|
254
|
+
public AnimationThread() {
|
255
|
+
super("Animation Thread");
|
256
|
+
}
|
257
|
+
|
258
|
+
// broken out so it can be overridden by Danger et al
|
259
|
+
public void callDraw() {
|
260
|
+
sketch.handleDraw();
|
261
|
+
}
|
262
|
+
|
263
|
+
/**
|
264
|
+
* Main method for the primary animation thread.
|
265
|
+
* <A HREF="http://java.sun.com/products/jfc/tsc/articles/painting/">Painting in AWT and Swing</A>
|
266
|
+
*/
|
267
|
+
@Override
|
268
|
+
public void run() { // not good to make this synchronized, locks things up
|
269
|
+
long beforeTime = System.nanoTime();
|
270
|
+
long overSleepTime = 0L;
|
271
|
+
|
272
|
+
int noDelays = 0;
|
273
|
+
// Number of frames with a delay of 0 ms before the
|
274
|
+
// animation thread yields to other running threads.
|
275
|
+
final int NO_DELAYS_PER_YIELD = 15;
|
276
|
+
|
277
|
+
/*
|
278
|
+
// If size un-initialized, might be a Canvas. Call setSize() here since
|
279
|
+
// we now have a parent object that this Canvas can use as a peer.
|
280
|
+
if (graphics.image == null) {
|
281
|
+
// System.out.format("it's null, sketchW/H already set to %d %d%n", sketchWidth, sketchHeight);
|
282
|
+
try {
|
283
|
+
EventQueue.invokeAndWait(new Runnable() {
|
284
|
+
public void run() {
|
285
|
+
setSize(sketchWidth, sketchHeight);
|
286
|
+
}
|
287
|
+
});
|
288
|
+
} catch (InterruptedException ie) {
|
289
|
+
ie.printStackTrace();
|
290
|
+
} catch (InvocationTargetException ite) {
|
291
|
+
ite.printStackTrace();
|
292
|
+
}
|
293
|
+
// System.out.format(" but now, sketchW/H changed to %d %d%n", sketchWidth, sketchHeight);
|
294
|
+
}
|
295
|
+
*/
|
296
|
+
|
297
|
+
// un-pause the sketch and get rolling
|
298
|
+
sketch.start();
|
299
|
+
|
300
|
+
while ((Thread.currentThread() == thread) && !sketch.finished) {
|
301
|
+
checkPause();
|
302
|
+
|
303
|
+
// Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
|
304
|
+
// otherwise it may attempt a resize mid-render.
|
305
|
+
// Dimension currentSize = canvas.getSize();
|
306
|
+
// if (currentSize.width != sketchWidth || currentSize.height != sketchHeight) {
|
307
|
+
// System.err.format("need to resize from %s to %d, %d%n", currentSize, sketchWidth, sketchHeight);
|
308
|
+
// }
|
309
|
+
|
310
|
+
// render a single frame
|
311
|
+
// try {
|
312
|
+
// EventQueue.invokeAndWait(new Runnable() {
|
313
|
+
// public void run() {
|
314
|
+
// System.out.println("calling draw, finished = " + sketch.finished);
|
315
|
+
//System.out.println("calling draw, looping = " + sketch.looping + ", frameCount = " + sketch.frameCount);
|
316
|
+
callDraw();
|
317
|
+
|
318
|
+
// EventQueue.invokeLater(new Runnable() {
|
319
|
+
// public void run() {
|
320
|
+
// if (sketch.frameCount == 1) {
|
321
|
+
// requestFocus();
|
322
|
+
// }
|
323
|
+
// }
|
324
|
+
// });
|
325
|
+
|
326
|
+
// }
|
327
|
+
// });
|
328
|
+
// } catch (InterruptedException ie) {
|
329
|
+
// ie.printStackTrace();
|
330
|
+
// } catch (InvocationTargetException ite) {
|
331
|
+
// ite.getTargetException().printStackTrace();
|
332
|
+
// }
|
333
|
+
|
334
|
+
// wait for update & paint to happen before drawing next frame
|
335
|
+
// this is necessary since the drawing is sometimes in a
|
336
|
+
// separate thread, meaning that the next frame will start
|
337
|
+
// before the update/paint is completed
|
338
|
+
|
339
|
+
long afterTime = System.nanoTime();
|
340
|
+
long timeDiff = afterTime - beforeTime;
|
341
|
+
//System.out.println("time diff is " + timeDiff);
|
342
|
+
long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
|
343
|
+
|
344
|
+
if (sleepTime > 0) { // some time left in this cycle
|
345
|
+
try {
|
346
|
+
Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
|
347
|
+
noDelays = 0; // Got some sleep, not delaying anymore
|
348
|
+
} catch (InterruptedException ex) { }
|
349
|
+
|
350
|
+
overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
|
351
|
+
|
352
|
+
} else { // sleepTime <= 0; the frame took longer than the period
|
353
|
+
overSleepTime = 0L;
|
354
|
+
noDelays++;
|
355
|
+
|
356
|
+
if (noDelays > NO_DELAYS_PER_YIELD) {
|
357
|
+
Thread.yield(); // give another thread a chance to run
|
358
|
+
noDelays = 0;
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
beforeTime = System.nanoTime();
|
363
|
+
}
|
364
|
+
|
365
|
+
sketch.dispose(); // call to shutdown libs?
|
366
|
+
|
367
|
+
// If the user called the exit() function, the window should close,
|
368
|
+
// rather than the sketch just halting.
|
369
|
+
if (sketch.exitCalled) {
|
370
|
+
sketch.exitActual();
|
371
|
+
}
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|