picrate 0.2.0-java → 0.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -5
  3. data/Rakefile +10 -2
  4. data/docs/_posts/2018-06-26-auto_install_picrate.md +15 -0
  5. data/lib/export.txt +8 -0
  6. data/lib/picrate/app.rb +4 -4
  7. data/lib/picrate/version.rb +1 -1
  8. data/picrate.gemspec +1 -1
  9. data/pom.rb +1 -1
  10. data/pom.xml +1 -1
  11. data/src/main/java/processing/awt/PGraphicsJava2D.java +16 -85
  12. data/src/main/java/processing/awt/PShapeJava2D.java +9 -33
  13. data/src/main/java/processing/awt/PSurfaceAWT.java +76 -169
  14. data/src/main/java/processing/core/PApplet.java +14019 -15963
  15. data/src/main/java/processing/core/PConstants.java +475 -981
  16. data/src/main/java/processing/core/PFont.java +50 -202
  17. data/src/main/java/processing/core/PGraphics.java +7330 -8477
  18. data/src/main/java/processing/core/PImage.java +42 -212
  19. data/src/main/java/processing/core/PMatrix.java +21 -160
  20. data/src/main/java/processing/core/PMatrix2D.java +18 -178
  21. data/src/main/java/processing/core/PMatrix3D.java +48 -324
  22. data/src/main/java/processing/core/PShape.java +294 -1181
  23. data/src/main/java/processing/core/PShapeOBJ.java +16 -91
  24. data/src/main/java/processing/core/PShapeSVG.java +53 -253
  25. data/src/main/java/processing/core/PStyle.java +34 -179
  26. data/src/main/java/processing/core/PSurface.java +13 -94
  27. data/src/main/java/processing/core/PSurfaceNone.java +35 -140
  28. data/src/main/java/processing/core/PVector.java +10 -87
  29. data/src/main/java/processing/event/Event.java +86 -69
  30. data/src/main/java/processing/event/MouseEvent.java +102 -102
  31. data/src/main/java/processing/opengl/PGL.java +23 -16
  32. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -10
  33. data/src/main/java/processing/opengl/PJOGL.java +32 -12
  34. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +154 -0
  35. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +2 -2
  36. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +160 -0
  37. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +2 -2
  38. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6df5ee2db467f6c57549b91693984aa44fc53046da0f6f3ca78ea2cf5bfc5ca
4
- data.tar.gz: 50bc6c07d8a6dc4e2d4da207444cb7b219a4e73642c628f7a729e93c0f249970
3
+ metadata.gz: 98912fc6c5238c86d49019bba74ea9c72f89d4e0888d0718400e16da3f57756c
4
+ data.tar.gz: b0519d1aa9030d1a63c012e3274e34c3908287af72232b687f0a6e6e9d5fa6d3
5
5
  SHA512:
