propane 3.1.0.pre-java → 3.2.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -0
  3. data/CHANGELOG.md +1 -5
  4. data/README.md +23 -12
  5. data/Rakefile +23 -12
  6. data/lib/propane/helpers/version_error.rb +6 -0
  7. data/lib/propane/runner.rb +12 -0
  8. data/lib/propane/version.rb +1 -1
  9. data/library/slider/slider.rb +1 -1
  10. data/mvnw +234 -0
  11. data/mvnw.cmd +145 -0
  12. data/pom.xml +28 -27
  13. data/propane.gemspec +2 -2
  14. data/src/main/java/japplemenubar/JAppleMenuBar.java +41 -47
  15. data/src/main/java/monkstone/ColorUtil.java +1 -1
  16. data/src/main/java/monkstone/MathToolModule.java +12 -11
  17. data/src/main/java/monkstone/PropaneLibrary.java +9 -10
  18. data/src/main/java/monkstone/core/LibraryProxy.java +124 -113
  19. data/src/main/java/monkstone/fastmath/Deglut.java +86 -89
  20. data/src/main/java/monkstone/filechooser/Chooser.java +7 -13
  21. data/src/main/java/monkstone/noise/SimplexNoise.java +0 -1
  22. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +4 -4
  23. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  24. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +9 -9
  25. data/src/main/java/monkstone/slider/SimpleSlider.java +0 -9
  26. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +11 -13
  27. data/src/main/java/monkstone/slider/Slider.java +1 -1
  28. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  29. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  30. data/src/main/java/monkstone/slider/WheelHandler.java +8 -9
  31. data/src/main/java/monkstone/vecmath/AppRender.java +2 -2
  32. data/src/main/java/monkstone/vecmath/ShapeRender.java +2 -2
  33. data/src/main/java/monkstone/vecmath/package-info.java +2 -2
  34. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
  35. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  36. data/src/main/java/monkstone/videoevent/VideoInterface.java +11 -5
  37. data/src/main/java/monkstone/videoevent/package-info.java +2 -2
  38. data/src/main/java/processing/awt/PGraphicsJava2D.java +1742 -2243
  39. data/src/main/java/processing/awt/PShapeJava2D.java +268 -270
  40. data/src/main/java/processing/awt/PSurfaceAWT.java +821 -920
  41. data/src/main/java/processing/core/DesktopHandler.java +94 -0
  42. data/src/main/java/processing/core/PApplet.java +14170 -14082
  43. data/src/main/java/processing/core/PConstants.java +447 -473
  44. data/src/main/java/processing/core/PFont.java +867 -873
  45. data/src/main/java/processing/core/PGraphics.java +7193 -7428
  46. data/src/main/java/processing/core/PImage.java +3051 -3117
  47. data/src/main/java/processing/core/PMatrix.java +159 -172
  48. data/src/main/java/processing/core/PMatrix2D.java +403 -444
  49. data/src/main/java/processing/core/PMatrix3D.java +735 -749
  50. data/src/main/java/processing/core/PShape.java +2651 -2793
  51. data/src/main/java/processing/core/PShapeOBJ.java +415 -422
  52. data/src/main/java/processing/core/PShapeSVG.java +1466 -1475
  53. data/src/main/java/processing/core/PStyle.java +37 -40
  54. data/src/main/java/processing/core/PSurface.java +98 -103
  55. data/src/main/java/processing/core/PSurfaceNone.java +208 -236
  56. data/src/main/java/processing/core/PVector.java +961 -990
  57. data/src/main/java/processing/data/DoubleDict.java +709 -753
  58. data/src/main/java/processing/data/DoubleList.java +695 -748
  59. data/src/main/java/processing/data/FloatDict.java +702 -746
  60. data/src/main/java/processing/data/FloatList.java +697 -751
  61. data/src/main/java/processing/data/IntDict.java +673 -718
  62. data/src/main/java/processing/data/IntList.java +633 -699
  63. data/src/main/java/processing/data/JSONArray.java +873 -931
  64. data/src/main/java/processing/data/JSONObject.java +1165 -1262
  65. data/src/main/java/processing/data/JSONTokener.java +341 -351
  66. data/src/main/java/processing/data/LongDict.java +662 -707
  67. data/src/main/java/processing/data/LongList.java +634 -700
  68. data/src/main/java/processing/data/Sort.java +41 -37
  69. data/src/main/java/processing/data/StringDict.java +486 -522
  70. data/src/main/java/processing/data/StringList.java +580 -624
  71. data/src/main/java/processing/data/Table.java +3508 -3686
  72. data/src/main/java/processing/data/TableRow.java +183 -182
  73. data/src/main/java/processing/data/XML.java +883 -957
  74. data/src/main/java/processing/event/Event.java +66 -87
  75. data/src/main/java/processing/event/KeyEvent.java +41 -48
  76. data/src/main/java/processing/event/MouseEvent.java +93 -103
  77. data/src/main/java/processing/event/TouchEvent.java +6 -10
  78. data/src/main/java/processing/javafx/PGraphicsFX2D.java +5 -69
  79. data/src/main/java/processing/javafx/PSurfaceFX.java +2 -7
  80. data/src/main/java/processing/opengl/FontTexture.java +270 -290
  81. data/src/main/java/processing/opengl/FrameBuffer.java +363 -375
  82. data/src/main/java/processing/opengl/LinePath.java +500 -543
  83. data/src/main/java/processing/opengl/LineStroker.java +582 -593
  84. data/src/main/java/processing/opengl/PGL.java +2881 -2904
  85. data/src/main/java/processing/opengl/PGraphics2D.java +315 -408
  86. data/src/main/java/processing/opengl/PGraphics3D.java +72 -107
  87. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12043 -12230
  88. data/src/main/java/processing/opengl/PJOGL.java +1681 -1745
  89. data/src/main/java/processing/opengl/PShader.java +1257 -1260
  90. data/src/main/java/processing/opengl/PShapeOpenGL.java +4599 -4662
  91. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1030 -1047
  92. data/src/main/java/processing/opengl/Texture.java +1397 -1462
  93. data/src/main/java/processing/opengl/VertexBuffer.java +55 -57
  94. data/src/main/resources/icon/icon-1024.png +0 -0
  95. data/src/main/resources/icon/icon-128.png +0 -0
  96. data/src/main/resources/icon/icon-16.png +0 -0
  97. data/src/main/resources/icon/icon-256.png +0 -0
  98. data/src/main/resources/icon/icon-32.png +0 -0
  99. data/src/main/resources/icon/icon-48.png +0 -0
  100. data/src/main/resources/icon/icon-512.png +0 -0
  101. data/src/main/resources/icon/icon-64.png +0 -0
  102. data/vendors/Rakefile +1 -1
  103. metadata +12 -8
  104. data/src/main/java/processing/core/ThinkDifferent.java +0 -70
