propane 3.10.0-java → 3.11.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  3. data/CHANGELOG.md +2 -0
  4. data/README.md +7 -7
  5. data/lib/propane/app.rb +2 -5
  6. data/lib/propane/helper_methods.rb +6 -6
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
  9. data/pom.rb +6 -6
  10. data/pom.xml +6 -6
  11. data/propane.gemspec +3 -3
  12. data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
  13. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
  14. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
  15. data/src/main/java/processing/awt/PImageAWT.java +6 -4
  16. data/src/main/java/processing/core/PApplet.java +71 -59
  17. data/src/main/java/processing/core/PImage.java +14 -14
  18. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
  19. data/src/main/java/processing/opengl/PShader.java +1 -6
  20. data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
  21. data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
  22. data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
  23. data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
  24. data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
  25. data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
  26. data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
  27. data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
  28. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
  29. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
  30. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
  31. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
  32. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
  33. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
  34. data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
  35. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
  36. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
  37. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
  38. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
  39. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
  40. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
  41. data/test/test_helper.rb +1 -0
  42. data/vendors/Rakefile +1 -1
  43. metadata +29 -155
  44. data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
  45. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  46. data/lib/java/monkstone/ColorUtil.java +0 -127
  47. data/lib/java/monkstone/MathToolModule.java +0 -287
  48. data/lib/java/monkstone/PropaneLibrary.java +0 -46
  49. data/lib/java/monkstone/core/LibraryProxy.java +0 -136
  50. data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
  51. data/lib/java/monkstone/fastmath/Deglut.java +0 -71
  52. data/lib/java/monkstone/fastmath/package-info.java +0 -6
  53. data/lib/java/monkstone/filechooser/Chooser.java +0 -39
  54. data/lib/java/monkstone/noise/FastTerrain.java +0 -874
  55. data/lib/java/monkstone/noise/Noise.java +0 -90
  56. data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
  57. data/lib/java/monkstone/noise/NoiseMode.java +0 -28
  58. data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
  59. data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
  60. data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
  61. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
  62. data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
  63. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
  64. data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
  65. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
  66. data/lib/java/monkstone/slider/Slider.java +0 -61
  67. data/lib/java/monkstone/slider/SliderBar.java +0 -245
  68. data/lib/java/monkstone/slider/SliderGroup.java +0 -56
  69. data/lib/java/monkstone/slider/WheelHandler.java +0 -35
  70. data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
  71. data/lib/java/monkstone/vecmath/JRender.java +0 -56
  72. data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
  73. data/lib/java/monkstone/vecmath/package-info.java +0 -20
  74. data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
  75. data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
  76. data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
  77. data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
  78. data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
  79. data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
  80. data/lib/java/monkstone/videoevent/package-info.java +0 -20
  81. data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
  82. data/lib/java/processing/awt/PImageAWT.java +0 -377
  83. data/lib/java/processing/awt/PShapeJava2D.java +0 -387
  84. data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
  85. data/lib/java/processing/awt/ShimAWT.java +0 -581
  86. data/lib/java/processing/core/PApplet.java +0 -15156
  87. data/lib/java/processing/core/PConstants.java +0 -523
  88. data/lib/java/processing/core/PFont.java +0 -1126
  89. data/lib/java/processing/core/PGraphics.java +0 -8600
  90. data/lib/java/processing/core/PImage.java +0 -3377
  91. data/lib/java/processing/core/PMatrix.java +0 -208
  92. data/lib/java/processing/core/PMatrix2D.java +0 -562
  93. data/lib/java/processing/core/PMatrix3D.java +0 -890
  94. data/lib/java/processing/core/PShape.java +0 -3561
  95. data/lib/java/processing/core/PShapeOBJ.java +0 -483
  96. data/lib/java/processing/core/PShapeSVG.java +0 -2016
  97. data/lib/java/processing/core/PStyle.java +0 -63
  98. data/lib/java/processing/core/PSurface.java +0 -198
  99. data/lib/java/processing/core/PSurfaceNone.java +0 -431
  100. data/lib/java/processing/core/PVector.java +0 -1066
  101. data/lib/java/processing/core/ThinkDifferent.java +0 -115
  102. data/lib/java/processing/data/DoubleDict.java +0 -850
  103. data/lib/java/processing/data/DoubleList.java +0 -928
  104. data/lib/java/processing/data/FloatDict.java +0 -847
  105. data/lib/java/processing/data/FloatList.java +0 -936
  106. data/lib/java/processing/data/IntDict.java +0 -807
  107. data/lib/java/processing/data/IntList.java +0 -936
  108. data/lib/java/processing/data/JSONArray.java +0 -1260
  109. data/lib/java/processing/data/JSONObject.java +0 -2282
  110. data/lib/java/processing/data/JSONTokener.java +0 -435
  111. data/lib/java/processing/data/LongDict.java +0 -802
  112. data/lib/java/processing/data/LongList.java +0 -937
  113. data/lib/java/processing/data/Sort.java +0 -46
  114. data/lib/java/processing/data/StringDict.java +0 -613
  115. data/lib/java/processing/data/StringList.java +0 -800
  116. data/lib/java/processing/data/Table.java +0 -4936
  117. data/lib/java/processing/data/TableRow.java +0 -198
  118. data/lib/java/processing/data/XML.java +0 -1156
  119. data/lib/java/processing/dxf/RawDXF.java +0 -404
  120. data/lib/java/processing/event/Event.java +0 -125
  121. data/lib/java/processing/event/KeyEvent.java +0 -70
  122. data/lib/java/processing/event/MouseEvent.java +0 -114
  123. data/lib/java/processing/event/TouchEvent.java +0 -57
  124. data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
  125. data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
  126. data/lib/java/processing/net/Client.java +0 -744
  127. data/lib/java/processing/net/Server.java +0 -388
  128. data/lib/java/processing/opengl/FontTexture.java +0 -378
  129. data/lib/java/processing/opengl/FrameBuffer.java +0 -513
  130. data/lib/java/processing/opengl/LinePath.java +0 -627
  131. data/lib/java/processing/opengl/LineStroker.java +0 -681
  132. data/lib/java/processing/opengl/PGL.java +0 -3483
  133. data/lib/java/processing/opengl/PGraphics2D.java +0 -615
  134. data/lib/java/processing/opengl/PGraphics3D.java +0 -281
  135. data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
  136. data/lib/java/processing/opengl/PJOGL.java +0 -2008
  137. data/lib/java/processing/opengl/PShader.java +0 -1484
  138. data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
  139. data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
  140. data/lib/java/processing/opengl/Texture.java +0 -1696
  141. data/lib/java/processing/opengl/VertexBuffer.java +0 -88
  142. data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
  143. data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
  144. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  145. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  146. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  147. data/src/main/java/processing/opengl/cursors/license.txt +0 -27
  148. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  149. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  150. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  151. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
  152. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
  153. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
  154. data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
  155. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
  156. data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
  157. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
  158. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
  159. data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
  160. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
  161. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
  162. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
  163. data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,581 +0,0 @@