6
- metadata.gz: a51e91f684e668bb94fb31e6807749895e0d8d1274087979249428dfe379a0b3d4e604425022fcebf7f8bf321a903e437577551bbf2c79f2e894c8961e0ae39f
7
- data.tar.gz: e9d54da06f207fcc798bdc0969235915742b05d57d86afe62782cc6dacea1d606c58a0dda9f26a8ace8f32633d529b1910dfb122b4beb8fed6cb27dd2df3f7d6
6
+ metadata.gz: aa44b2c66509e6348d3a455cb27de46c1a8f004278adb4062a306f0b1da6d7398efa00b5841d3c71b7c9c2f6482b15cc6282fcd668789db518507046a76665bf
7
+ data.tar.gz: f63e3511db6a033fcce9bf87a691324deebe1329897edf9c74556d9d1da701acbecd2ca7f9b601adf42cc1b2521d8d55b8a996b0115e619affd63160d061a2d7
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
- __C6H3N3O7__ [![Build Status](https://travis-ci.org/ruby-processing/PiCrate.svg?branch=master)](https://travis-ci.org/ruby-processing/PiCrate)
2
- [![Gem Version](https://badge.fury.io/rb/picrate.svg)](https://badge.fury.io/rb/picrate)
1
+ __C6H3N3O7__ [![Gem Version](https://badge.fury.io/rb/picrate.svg)](https://badge.fury.io/rb/picrate)
3
2
 
4
3
  # PiCrate
5
4
  Create processing sketches in ruby on raspberry-pi and linux (this project is a parallel development of [propane][propane] targetting the raspberry-pi, but will initially be developed on a regular linux box). The aim is to produce a gem installable app that can be run with jruby, with minimal dependencies. Drop the `C` and you get pirate, or and an `e` and get `PiCreate`, a happy coincidence?
6
5
 
6
+ ### To install from rubygems ###
7
+
8
+ Unfortunately jgem will not currently download the gem (see #https://github.com/jruby/jruby/issues/5192 issue on raspberrypi) so download the gem and install locally.
9
+
7
10
  ### To Build and Test ###
8
11
 
9
12
  Clone this repo:-
@@ -12,14 +15,14 @@ Requires maven, [jdk8][oracle] (but could be openjdk), and a jruby install.
12
15
 
13
16
  ```bash
14
17
  cd PiCrate
15
- rake
16
- jgem install picrate-0.1.0-java.gem
18
+ rake # assumes an installed version of vanilla processing
19
+ jgem install picrate-0.2.0-java.gem
17
20
  ```
18
21
  To create a template sketch:-
19
22
  ```bash
20
23
  picrate -c my_sketch 200 200
21
24
  ```
22
- Edit sketch (vim is good choice):-
25
+ Edit sketch (vim is a good choice):-
23
26
  ```ruby
24
27
  #!/usr/bin/env jruby
25
28
  # frozen_string_literal: false
data/Rakefile CHANGED
@@ -13,14 +13,22 @@ end
13
13
 
14
14
  task default: [:init, :compile, :install, :test, :gem]
15
15
 
16
- desc 'Create Manifest'
16
+ # depends on installed processing, with processing on path
17
+ desc 'Create Manifest and Copy Jars'
17
18
  task :init do
18
19
  create_manifest
20
+ processing_root = File.dirname(`readlink -f $(which processing)`)
21
+ jar_dir = File.join(processing_root, 'core', 'library')
22
+ opengl = Dir.entries(jar_dir).grep(/amd64|armv6hf/).select { |jar| jar =~ /linux/ }
23
+ opengl.concat %w[jogl-all.jar gluegen-rt.jar]
24
+ opengl.each do |gl|
25
+ FileUtils.cp(File.join(jar_dir, gl), File.join('.', 'lib'))
26
+ end
19
27
  end
20
28
 
21
29
  desc 'Install'
22
30
  task :install do
23
- sh 'mv target/picrate-0.2.0.jar lib'
31
+ sh 'mv target/picrate-0.3.0.jar lib'
24
32
  end
25
33
 
26
34
  desc 'Gem'
@@ -0,0 +1,15 @@
1
+ ---
2
+ layout: post
3
+ title: "Automated PiCrate Install"
4
+ date: 2018-06-26 07:34:13
5
+ categories: PiCrate update
6
+ permalink: /install_picrate/
7
+ ---
8
+
9
+ For a semi-automated setup and install, download and extract [this gist](https://gist.github.com/monkstone/8f06529790c36f5b7f668015faadcbc5/archive/d8617b32e5b83f33e077d48b862a79b46bcdbbbc.zip)
10
+
11
+ ```bash
12
+ bash gem_environment.sh # sets up a local gem environment
13
+ rake # default is to install jruby to opt, then link using update-alternatives
14
+ ```
15
+ Adjust script to suit needs if required, currently downloads gems and installs using downloaded copies (currently there is an issue with jgem downloads from rubygems on raspberryPI).
@@ -0,0 +1,8 @@
1
+ # If you want to support more platforms, visit jogamp.org to get the
2
+ # natives libraries for the platform in question (i.e. Solaris).
3
+
4
+ name = OpenGL
5
+
6
+ application.linux64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-amd64.jar,gluegen-rt-natives-linux-amd64.jar
7
+ application.linux-armv6hf=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-armv6hf.jar,gluegen-rt-natives-linux-armv6hf.jar
8
+ application.linux-arm64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-aarch64.jar,gluegen-rt-natives-linux-aarch64.jar
@@ -62,6 +62,10 @@ module Processing
62
62
  self.class.sketch_class
63
63
  end
64
64
 
65
+ def sketch_title(title)
66
+ surface.set_title(title)
67
+ end
68
+
65
69
  # Keep track of what inherits from the Processing::App, because we're
66
70
  # going to want to instantiate one.
67
71
  def self.inherited(subclass)
@@ -133,10 +137,6 @@ module Processing
133
137
  def post_initialize(_args)
134
138
  end
135
139
 
136
- def sketch_title(title)
137
- surface.set_title(title)
138
- end
139
-
140
140
  def data_path(dat)
141
141
  dat_root = File.join(SKETCH_ROOT, 'data')
142
142
  Dir.mkdir(dat_root) unless File.exist?(dat_root)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PiCrate
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.summary = %q{ruby wrapper for processing-3.3.7 on raspberrypi and linux64}
16
16
  gem.homepage = 'https://ruby-processing.github.io/PiCrate/'
17
17
  gem.files = `git ls-files`.split($/)
18
- gem.files << 'lib/picrate-0.2.0.jar'
18
+ gem.files << 'lib/picrate-0.3.0.jar'
19
19
  gem.files << 'lib/gluegen-rt.jar'
20
20
  gem.files << 'lib/jogl-all.jar'
21
21
  gem.files << 'lib/gluegen-rt-natives-linux-amd64.jar'
data/pom.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  project 'picrate', 'http://maven.apache.org' do
2
2
 
3
3
  model_version '4.0.0'
4
- id 'ruby-processing:picrate:0.2.0'
4
+ id 'ruby-processing:picrate:0.3.0'
5
5
  packaging 'jar'
6
6
 
7
7
  description 'An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.'
data/pom.xml CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>ruby-processing</groupId>
13
13
  <artifactId>picrate</artifactId>
14
- <version>0.2.0</version>
14
+ <version>0.3.0</version>
15
15
  <name>picrate</name>
16
16
  <description>An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.</description>
17
17
  <url>http://maven.apache.org</url>
@@ -60,10 +60,6 @@ public class PGraphicsJava2D extends PGraphics {
60
60
  //// boolean useOffscreen = true; // ~40fps
61
61
  // boolean useOffscreen = false;
62
62
 
63
- /**
64
- *
65
- */
66
-
67
63
  public Graphics2D g2;
68
64
  // protected BufferedImage offscreen;
69
65
 
@@ -95,45 +91,16 @@ public class PGraphicsJava2D extends PGraphics {
95
91
  Rectangle2D.Float rect = new Rectangle2D.Float();
96
92
  Arc2D.Float arc = new Arc2D.Float();
97
93
 
98
- /**
99
- *
100
- */
101
- protected Color tintColorObject;
102
-
103
- /**
104
- *
105
- */
106
- protected Color fillColorObject;
107
-
108
- /**
109
- *
110
- */
111
- public boolean fillGradient;
112
-
113
- /**
114
- *
115
- */
116
- public Paint fillGradientObject;
117
-
118
- /**
119
- *
120
- */
121
- protected Stroke strokeObject;
122
-
123
- /**
124
- *
125
- */
126
- protected Color strokeColorObject;
94
+ protected Color tintColorObject;
127
95
 
128
- /**
129
- *
130
- */
131
- public boolean strokeGradient;
96
+ protected Color fillColorObject;
97
+ public boolean fillGradient;
98
+ public Paint fillGradientObject;
132
99
 
133
- /**
134
- *
135
- */
136
- public Paint strokeGradientObject;
100
+ protected Stroke strokeObject;
101
+ protected Color strokeColorObject;
102
+ public boolean strokeGradient;
103
+ public Paint strokeGradientObject;
137
104
 
138
105
  Font fontObject;
139
106
 
@@ -143,10 +110,6 @@ public class PGraphicsJava2D extends PGraphics {
143
110
 
144
111
  // INTERNAL
145
112
 
146
- /**
147
- *
148
- */
149
-
150
113
 
151
114
  public PGraphicsJava2D() { }
152
115
 
@@ -293,7 +256,6 @@ public class PGraphicsJava2D extends PGraphics {
293
256
  /**
294
257
  * Still need a means to get the java.awt.Image object, since getNative()
295
258
  * is going to return the {@link Graphics2D} object.
296
- * @return
297
259
  */
298
260
  @Override
299
261
  public Image getImage() {
@@ -301,8 +263,7 @@ public class PGraphicsJava2D extends PGraphics {
301
263
  }
302
264
 
303
265
 
304
- /** Returns the java.awt.Graphics2D object used by this renderer.
305
- * @return */
266
+ /** Returns the java.awt.Graphics2D object used by this renderer. */
306
267
  @Override
307
268
  public Object getNative() {
308
269
  return g2;
@@ -332,11 +293,6 @@ public class PGraphicsJava2D extends PGraphics {
332
293
 
333
294
  // Graphics2D g2old;
334
295
 
335
- /**
336
- *
337
- * @return
338
- */
339
-
340
296
  public Graphics2D checkImage() {
341
297
  if (image == null ||
342
298
  ((BufferedImage) image).getWidth() != width*pixelDensity ||
@@ -1367,11 +1323,6 @@ public class PGraphicsJava2D extends PGraphics {
1367
1323
 
1368
1324
  // JAVA2D SHAPE/PATH HANDLING
1369
1325
 
1370
- /**
1371
- *
1372
- * @param s
1373
- */
1374
-
1375
1326
 
1376
1327
  protected void fillShape(Shape s) {
1377
1328
  if (fillGradient) {
@@ -1383,11 +1334,8 @@ public class PGraphicsJava2D extends PGraphics {
1383
1334
  }
1384
1335
  }
1385
1336
 
1386
- /**
1387
- *
1388
- * @param s
1389
- */
1390
- protected void strokeShape(Shape s) {
1337
+
1338
+ protected void strokeShape(Shape s) {
1391
1339
  if (strokeGradient) {
1392
1340
  g2.setPaint(strokeGradientObject);
1393
1341
  g2.draw(s);
@@ -1397,11 +1345,8 @@ public class PGraphicsJava2D extends PGraphics {
1397
1345
  }
1398
1346
  }
1399
1347
 
1400
- /**
1401
- *
1402
- * @param s
1403
- */
1404
- protected void drawShape(Shape s) {
1348
+
1349
+ protected void drawShape(Shape s) {
1405
1350
  if (fillGradient) {
1406
1351
  g2.setPaint(fillGradientObject);
1407
1352
  g2.fill(s);
@@ -1614,7 +1559,6 @@ public class PGraphicsJava2D extends PGraphics {
1614
1559
 
1615
1560
  /**
1616
1561
  * Handle renderer-specific image drawing.
1617
- * @param who
1618
1562
  */
1619
1563
  @Override
1620
1564
  protected void imageImpl(PImage who,
@@ -2486,10 +2430,8 @@ public class PGraphicsJava2D extends PGraphics {
2486
2430
  strokeImpl();
2487
2431
  }
2488
2432
 
2489
- /**
2490
- *
2491
- */
2492
- protected void strokeImpl() {
2433
+
2434
+ protected void strokeImpl() {
2493
2435
  int cap = BasicStroke.CAP_BUTT;
2494
2436
  if (strokeCap == ROUND) {
2495
2437
  cap = BasicStroke.CAP_ROUND;
@@ -2611,11 +2553,7 @@ public class PGraphicsJava2D extends PGraphics {
2611
2553
 
2612
2554
  int[] clearPixels;
2613
2555
 
2614
- /**
2615
- *
2616
- * @param color
2617
- */
2618
- protected void clearPixels(int color) {
2556
+ protected void clearPixels(int color) {
2619
2557
  // On a hi-res display, image may be larger than width/height
2620
2558
  int imageWidth = image.getWidth(null);
2621
2559
  int imageHeight = image.getHeight(null);
@@ -2772,11 +2710,6 @@ public class PGraphicsJava2D extends PGraphics {
2772
2710
 
2773
2711
  // getImage, setCache, getCache, removeCache, isModified, setModified
2774
2712
 
2775
- /**
2776
- *
2777
- * @return
2778
- */
2779
-
2780
2713
 
2781
2714
  protected WritableRaster getRaster() {
2782
2715
  WritableRaster raster = null;
@@ -2850,8 +2783,6 @@ public class PGraphicsJava2D extends PGraphics {
2850
2783
  * <P>
2851
2784
  * Unlike in PImage, where updatePixels() only requests that the
2852
2785
  * update happens, in PGraphicsJava2D, this will happen immediately.
2853
- * @param c
2854
- * @param d
2855
2786
  */
2856
2787
  @Override
2857
2788
  public void updatePixels(int x, int y, int c, int d) {
@@ -47,29 +47,18 @@ public class PShapeJava2D extends PShapeSVG {
47
47
  Paint strokeGradientPaint;
48
48
  Paint fillGradientPaint;
49
49
 
50
- /**
51
- *
52
- * @param svg
53
- */
54
- public PShapeJava2D(XML svg) {
50
+
51
+ public PShapeJava2D(XML svg) {
55
52
  super(svg);
56
53
  }
57
54
 
58
- /**
59
- *
60
- * @param parent
61
- * @param properties
62
- * @param parseKids
63
- */
64
- public PShapeJava2D(PShapeSVG parent, XML properties, boolean parseKids) {
55
+
56
+ public PShapeJava2D(PShapeSVG parent, XML properties, boolean parseKids) {
65
57
  super(parent, properties, parseKids);
66
58
  }
67
59
 
68
- /**
69
- *
70
- * @param parent
71
- */
72
- @Override
60
+
61
+ @Override
73
62
  protected void setParent(PShapeSVG parent) {
74
63
  super.setParent(parent);
75
64
 
@@ -85,11 +74,7 @@ public class PShapeJava2D extends PShapeSVG {
85
74
  }
86
75
 
87
76
 
88
- /** Factory method for subclasses.
89
- * @param parent
90
- * @param properties
91
- * @param parseKids
92
- * @return */
77
+ /** Factory method for subclasses. */
93
78
  @Override
94
79
  protected PShapeSVG createShape(PShapeSVG parent, XML properties, boolean parseKids) {
95
80
  return new PShapeJava2D(parent, properties, parseKids);
@@ -313,12 +298,8 @@ public class PShapeJava2D extends PShapeSVG {
313
298
  }
314
299
  }
315
300
 
316
- /**
317
- *
318
- * @param gradient
319
- * @return
320
- */
321
- protected Paint calcGradientPaint(Gradient gradient) {
301
+
302
+ protected Paint calcGradientPaint(Gradient gradient) {
322
303
  if (gradient instanceof LinearGradient) {
323
304
  // System.out.println("creating linear gradient");
324
305
  LinearGradient grad = (LinearGradient) gradient;
@@ -363,11 +344,6 @@ public class PShapeJava2D extends PShapeSVG {
363
344
 
364
345
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
365
346
 
366
- /**
367
- *
368
- * @param g
369
- */
370
-
371
347
 
372
348
  @Override
373
349
  protected void styles(PGraphics g) {
@@ -57,10 +57,7 @@ import processing.core.PSurfaceNone;
57
57
  import processing.event.KeyEvent;
58
58
  import processing.event.MouseEvent;
59
59
 
60
- /**
61
- *
62
- * @author tux
63
- */
60
+
64
61
  public class PSurfaceAWT extends PSurfaceNone {
65
62
  GraphicsDevice displayDevice;
66
63
 
@@ -95,11 +92,8 @@ public class PSurfaceAWT extends PSurfaceNone {
95
92
 
96
93
  int windowScaleFactor;
97
94
 
98
- /**
99
- *
100
- * @param graphics
101
- */
102
- public PSurfaceAWT(PGraphics graphics) {
95
+
96
+ public PSurfaceAWT(PGraphics graphics) {
103
97
  //this.graphics = graphics;
104
98
  super(graphics);
105
99
 
@@ -189,10 +183,6 @@ public class PSurfaceAWT extends PSurfaceNone {
189
183
 
190
184
  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
191
185
 
192
- /**
193
- *
194
- */
195
-
196
186
 
197
187
  public class SmoothCanvas extends Canvas {
198
188
  private Dimension oldSize = new Dimension(0, 0);
@@ -200,47 +190,31 @@ public class PSurfaceAWT extends PSurfaceNone {
200
190
 
201
191
 
202
192
  // Turns out getParent() returns a JPanel on a JFrame. Yech.
203
-
204
- /**
205
- *
206
- * @return
207
- */
208
193
  public Frame getFrame() {
209
194
  return frame;
210
195
  }
211
196
 
212
- /**
213
- *
214
- * @return
215
- */
216
- @Override
197
+
198
+ @Override
217
199
  public Dimension getPreferredSize() {
218
200
  return new Dimension(sketchWidth, sketchHeight);
219
201
  }
220
202
 
221
- /**
222
- *
223
- * @return
224
- */
225
- @Override
203
+
204
+ @Override
226
205
  public Dimension getMinimumSize() {
227
206
  return getPreferredSize();
228
207
  }
229
208
 
230
- /**
231
- *
232
- * @return
233
- */
234
- @Override
209
+
210
+ @Override
235
211
  public Dimension getMaximumSize() {
236
212
  //return resizable ? super.getMaximumSize() : getPreferredSize();
237
213
  return frame.isResizable() ? super.getMaximumSize() : getPreferredSize();
238
214
  }
239
215
 
240
- /**
241
- *
242
- */
243
- @Override
216
+
217
+ @Override
244
218
  public void validate() {
245
219
  super.validate();
246
220
  newSize.width = getWidth();
@@ -261,21 +235,15 @@ public class PSurfaceAWT extends PSurfaceNone {
261
235
  }
262
236
  }
263
237
 
264
- /**
265
- *
266
- * @param g
267
- */
268
- @Override
238
+
239
+ @Override
269
240
  public void update(Graphics g) {
270
241
  // System.out.println("updating");
271
242
  paint(g);
272
243
  }
273
244
 
274
- /**
275
- *
276
- * @param screen
277
- */
278
- @Override
245
+
246
+ @Override
279
247
  public void paint(Graphics screen) {
280
248
  // System.out.println("painting");
281
249
  // if (useStrategy) {
@@ -312,10 +280,8 @@ public class PSurfaceAWT extends PSurfaceNone {
312
280
  }
313
281
  */
314
282
 
315
- /**
316
- *
317
- */
318
- synchronized protected void render() {
283
+
284
+ synchronized protected void render() {
319
285
  if (canvas.isDisplayable() &&
320
286
  graphics.image != null) {
321
287
  if (canvas.getBufferStrategy() == null) {
@@ -391,11 +357,6 @@ public class PSurfaceAWT extends PSurfaceNone {
391
357
 
392
358
 
393
359
  // what needs to happen here?
394
-
395
- /**
396
- *
397
- * @param sketch
398
- */
399
360
  @Override
400
361
  public void initOffscreen(PApplet sketch) {
401
362
  this.sketch = sketch;
@@ -423,11 +384,8 @@ public class PSurfaceAWT extends PSurfaceNone {
423
384
  }
424
385
  */
425
386
 
426
- /**
427
- *
428
- * @param sketch
429
- */
430
- @Override
387
+
388
+ @Override
431
389
  public void initFrame(final PApplet sketch) {/*, int backgroundColor,
432
390
  int deviceIndex, boolean fullScreen, boolean spanDisplays) {*/
433
391
  this.sketch = sketch;
@@ -600,8 +558,7 @@ public class PSurfaceAWT extends PSurfaceNone {
600
558
  // }
601
559
 
602
560
 
603
- /** Set the window (and dock, or whatever necessary) title.
604
- * @param title */
561
+ /** Set the window (and dock, or whatever necessary) title. */
605
562
  @Override
606
563
  public void setTitle(String title) {
607
564
  frame.setTitle(title);
@@ -616,8 +573,7 @@ public class PSurfaceAWT extends PSurfaceNone {
616
573
  }
617
574
 
618
575
 
619
- /** Set true if we want to resize things (default is not resizable)
620
- * @param resizable */
576
+ /** Set true if we want to resize things (default is not resizable) */
621
577
  @Override
622
578
  public void setResizable(boolean resizable) {
623
579
  //this.resizable = resizable; // really only used for canvas
@@ -627,29 +583,26 @@ public class PSurfaceAWT extends PSurfaceNone {
627
583
  }
628
584
  }
629
585
 
630
- /**
631
- *
632
- * @param image
633
- */
634
- @Override
586
+
587
+ @Override
635
588
  public void setIcon(PImage image) {
636
589
  Image awtImage = (Image) image.getNative();
637
- frame.setIconImage(awtImage);
638
- // if (PApplet.platform != PConstants.MACOSX) {
639
- // frame.setIconImage(awtImage);
640
- //
641
- // } else {
642
- // try {
643
- // final String td = "processing.core.ThinkDifferent";
644
- // Class<?> thinkDifferent =
645
- // Thread.currentThread().getContextClassLoader().loadClass(td);
646
- // Method method =
647
- // thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class });
648
- // method.invoke(null, new Object[] { awtImage });
649
- // } catch (Exception e) {
650
- // e.printStackTrace(); // That's unfortunate
651
- // }
652
- // }
590
+
591
+ if (PApplet.platform != PConstants.MACOSX) {
592
+ frame.setIconImage(awtImage);
593
+
594
+ } else {
595
+ try {
596
+ final String td = "processing.core.ThinkDifferent";
597
+ Class<?> thinkDifferent =
598
+ Thread.currentThread().getContextClassLoader().loadClass(td);
599
+ Method method =
600
+ thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class });
601
+ method.invoke(null, new Object[] { awtImage });
602
+ } catch (Exception e) {
603
+ e.printStackTrace(); // That's unfortunate
604
+ }
605
+ }
653
606
  }
654
607
 
655
608
 
@@ -658,12 +611,8 @@ public class PSurfaceAWT extends PSurfaceNone {
658
611
  frame.setAlwaysOnTop(always);
659
612
  }
660
613
 
661
- /**
662
- *
663
- * @param x
664
- * @param y
665
- */
666
- @Override
614
+
615
+ @Override
667
616
  public void setLocation(int x, int y) {
668
617
  frame.setLocation(x, y);
669
618
  }
@@ -671,14 +620,10 @@ public class PSurfaceAWT extends PSurfaceNone {
671
620
 
672
621
  List<Image> iconImages;
673
622
 
674
- /**
675
- *
676
- * @param frame
677
- */
678
- protected void setProcessingIcon(Frame frame) {
623
+ protected void setProcessingIcon(Frame frame) {
679
624
  // On OS X, this only affects what shows up in the dock when minimized.
680
625
  // So replacing it is actually a step backwards. Brilliant.
681
- // if (PApplet.platform != PConstants.MACOSX) {
626
+ if (PApplet.platform != PConstants.MACOSX) {
682
627
  //Image image = Toolkit.getDefaultToolkit().createImage(ICON_IMAGE);
683
628
  //frame.setIconImage(image);
684
629
  try {
@@ -698,25 +643,25 @@ public class PSurfaceAWT extends PSurfaceNone {
698
643
 
699
644
  } catch (Exception e) { } // harmless; keep this to ourselves
700
645
 
701
- // } else { // handle OS X differently
702
- // if (!dockIconSpecified()) { // don't override existing -Xdock param
703
- // // On OS X, set this for AWT surfaces, which handles the dock image
704
- // // as well as the cmd-tab image that's shown. Just one size, I guess.
705
- // URL url = PApplet.class.getResource("/icon/icon-512.png");
706
- // // Seems dangerous to have this in code instead of using reflection, no?
707
- // //ThinkDifferent.setIconImage(Toolkit.getDefaultToolkit().getImage(url));
708
- // try {
709
- // final String td = "processing.core.ThinkDifferent";
710
- // Class<?> thinkDifferent =
711
- // Thread.currentThread().getContextClassLoader().loadClass(td);
712
- // Method method =
713
- // thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class });
714
- // method.invoke(null, new Object[] { Toolkit.getDefaultToolkit().getImage(url) });
715
- // } catch (Exception e) {
716
- // e.printStackTrace(); // That's unfortunate
717
- // }
718
- // }
719
- // }
646
+ } else { // handle OS X differently
647
+ if (!dockIconSpecified()) { // don't override existing -Xdock param
648
+ // On OS X, set this for AWT surfaces, which handles the dock image
649
+ // as well as the cmd-tab image that's shown. Just one size, I guess.
650
+ URL url = PApplet.class.getResource("/icon/icon-512.png");
651
+ // Seems dangerous to have this in code instead of using reflection, no?
652
+ //ThinkDifferent.setIconImage(Toolkit.getDefaultToolkit().getImage(url));
653
+ try {
654
+ final String td = "processing.core.ThinkDifferent";
655
+ Class<?> thinkDifferent =
656
+ Thread.currentThread().getContextClassLoader().loadClass(td);
657
+ Method method =
658
+ thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class });
659
+ method.invoke(null, new Object[] { Toolkit.getDefaultToolkit().getImage(url) });
660
+ } catch (Exception e) {
661
+ e.printStackTrace(); // That's unfortunate
662
+ }
663
+ }
664
+ }
720
665
  }
721
666
 
722
667
 
@@ -767,11 +712,6 @@ public class PSurfaceAWT extends PSurfaceNone {
767
712
 
768
713
 
769
714
  //public void placeFullScreen(boolean hideStop) {
770
-
771
- /**
772
- *
773
- * @param stopColor
774
- */
775
715
  @Override
776
716
  public void placePresent(int stopColor) {
777
717
  setFullFrame();
@@ -919,12 +859,8 @@ public class PSurfaceAWT extends PSurfaceNone {
919
859
  //frame.setVisible(true); // re-add native resources
920
860
  }
921
861
 
922
- /**
923
- *
924
- * @param location
925
- * @param editorLocation
926
- */
927
- @Override
862
+
863
+ @Override
928
864
  public void placeWindow(int[] location, int[] editorLocation) {
929
865
  //Dimension window = setFrameSize(sketchWidth, sketchHeight);
930
866
  Dimension window = setFrameSize(); //sketchWidth, sketchHeight);
@@ -1007,12 +943,6 @@ public class PSurfaceAWT extends PSurfaceNone {
1007
943
 
1008
944
 
1009
945
  // needs to resize the frame, which will resize the canvas, and so on...
1010
-
1011
- /**
1012
- *
1013
- * @param wide
1014
- * @param high
1015
- */
1016
946
  @Override
1017
947
  public void setSize(int wide, int high) {
1018
948
  // When the surface is set to resizable via surface.setResizable(true),
@@ -1305,7 +1235,6 @@ public class PSurfaceAWT extends PSurfaceNone {
1305
1235
  * Figure out how to process a mouse event. When loop() has been
1306
1236
  * called, the events will be queued up until drawing is complete.
1307
1237
  * If noLoop() has been called, then events will happen immediately.
1308
- * @param nativeEvent
1309
1238
  */
1310
1239
  protected void nativeMouseEvent(java.awt.event.MouseEvent nativeEvent) {
1311
1240
  // the 'amount' is the number of button clicks for a click event,
@@ -1405,11 +1334,8 @@ public class PSurfaceAWT extends PSurfaceNone {
1405
1334
  peCount));
1406
1335
  }
1407
1336
 
1408
- /**
1409
- *
1410
- * @param event
1411
- */
1412
- protected void nativeKeyEvent(java.awt.event.KeyEvent event) {
1337
+
1338
+ protected void nativeKeyEvent(java.awt.event.KeyEvent event) {
1413
1339
  int peAction = 0;
1414
1340
  switch (event.getID()) {
1415
1341
  case java.awt.event.KeyEvent.KEY_PRESSED:
@@ -1441,10 +1367,6 @@ public class PSurfaceAWT extends PSurfaceNone {
1441
1367
 
1442
1368
 
1443
1369
  // listeners, for all my men!
1444
-
1445
- /**
1446
- *
1447
- */
1448
1370
  protected void addListeners() {
1449
1371
 
1450
1372
  canvas.addMouseListener(new MouseListener() {
@@ -1558,11 +1480,8 @@ public class PSurfaceAWT extends PSurfaceNone {
1558
1480
  boolean cursorVisible = true;
1559
1481
  Cursor invisibleCursor;
1560
1482
 
1561
- /**
1562
- *
1563
- * @param kind
1564
- */
1565
- @Override
1483
+
1484
+ @Override
1566
1485
  public void setCursor(int kind) {
1567
1486
  // Swap the HAND cursor because MOVE doesn't seem to be available on OS X
1568
1487
  // https://github.com/processing/processing/issues/2358
@@ -1574,13 +1493,8 @@ public class PSurfaceAWT extends PSurfaceNone {
1574
1493
  this.cursorType = kind;
1575
1494
  }
1576
1495
 
1577
- /**
1578
- *
1579
- * @param img
1580
- * @param x
1581
- * @param y
1582
- */
1583
- @Override
1496
+
1497
+ @Override
1584
1498
  public void setCursor(PImage img, int x, int y) {
1585
1499
  // Don't set cursorType, instead use cursorType to save the last
1586
1500
  // regular cursor type used for when cursor() is called.
@@ -1600,10 +1514,8 @@ public class PSurfaceAWT extends PSurfaceNone {
1600
1514
  cursorVisible = true;
1601
1515
  }
1602
1516
 
1603
- /**
1604
- *
1605
- */
1606
- @Override
1517
+
1518
+ @Override
1607
1519
  public void showCursor() {
1608
1520
  // Maybe should always set here? Seems dangerous, since it's likely that
1609
1521
  // Java will set the cursor to something else on its own, and the sketch
@@ -1614,10 +1526,8 @@ public class PSurfaceAWT extends PSurfaceNone {
1614
1526
  }
1615
1527
  }
1616
1528
 
1617
- /**
1618
- *
1619
- */
1620
- @Override
1529
+
1530
+ @Override
1621
1531
  public void hideCursor() {
1622
1532
  // Because the OS may have shown the cursor on its own,
1623
1533
  // don't return if 'cursorVisible' is set to true. [rev 0216]
@@ -1638,11 +1548,8 @@ public class PSurfaceAWT extends PSurfaceNone {
1638
1548
  cursorVisible = false;
1639
1549
  }
1640
1550
 
1641
- /**
1642
- *
1643
- * @return
1644
- */
1645
- @Override
1551
+
1552
+ @Override
1646
1553
  public Thread createThread() {
1647
1554
  return new AnimationThread() {
1648
1555
  @Override