@@ -1,5 +1,3 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
1
  /*
4
2
  Part of the Processing project - http://processing.org
5
3
 
@@ -19,45 +17,44 @@
19
17
  Public License along with this library; if not, write to the
20
18
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
19
  Boston, MA 02111-1307 USA
22
- */
23
-
20
+ */
24
21
  package processing.core;
25
22
 
26
-
27
23
  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;
24
+
25
+ public int imageMode;
26
+ public int rectMode;
27
+ public int ellipseMode;
28
+ public int shapeMode;
29
+
30
+ public int blendMode;
31
+
32
+ public int colorMode;
33
+ public float colorModeX;
34
+ public float colorModeY;
35
+ public float colorModeZ;
36
+ public float colorModeA;
37
+
38
+ public boolean tint;
39
+ public int tintColor;
40
+ public boolean fill;
41
+ public int fillColor;
42
+ public boolean stroke;
43
+ public int strokeColor;
44
+ public float strokeWeight;
45
+ public int strokeCap;
46
+ public int strokeJoin;
47
+
48
+ // TODO these fellas are inconsistent, and may need to go elsewhere
49
+ public float ambientR, ambientG, ambientB;
50
+ public float specularR, specularG, specularB;
51
+ public float emissiveR, emissiveG, emissiveB;
52
+ public float shininess;
53
+
54
+ public PFont textFont;
55
+ public int textAlign;
56
+ public int textAlignY;
57
+ public int textMode;
58
+ public float textSize;
59
+ public float textLeading;
63
60
  }
@@ -1,5 +1,3 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
1
  /*
4
2
  Part of the Processing project - http://processing.org
5
3
 
@@ -18,84 +16,84 @@
18
16
  Public License along with this library; if not, write to the
19
17
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
18
  Boston, MA 02111-1307 USA
21
- */
22
-
19
+ */
23
20
  package processing.core;