1
- package processing.awt;
2
-
3
- import java.awt.Desktop;
4
- import java.awt.EventQueue;
5
- import java.awt.FileDialog;
6
- import java.awt.Frame;
7
- import java.awt.HeadlessException;
8
- import java.awt.Image;
9
- import java.awt.Toolkit;
10
- import java.awt.color.ColorSpace;
11
- import java.awt.image.BufferedImage;
12
- import java.io.File;
13
- import java.io.IOException;
14
- import java.io.InputStream;
15
- import java.net.URI;
16
- import java.net.URISyntaxException;
17
-
18
- import java.awt.DisplayMode;
19
- import java.awt.GraphicsConfiguration;
20
- import java.awt.GraphicsDevice;
21
- import java.awt.GraphicsEnvironment;
22
- import java.awt.geom.AffineTransform;
23
-
24
- import javax.imageio.ImageIO;
25
- import javax.swing.ImageIcon;
26
- import javax.swing.JFileChooser;
27
- import javax.swing.UIManager;
28
- import javax.swing.UnsupportedLookAndFeelException;
29
-
30
- // used by desktopFile() method
31
- import javax.swing.filechooser.FileSystemView;
32
-
33
- import processing.core.PApplet;
34
- import processing.core.PConstants;
35
- import processing.core.PImage;
36
-
37
-
38
- /**
39
- * This class exists as an abstraction layer to remove AWT from PApplet.
40
- * It is a staging area for AWT-specific code that's shared by the Java2D,
41
- * JavaFX, and JOGL renderers. Once PSurfaceFX and PSurfaceJOGL have
42
- * their own implementations, these methods will move to PSurfaceAWT.
43
- */
44
- public class ShimAWT implements PConstants {
45
- /*
46
- PGraphics graphics;
47
- PApplet sketch;
48
-
49
-
50
- public ShimAWT(PApplet sketch) {
51
- this.graphics = graphics;
52
- this.sketch = sketch;
53
- }
54
- */
55
- static private ShimAWT instance;
56
-
57
- private GraphicsDevice[] displayDevices;
58
-
59
- private final int displayWidth;
60
- private final int displayHeight;
61
-
62
-
63
- /** Only needed for display functions */
64
- static private ShimAWT getInstance() {
65
- if (instance == null) {
66
- instance = new ShimAWT();
67
- }
68
- return instance;
69
- }
70
-
71
-
72
- private ShimAWT() {
73
- // Need the list of display devices to be queried already for usage below.
74
- // https://github.com/processing/processing/issues/3295
75
- // https://github.com/processing/processing/issues/3296
76
- // Not doing this from a static initializer because it may cause
77
- // PApplet to cache and the values to stick through subsequent runs.
78
- // Instead make it a runtime thing and a local variable.
79
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
80
- GraphicsDevice device = ge.getDefaultScreenDevice();
81
- displayDevices = ge.getScreenDevices();
82
-
83
- // // Default or unparsed will be -1, spanning will be 0, actual displays will
84
- // // be numbered from 1 because it's too weird to say "display 0" in prefs.
85
- // if (display > 0 && display <= displayDevices.length) {
86
- // device = displayDevices[display-1];
87
- // }
88
- // When this was called, display will always be unset (even in 3.x),
89
- // since this happens before settings() is called.
90
-
91
- // Set displayWidth and displayHeight for people still using those.
92
- DisplayMode displayMode = device.getDisplayMode();
93
- displayWidth = displayMode.getWidth();
94
- displayHeight = displayMode.getHeight();
95
- }
96
-
97
-
98
- static public int getDisplayWidth() {
99
- return getInstance().displayWidth;
100
- }
101
-
102
-
103
- static public int getDisplayHeight() {
104
- return getInstance().displayHeight;
105
- }
106
-
107
-
108
- static public int getDisplayCount() {
109
- return getInstance().displayDevices.length;
110
- }
111
-
112
-
113
- static public int getDisplayDensity(int num) {
114
- return getInstance().displayDensityImpl(num);
115
- }
116
-
117
-
118
- /*
119
- private int displayDensityImpl() {
120
- if (display != SPAN && (fullScreen || present)) {
121
- return displayDensity(display);
122
- }
123
- // walk through all displays, use 2 if any display is 2
124
- for (int i = 0; i < displayDevices.length; i++) {
125
- if (displayDensity(i+1) == 2) {
126
- return 2;
127
- }
128
- }
129
- // If nobody's density is 2 then everyone is 1
130
- return 1;
131
- }
132
- */
133
-
134
-
135
- private int displayDensityImpl(int display) {
136
- if (display > 0 && display <= displayDevices.length) {
137
- GraphicsConfiguration graphicsConfig =
138
- displayDevices[display - 1].getDefaultConfiguration();
139
- AffineTransform tx = graphicsConfig.getDefaultTransform();
140
- return (int) Math.round(tx.getScaleX());
141
- }
142
-
143
- System.err.println("Display " + display + " does not exist, " +
144
- "returning 1 for displayDensity(" + display + ")");
145
- return 1; // not the end of the world, so don't throw a RuntimeException
146
- }
147
-
148
-
149
- static public PImage loadImage(PApplet sketch, String filename, Object... args) {
150
- String extension = null;
151
- if (args != null && args.length > 0) {
152
- // the only one that's supported for now
153
- extension = (String) args[0];
154
- }
155
-
156
- if (extension == null) {
157
- String lower = filename.toLowerCase();
158
- int dot = filename.lastIndexOf('.');
159
- if (dot == -1) {
160
- extension = "unknown"; // no extension found
161
-
162
- } else {
163
- extension = lower.substring(dot + 1);
164
-
165
- // check for, and strip any parameters on the url, i.e.
166
- // filename.jpg?blah=blah&something=that
167
- int question = extension.indexOf('?');
168
- if (question != -1) {
169
- extension = extension.substring(0, question);
170
- }
171
- }
172
- }
173
-
174
- // just in case. them users will try anything!
175
- extension = extension.toLowerCase();
176
-
177
- if (extension.equals("tga")) {
178
- try {
179
- InputStream input = sketch.createInput(filename);
180
- if (input == null) return null;
181
-
182
- PImage image = PImage.loadTGA(input);
183
- image.parent = sketch;
184
- return image;
185
-
186
- } catch (IOException e) {
187
- return null;
188
- }
189
- }
190
-
191
- if (extension.equals("tif") || extension.equals("tiff")) {
192
- InputStream input = sketch.createInput(filename);
193
- PImage image = (input == null) ? null : PImage.loadTIFF(input);
194
- return image;
195
- }
196
-
197
- // For jpeg, gif, and png, load them using createImage(),
198
- // because the javax.imageio code was found to be much slower.
199
- // http://dev.processing.org/bugs/show_bug.cgi?id=392
200
- try {
201
- if (extension.equals("jpg") || extension.equals("jpeg") ||
202
- extension.equals("gif") || extension.equals("png") ||
203
- extension.equals("unknown")) {
204
- byte[] bytes = sketch.loadBytes(filename);
205
- if (bytes == null) {
206
- return null;
207
- } else {
208
- //Image awtImage = Toolkit.getDefaultToolkit().createImage(bytes);
209
- Image awtImage = new ImageIcon(bytes).getImage();
210
-
211
- if (awtImage instanceof BufferedImage) {
212
- BufferedImage buffImage = (BufferedImage) awtImage;
213
- int space = buffImage.getColorModel().getColorSpace().getType();
214
- if (space == ColorSpace.TYPE_CMYK) {
215
- System.err.println(filename + " is a CMYK image, " +
216
- "only RGB images are supported.");
217
- return null;
218
- /*
219
- // wishful thinking, appears to not be supported
220
- // https://community.oracle.com/thread/1272045?start=0&tstart=0
221
- BufferedImage destImage =
222
- new BufferedImage(buffImage.getWidth(),
223
- buffImage.getHeight(),
224
- BufferedImage.TYPE_3BYTE_BGR);
225
- ColorConvertOp op = new ColorConvertOp(null);
226
- op.filter(buffImage, destImage);
227
- image = new PImage(destImage);
228
- */
229
- }
230
- }
231
-
232
- PImage image = new PImageAWT(awtImage);
233
- if (image.width == -1) {
234
- System.err.println("The file " + filename +
235
- " contains bad image data, or may not be an image.");
236
- }
237
-
238
- // if it's a .gif image, test to see if it has transparency
239
- if (extension.equals("gif") || extension.equals("png") ||
240
- extension.equals("unknown")) {
241
- image.checkAlpha();
242
- }
243
-
244
- image.parent = sketch;
245
- return image;
246
- }
247
- }
248
- } catch (Exception e) {
249
- // show error, but move on to the stuff below, see if it'll work
250
-
251
- }
252
-
253
- if (loadImageFormats == null) {
254
- loadImageFormats = ImageIO.getReaderFormatNames();
255
- }
256
- if (loadImageFormats != null) {
257
- for (String loadImageFormat : loadImageFormats) {
258
- if (extension.equals(loadImageFormat)) {
259
- return loadImageIO(sketch, filename);
260
- }
261
- }
262
- }
263
-
264
- // failed, could not load image after all those attempts
265
- System.err.println("Could not find a method to load " + filename);
266
- return null;
267
- }
268
-
269
-
270
- static protected String[] loadImageFormats;
271
-
272
-
273
- /**
274
- * Use Java 1.4 ImageIO methods to load an image.
275
- */
276
- static protected PImage loadImageIO(PApplet sketch, String filename) {
277
- InputStream stream = sketch.createInput(filename);
278
- if (stream == null) {
279
- System.err.println("The image " + filename + " could not be found.");
280
- return null;
281
- }
282
-
283
- try {
284
- BufferedImage bi = ImageIO.read(stream);
285
- //PImage outgoing = new PImage(bi.getWidth(), bi.getHeight());
286
- PImage outgoing = new PImageAWT(bi);
287
- outgoing.parent = sketch;
288
-
289
- //bi.getRGB(0, 0, outgoing.width, outgoing.height,
290
- // outgoing.pixels, 0, outgoing.width);
291
-
292
- // check the alpha for this image
293
- // was gonna call getType() on the image to see if RGB or ARGB,
294
- // but it's not actually useful, since gif images will come through
295
- // as TYPE_BYTE_INDEXED, which means it'll still have to check for
296
- // the transparency. also, would have to iterate through all the other
297
- // types and guess whether alpha was in there, so.. just gonna stick
298
- // with the old method.
299
- outgoing.checkAlpha();
300
-
301
- stream.close();
302
- // return the image
303
- return outgoing;
304
-
305
- } catch (IOException e) {
306
- return null;
307
- }
308
- }
309
-
310
-
311
- static public void initRun() {
312
- // Supposed to help with flicker, but no effect on OS X.
313
- // TODO IIRC this helped on Windows, but need to double check.
314
- System.setProperty("sun.awt.noerasebackground", "true");
315
-
316
- // Remove 60fps limit on the JavaFX "pulse" timer
317
- System.setProperty("javafx.animation.fullspeed", "true");
318
-
319
- // Catch any HeadlessException to provide more useful feedback
320
- try {
321
- // Call validate() while resize events are in progress
322
- Toolkit.getDefaultToolkit().setDynamicLayout(true);
323
- } catch (HeadlessException e) {
324
- System.err.println("Cannot run sketch without a display. Read this for possible solutions:");
325
- System.err.println("https://github.com/processing/processing/wiki/Running-without-a-Display");
326
- System.exit(1);
327
- }
328
- }
329
-
330
-
331
- /*
332
- public int displayDensity() {
333
- if (sketch.display != PConstants.SPAN && (sketch.fullScreen || sketch.present)) {
334
- return displayDensity(sketch.display);
335
- }
336
- // walk through all displays, use 2 if any display is 2
337
- for (int i = 0; i < displayDevices.length; i++) {
338
- if (displayDensity(i+1) == 2) {
339
- return 2;
340
- }
341
- }
342
- // If nobody's density is 2 then everyone is 1
343
- return 1;
344
- }
345
- */
346
-
347
-
348
- /**
349
- * @param display the display number to check
350
- * (1-indexed to match the Preferences dialog box)
351
- */
352
- /*
353
- public int displayDensity(int display) {
354
- if (display > 0 && display <= displayDevices.length) {
355
- GraphicsConfiguration graphicsConfig =
356
- displayDevices[display - 1].getDefaultConfiguration();
357
- AffineTransform tx = graphicsConfig.getDefaultTransform();
358
- return (int) Math.round(tx.getScaleX());
359
- }
360
-
361
- System.err.println("Display " + display + " does not exist, returning ");
362
- return 1; // not the end of the world, so don't throw a RuntimeException
363
- }
364
- */
365
-
366
-
367
- static public void selectInput(String prompt, String callbackMethod,
368
- File file, Object callbackObject) {
369
- EventQueue.invokeLater(() -> {
370
- selectImpl(prompt, callbackMethod, file,
371
- callbackObject, null, FileDialog.LOAD);
372
- });
373
- }
374
-
375
-
376
- /*
377
- static public void selectOutput(String prompt, String callbackMethod,
378
- File file, Object callbackObject, Frame parent) {
379
- selectImpl(prompt, callbackMethod, file, callbackObject, parent, FileDialog.SAVE, null);
380
- }
381
-
382
-
383
- static public void selectOutput(String prompt, String callbackMethod,
384
- File file, Object callbackObject, Frame parent,
385
- PApplet sketch) {
386
- selectImpl(prompt, callbackMethod, file, callbackObject, parent, FileDialog.SAVE, sketch);
387
- }
388
- */
389
-
390
-
391
- static public void selectOutput(String prompt, String callbackMethod,
392
- File file, Object callbackObject) {
393
- EventQueue.invokeLater(() -> {
394
- selectImpl(prompt, callbackMethod, file,
395
- callbackObject, null, FileDialog.SAVE);
396
- });
397
- }
398
-
399
-
400
- /*
401
- // Will remove the 'sketch' parameter once we get an upstream JOGL fix
402
- // https://github.com/processing/processing/issues/3831
403
- static protected void selectEvent(final String prompt,
404
- final String callbackMethod,
405
- final File defaultSelection,
406
- final Object callbackObject,
407
- final Frame parentFrame,
408
- final int mode,
409
- final PApplet sketch) {
410
- EventQueue.invokeLater(new Runnable() {
411
- public void run() {
412
- boolean hide = (sketch != null) &&
413
- (sketch.g instanceof PGraphicsOpenGL) &&
414
- (PApplet.platform == PConstants.WINDOWS);
415
- if (hide) sketch.getSurface().setVisible(false);
416
-
417
- selectImpl(prompt, callbackMethod, defaultSelection, callbackObject,
418
- parentFrame, mode, sketch);
419
-
420
- if (hide) sketch.getSurface().setVisible(true);
421
- }
422
- });
423
- }
424
- */
425
-
426
-
427
- static public void selectImpl(final String prompt,
428
- final String callbackMethod,
429
- final File defaultSelection,
430
- final Object callbackObject,
431
- final Frame parentFrame,
432
- final int mode) {
433
- File selectedFile = null;
434
-
435
- if (PApplet.useNativeSelect) {
436
- FileDialog dialog = new FileDialog(parentFrame, prompt, mode);
437
- if (defaultSelection != null) {
438
- dialog.setDirectory(defaultSelection.getParent());
439
- dialog.setFile(defaultSelection.getName());
440
- }
441
-
442
- dialog.setVisible(true);
443
- String directory = dialog.getDirectory();
444
- String filename = dialog.getFile();
445
- if (filename != null) {
446
- selectedFile = new File(directory, filename);
447
- }
448
-
449
- } else {
450
- JFileChooser chooser = new JFileChooser();
451
- chooser.setDialogTitle(prompt);
452
- if (defaultSelection != null) {
453
- chooser.setSelectedFile(defaultSelection);
454
- }
455
-
456
- int result = -1;
457
- if (mode == FileDialog.SAVE) {
458
- result = chooser.showSaveDialog(parentFrame);
459
- } else if (mode == FileDialog.LOAD) {
460
- result = chooser.showOpenDialog(parentFrame);
461
- }
462
- if (result == JFileChooser.APPROVE_OPTION) {
463
- selectedFile = chooser.getSelectedFile();
464
- }
465
- }
466
- PApplet.selectCallback(selectedFile, callbackMethod, callbackObject);
467
- }
468
-
469
-
470
- static public void selectFolder(final String prompt,
471
- final String callbackMethod,
472
- final File defaultSelection,
473
- final Object callbackObject) {
474
- EventQueue.invokeLater(() -> {
475
- selectFolderImpl(prompt, callbackMethod, defaultSelection,
476
- callbackObject, null);
477
- });
478
- }
479
-
480
-
481
- /*
482
- static public void selectFolder(final String prompt,
483
- final String callbackMethod,
484
- final File defaultSelection,
485
- final Object callbackObject,
486
- final Frame parentFrame) {
487
- selectFolderEvent(prompt, callbackMethod, defaultSelection, callbackObject, parentFrame, null);
488
- }
489
-
490
-
491
- // Will remove the 'sketch' parameter once we get an upstream JOGL fix
492
- // https://github.com/processing/processing/issues/3831
493
- static public void selectFolderEvent(final String prompt,
494
- final String callbackMethod,
495
- final File defaultSelection,
496
- final Object callbackObject,
497
- final Frame parentFrame,
498
- final PApplet sketch) {
499
- EventQueue.invokeLater(() -> {
500
- selectFolderImpl(prompt, callbackMethod, defaultSelection,
501
- callbackObject, parentFrame, sketch);
502
- });
503
- }
504
- */
505
-
506
-
507
- static public void selectFolderImpl(final String prompt,
508
- final String callbackMethod,
509
- final File defaultSelection,
510
- final Object callbackObject,
511
- final Frame parentFrame) {
512
- File selectedFile = null;
513
- if (PApplet.platform == PConstants.MACOS && PApplet.useNativeSelect) {
514
- FileDialog fileDialog =
515
- new FileDialog(parentFrame, prompt, FileDialog.LOAD);
516
- if (defaultSelection != null) {
517
- fileDialog.setDirectory(defaultSelection.getAbsolutePath());
518
- }
519
- System.setProperty("apple.awt.fileDialogForDirectories", "true");
520
- fileDialog.setVisible(true);
521
- System.setProperty("apple.awt.fileDialogForDirectories", "false");
522
- String filename = fileDialog.getFile();
523
- if (filename != null) {
524
- selectedFile = new File(fileDialog.getDirectory(), fileDialog.getFile());
525
- }
526
- } else {
527
- checkLookAndFeel();
528
- JFileChooser fileChooser = new JFileChooser();
529
- fileChooser.setDialogTitle(prompt);
530
- fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
531
- if (defaultSelection != null) {
532
- fileChooser.setCurrentDirectory(defaultSelection);
533
- }
534
-
535
- int result = fileChooser.showOpenDialog(parentFrame);
536
- if (result == JFileChooser.APPROVE_OPTION) {
537
- selectedFile = fileChooser.getSelectedFile();
538
- }
539
- }
540
- PApplet.selectCallback(selectedFile, callbackMethod, callbackObject);
541
- }
542
-
543
-
544
- static private boolean lookAndFeelCheck;
545
-
546
- /**
547
- * Initialize the Look & Feel if it hasn't been already.
548
- * Call this before using any Swing-related code in PApplet methods.
549
- */
550
- static private void checkLookAndFeel() {
551
- if (!lookAndFeelCheck) {
552
- if (PApplet.platform == PConstants.WINDOWS) {
553
- // Windows is defaulting to Metal or something else awful.
554
- // Which also is not scaled properly with HiDPI interfaces.
555
- try {
556
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
557
- } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException e) { }
558
- }
559
- lookAndFeelCheck = true;
560
- }
561
- }
562
-
563
-
564
- // TODO maybe call this with reflection from inside PApplet?
565
- // longer term, develop a more general method for other platforms
566
- static public File getWindowsDesktop() {
567
- return FileSystemView.getFileSystemView().getHomeDirectory();
568
- }
569
-
570
-
571
- static public boolean openLink(String url) {
572
- try {
573
- if (Desktop.isDesktopSupported()) {
574
- Desktop.getDesktop().browse(new URI(url));
575
- return true;
576
- }
577
- } catch (IOException | URISyntaxException e) {
578
- }
579
- return false;
580
- }
581
- }