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