24
21
 
25
-
26
22
  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 )
42
- //public Component initComponent(PApplet sketch);
43
-
44
- //public Frame initFrame(PApplet sketch, Color backgroundColor,
23
+
24
+ /**
25
+ * Minimum dimensions for the window holding an applet. This varies between
26
+ * platforms, Mac OS X 10.3 (confirmed with 10.7 and Java 6) can do any
27
+ * height but requires at least 128 pixels width. Windows XP has another set
28
+ * of limitations. And for all I know, Linux probably allows window sizes to
29
+ * be negative numbers.
30
+ */
31
+ static public final int MIN_WINDOW_WIDTH = 128;
32
+ static public final int MIN_WINDOW_HEIGHT = 128;
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,
45
41
  // public void initFrame(PApplet sketch, int backgroundColor,
46
42
  // 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
-
43
+ public void initFrame(PApplet sketch);
44
+
45
+ /**
46
+ * Get the native window object associated with this drawing surface. For
47
+ * Java2D, this will be an AWT Frame object. For OpenGL, the window. The
48
+ * data returned here is subject to the whims of the renderer, and using
49
+ * this method means you're willing to deal with underlying implementation
50
+ * changes and that you won't throw a fit like a toddler if your code breaks
51
+ * sometime in the future.
52
+ */
53
+ public Object getNative();
54
+
55
+ //
56
+ // Just call these on an AWT Frame object stored in PApplet.
57
+ // Silly, but prevents a lot of rewrite and extra methods for little benefit.
58
+ // However, maybe prevents us from having to document the 'frame' variable?
59
+ /**
60
+ * Set the window (and dock, or whatever necessary) title.
61
+ */
62
+ public void setTitle(String title);
63
+
64
+ /**
65
+ * Show or hide the window.
66
+ */
67
+ public void setVisible(boolean visible);
68
+
69
+ /**
70
+ * Set true if we want to resize things (default is not resizable)
71
+ */
72
+ public void setResizable(boolean resizable);
73
+
74
+ /**
75
+ * Dumb name, but inherited from Frame and no better ideas.
76
+ */
77
+ public void setAlwaysOnTop(boolean always);
78
+
79
+ public void setIcon(PImage icon);
80
+
81
+ //
81
82
  // public void placeWindow(int[] location);
83
+ public void placeWindow(int[] location, int[] editorLocation);
82
84
 
83
- public void placeWindow(int[] location, int[] editorLocation);
84
-
85
- //public void placeFullScreen(boolean hideStop);
86
- public void placePresent(int stopColor);
85
+ //public void placeFullScreen(boolean hideStop);
86
+ public void placePresent(int stopColor);
87
87
 
88
- // Sketch is running from the PDE, set up messaging back to the PDE
89
- public void setupExternalMessages();
88
+ // Sketch is running from the PDE, set up messaging back to the PDE
89
+ public void setupExternalMessages();
90
90
 
91
- //
91
+ //
92
+ // sets displayWidth/Height inside PApplet
93
+ //public void checkDisplaySize();
94
+ public void setLocation(int x, int y);
92
95
 
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);
96
+ public void setSize(int width, int height);
99
97
 
100
98
  // /**
101
99
  // * Called by {@link PApplet#createGraphics} to initialize the
@@ -105,57 +103,54 @@ public interface PSurface {
105
103
  // * @param wide
106
104
  // * @param high
107
105
  // */
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
106
+ // create pixel buffer (pulled out for offscreen graphics)
107
+ //public void initImage(PGraphics gr, int wide, int high);
108
+ // create pixel buffer, called from allocate() to produce a compatible image for rendering efficiently
111
109
  // public void initImage(PGraphics gr);
112
-
113
- //public Component getComponent();
114
-
110
+ //public Component getComponent();
115
111
  // /**
116
112
  // * Sometimes smoothing must be set at the drawing surface level
117
113
  // * not just inside the renderer itself.
118
114
  // */
119
115
  // public void setSmooth(int level);
120
-
121
- public void setFrameRate(float fps);
116
+ public void setFrameRate(float fps);
122
117
 
123
118
  // // called on the first frame so that the now-visible drawing surface can
124
119
  // // receive key and mouse events
125
120
  // public void requestFocus();
126
-
127
121
  // // finish rendering to the screen (called by PApplet)
128
122
  // public void blit();
123
+ //
124
+ public void setCursor(int kind);
129
125
 
130
- //
131
-
132
- public void setCursor(int kind);
133
-
134
- public void setCursor(PImage image, int hotspotX, int hotspotY);
135
-
136
- public void showCursor();
126
+ public void setCursor(PImage image, int hotspotX, int hotspotY);
137
127
 
138
- public void hideCursor();
128
+ public void showCursor();
139
129
 
140
- //
130
+ public void hideCursor();
141
131
 
142
- /** Start the animation thread */
143
- public void startThread();
132
+ //
133
+ /**
134
+ * Start the animation thread
135
+ */
136
+ public void startThread();
144
137
 
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();
138
+ /**
139
+ * On the next trip through the animation thread, things should go
140
+ * sleepy-bye. Does not pause the thread immediately because that needs to
141
+ * happen on the animation thread itself, so fires on the next trip through
142
+ * draw().
143
+ */
144
+ public void pauseThread();
151
145
 
152
- public void resumeThread();
146
+ public void resumeThread();
153
147
 
154
- /**
155
- * Stop the animation thread (set it null)
156
- * @return false if already stopped
157
- */
158
- public boolean stopThread();
148
+ /**
149
+ * Stop the animation thread (set it null)
150
+ *
151
+ * @return false if already stopped
152
+ */
153
+ public boolean stopThread();
159
154
 
160
- public boolean isStopped();
155
+ public boolean isStopped();
161
156
  }
@@ -1,5 +1,3 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
1
  /*
4
2
  Part of the Processing project - http://processing.org
5
3
 
@@ -18,260 +16,238 @@
18
16
  Public License along with this library; if not, write to the
19
17
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
18
  Boston, MA 02111-1307 USA
21
- */
22
-
19
+ */
23
20
  package processing.core;
24
21
 
25
-
26
22
  /**
27
23
  * Surface that's not really visible. Used for PDF and friends, or as a base
28
24
  * class for other drawing surfaces. It includes the standard rendering loop.
29
25
  */
30
26
  public class PSurfaceNone implements PSurface {
31
- protected PApplet sketch;
32
- protected PGraphics graphics;
33
27
 
34
- protected Thread thread;
35
- protected boolean paused;
36
- protected Object pauseObject = new Object();
28
+ protected PApplet sketch;
29
+ protected PGraphics graphics;
37
30
 
38
- protected float frameRateTarget = 60;
39
- protected long frameRatePeriod = 1000000000L / 60L;
31
+ protected Thread thread;
32
+ protected boolean paused;
33
+ protected Object pauseObject = new Object();
40
34
 
35
+ protected float frameRateTarget = 60;
36
+ protected long frameRatePeriod = 1000000000L / 60L;
41
37
 
42
- public PSurfaceNone(PGraphics graphics) {
43
- this.graphics = graphics;
44
- }
45
-
46
-
47
- @Override
48
- public void initOffscreen(PApplet sketch) {
49
- this.sketch = sketch;
38
+ public PSurfaceNone(PGraphics graphics) {
39
+ this.graphics = graphics;
40
+ }
50
41
 
51
- setSize(sketch.sketchWidth(), sketch.sketchHeight());
52
- }
42
+ @Override
43
+ public void initOffscreen(PApplet sketch) {
44
+ this.sketch = sketch;
53
45
 
46
+ setSize(sketch.sketchWidth(), sketch.sketchHeight());
47
+ }
54
48
 
55
49
  // public Component initComponent(PApplet sketch) {
56
50
  // return null;
57
51
  // }
52
+ @Override
53
+ public void initFrame(PApplet sketch) {
54
+ throw new IllegalStateException("initFrame() not available with "
55
+ + getClass().getSimpleName());
56
+ }
58
57
 
58
+ public Object getNative() {
59
+ return null;
60
+ }
59
61
 
60
- @Override
61
- public void initFrame(PApplet sketch) {
62
- throw new IllegalStateException("initFrame() not available with " +
63
- getClass().getSimpleName());
64
- }
65
-
66
-
67
- public Object getNative() {
68
- return null;
69
- }
70
-
71
-
72
- /** Set the window (and dock, or whatever necessary) title. */
73
- @Override
74
- public void setTitle(String title) {
75
- // You're in a utopian PSurface implementation where titles don't exist.
76
- }
77
-
78
-
79
- @Override
80
- public void setIcon(PImage image) {
81
- // I ain't visible, man.
82
- }
83
-
84
-
85
- /** Show or hide the window. */
86
- @Override
87
- public void setVisible(boolean visible) {
88
- // I'm always invisible. You can't catch me.
89
- }
90
-
91
-
92
- /** Set true if we want to resize things (default is not resizable) */
93
- @Override
94
- public void setResizable(boolean resizable) {
95
- // I don't need size to know my worth.
96
- }
97
-
98
-
99
- @Override
100
- public void placeWindow(int[] location, int[] editorLocation) { }
101
-
102
-
103
- @Override
104
- public void placePresent(int stopColor) { }
105
-
106
-
107
- @Override
108
- public void setupExternalMessages() { }
109
-
62
+ /**
63
+ * Set the window (and dock, or whatever necessary) title.
64
+ */
65
+ @Override
66
+ public void setTitle(String title) {
67
+ // You're in a utopian PSurface implementation where titles don't exist.
68
+ }
110
69
 
111
- @Override
112
- public void setAlwaysOnTop(boolean always) { }
70
+ @Override
71
+ public void setIcon(PImage image) {
72
+ // I ain't visible, man.
73
+ }
113
74
 
75
+ /**
76
+ * Show or hide the window.
77
+ */
78
+ @Override
79
+ public void setVisible(boolean visible) {
80
+ // I'm always invisible. You can't catch me.
81
+ }
114
82
 
115
- //
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
+ }
116
90
 
91
+ @Override
92
+ public void placeWindow(int[] location, int[] editorLocation) {
93
+ }
117
94
 
118
- @Override
119
- public void setLocation(int x, int y) {
120
- // I'm everywhere, because I'm nowhere.
121
- }
95
+ @Override
96
+ public void placePresent(int stopColor) {
97
+ }
122
98
 
99
+ @Override
100
+ public void setupExternalMessages() {
101
+ }
123
102
 
124
- @Override
125
- public void setSize(int wide, int high) {
126
- if (PApplet.DEBUG) {
127
- //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
128
- new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
103
+ @Override
104
+ public void setAlwaysOnTop(boolean always) {
129
105
  }
130
106
 
131
- //if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
132
- if (wide == sketch.width && high == sketch.height) {
133
- if (PApplet.DEBUG) {
134
- new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
135
- }
136
- return; // unchanged, don't rebuild everything
107
+ //
108
+ @Override
109
+ public void setLocation(int x, int y) {
110
+ // I'm everywhere, because I'm nowhere.
137
111
  }
138
112
 
139
- //throw new RuntimeException("implement me, see readme.md");
140
- sketch.width = wide;
141
- sketch.height = high;
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
+
120
+ //if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
121
+ if (wide == sketch.width && high == sketch.height) {
122
+ if (PApplet.DEBUG) {
123
+ new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
124
+ }
125
+ return; // unchanged, don't rebuild everything
126
+ }
142
127
 
143
- // set PGraphics variables for width/height/pixelWidth/pixelHeight
144
- graphics.setSize(wide, high);
145
- }
128
+ //throw new RuntimeException("implement me, see readme.md");
129
+ sketch.width = wide;
130
+ sketch.height = high;
146
131
 
132
+ // set PGraphics variables for width/height/pixelWidth/pixelHeight
133
+ graphics.setSize(wide, high);
134
+ }
147
135
 
148
136
  // public void initImage(PGraphics graphics) {
149
137
  // // TODO Auto-generated method stub
150
138
  //
151
139
  // }
152
-
153
140
  // public Component getComponent() {
154
141
  // return null;
155
142
  // }
156
-
157
-
158
143
  // public void setSmooth(int level) {
159
144
  // // TODO Auto-generated method stub
160
145
  // }
161
-
162
146
  // void requestFocus() {
163
147
  // }
164
-
165
148
  // public void blit() {
166
149
  // // TODO Auto-generated method stub
167
150
  // }
151
+ public void setCursor(int kind) {
152
+ }
168
153
 
169
- public void setCursor(int kind) { }
170
-
171
- public void setCursor(PImage image, int hotspotX, int hotspotY) { }
172
-
173
- public void showCursor() { }
174
-
175
- public void hideCursor() { }
176
-
177
-
178
- //
179
-
180
-
181
- public Thread createThread() {
182
- return new AnimationThread();
183
- }
184
-
185
-
186
- public void startThread() {
187
- if (thread == null) {
188
- thread = createThread();
189
- thread.start();
190
- } else {
191
- throw new IllegalStateException("Thread already started in " +
192
- getClass().getSimpleName());
154
+ public void setCursor(PImage image, int hotspotX, int hotspotY) {
193
155
  }
194
- }
195
156
 
157
+ public void showCursor() {
158
+ }
196
159
 
197
- public boolean stopThread() {
198
- if (thread == null) {
199
- return false;
160
+ public void hideCursor() {
200
161
  }
201
- thread = null;
202
- return true;
203
- }
204
162
 
163
+ //
164
+ public Thread createThread() {
165
+ return new AnimationThread();
166
+ }
205
167
 
206
- public boolean isStopped() {
207
- return thread == null || !thread.isAlive();
208
- }
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
+ }
209
177
 
178
+ public boolean stopThread() {
179
+ if (thread == null) {
180
+ return false;
181
+ }
182
+ thread = null;
183
+ return true;
184
+ }
210
185
 
211
- // sets a flag to pause the thread when ready
212
- public void pauseThread() {
213
- PApplet.debug("PApplet.run() paused, calling object wait...");
214
- paused = true;
215
- }
186
+ public boolean isStopped() {
187
+ return thread == null || !thread.isAlive();
188
+ }
216
189
 
190
+ // sets a flag to pause the thread when ready
191
+ public void pauseThread() {
192
+ PApplet.debug("PApplet.run() paused, calling object wait...");
193
+ paused = true;
194
+ }
217
195
 
218
- // halts the animation thread if the pause flag is set
219
- protected void checkPause() {
220
- if (paused) {
221
- synchronized (pauseObject) {
222
- try {
223
- pauseObject.wait();
196
+ // halts the animation thread if the pause flag is set
197
+ protected void checkPause() {
198
+ if (paused) {
199
+ synchronized (pauseObject) {
200
+ try {
201
+ pauseObject.wait();
224
202
  // PApplet.debug("out of wait");
225
- } catch (InterruptedException e) {
226
- // waiting for this interrupt on a start() (resume) call
203
+ } catch (InterruptedException e) {
204
+ // waiting for this interrupt on a start() (resume) call
205
+ }
206
+ }
227
207
  }
228
- }
229
- }
230
208
  // PApplet.debug("done with pause");
231
- }
232
-
233
-
234
- public void resumeThread() {
235
- paused = false;
236
- synchronized (pauseObject) {
237
- pauseObject.notifyAll(); // wake up the animation thread
238
209
  }
239
- }
240
-
241
-
242
- public void setFrameRate(float fps) {
243
- frameRateTarget = fps;
244
- frameRatePeriod = (long) (1000000000.0 / frameRateTarget);
245
- //g.setFrameRate(fps);
246
- }
247
-
248
-
249
- public class AnimationThread extends Thread {
250
210
 
251
- public AnimationThread() {
252
- super("Animation Thread");
211
+ public void resumeThread() {
212
+ paused = false;
213
+ synchronized (pauseObject) {
214
+ pauseObject.notifyAll(); // wake up the animation thread
215
+ }
253
216
  }
254
217
 
255
- // broken out so it can be overridden by Danger et al
256
- public void callDraw() {
257
- sketch.handleDraw();
218
+ public void setFrameRate(float fps) {
219
+ frameRateTarget = fps;
220
+ frameRatePeriod = (long) (1000000000.0 / frameRateTarget);
221
+ //g.setFrameRate(fps);
258
222
  }
259
223
 
260
- /**
261
- * Main method for the primary animation thread.
262
- * <A HREF="http://java.sun.com/products/jfc/tsc/articles/painting/">Painting in AWT and Swing</A>
263
- */
264
- @Override
265
- public void run() { // not good to make this synchronized, locks things up
266
- long beforeTime = System.nanoTime();
267
- long overSleepTime = 0L;
224
+ public class AnimationThread extends Thread {
268
225
 
269
- int noDelays = 0;
270
- // Number of frames with a delay of 0 ms before the
271
- // animation thread yields to other running threads.
272
- final int NO_DELAYS_PER_YIELD = 15;
226
+ public AnimationThread() {
227
+ super("Animation Thread");
228
+ }
229
+
230
+ // broken out so it can be overridden by Danger et al
231
+ public void callDraw() {
232
+ sketch.handleDraw();
233
+ }
273
234
 
274
- /*
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
+ /*
275
251
  // If size un-initialized, might be a Canvas. Call setSize() here since
276
252
  // we now have a parent object that this Canvas can use as a peer.
277
253
  if (graphics.image == null) {
@@ -289,28 +265,26 @@ public class PSurfaceNone implements PSurface {
289
265
  }
290
266
  // System.out.format(" but now, sketchW/H changed to %d %d%n", sketchWidth, sketchHeight);
291
267
  }
292
- */
268
+ */
269
+ // un-pause the sketch and get rolling
270
+ sketch.start();
293
271
 
294
- // un-pause the sketch and get rolling
295
- sketch.start();
272
+ while ((Thread.currentThread() == thread) && !sketch.finished) {
273
+ checkPause();
296
274
 
297
- while ((Thread.currentThread() == thread) && !sketch.finished) {
298
- checkPause();
299
-
300
- // Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
301
- // otherwise it may attempt a resize mid-render.
275
+ // Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
276
+ // otherwise it may attempt a resize mid-render.
302
277
  // Dimension currentSize = canvas.getSize();
303
278
  // if (currentSize.width != sketchWidth || currentSize.height != sketchHeight) {
304
279
  // System.err.format("need to resize from %s to %d, %d%n", currentSize, sketchWidth, sketchHeight);
305
280
  // }
306
-
307
- // render a single frame
281
+ // render a single frame
308
282
  // try {
309
283
  // EventQueue.invokeAndWait(new Runnable() {
310
284
  // public void run() {
311
285
  // System.out.println("calling draw, finished = " + sketch.finished);
312
- //System.out.println("calling draw, looping = " + sketch.looping + ", frameCount = " + sketch.frameCount);
313
- callDraw();
286
+ //System.out.println("calling draw, looping = " + sketch.looping + ", frameCount = " + sketch.frameCount);
287
+ callDraw();
314
288
 
315
289
  // EventQueue.invokeLater(new Runnable() {
316
290
  // public void run() {
@@ -319,7 +293,6 @@ public class PSurfaceNone implements PSurface {
319
293
  // }
320
294
  // }
321
295
  // });
322
-
323
296
  // }
324
297
  // });
325
298
  // } catch (InterruptedException ie) {
@@ -327,45 +300,44 @@ public class PSurfaceNone implements PSurface {
327
300
  // } catch (InvocationTargetException ite) {
328
301
  // ite.getTargetException().printStackTrace();
329
302
  // }
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
+ }
330
333
 
331
- // wait for update & paint to happen before drawing next frame
332
- // this is necessary since the drawing is sometimes in a
333
- // separate thread, meaning that the next frame will start
334
- // before the update/paint is completed
335
-
336
- long afterTime = System.nanoTime();
337
- long timeDiff = afterTime - beforeTime;
338
- //System.out.println("time diff is " + timeDiff);
339
- long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime;
340
-
341
- if (sleepTime > 0) { // some time left in this cycle
342
- try {
343
- Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L));
344
- noDelays = 0; // Got some sleep, not delaying anymore
345
- } catch (InterruptedException ex) { }
346
-
347
- overSleepTime = (System.nanoTime() - afterTime) - sleepTime;
348
-
349
- } else { // sleepTime <= 0; the frame took longer than the period
350
- overSleepTime = 0L;
351
- noDelays++;
334
+ sketch.dispose(); // call to shutdown libs?
352
335
 
353
- if (noDelays > NO_DELAYS_PER_YIELD) {
354
- Thread.yield(); // give another thread a chance to run
355
- noDelays = 0;
356
- }
336
+ // If the user called the exit() function, the window should close,
337
+ // rather than the sketch just halting.
338
+ if (sketch.exitCalled) {
339
+ sketch.exitActual();
340
+ }
357
341
  }
358
-
359
- beforeTime = System.nanoTime();
360
- }
361
-
362
- sketch.dispose(); // call to shutdown libs?
363
-
364
- // If the user called the exit() function, the window should close,
365
- // rather than the sketch just halting.
366
- if (sketch.exitCalled) {
367
- sketch.exitActual();
368
- }
369
342
  }
370
- }
371
343
  }