picrate 0.3.0-java → 0.4.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.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/CHANGELOG.md +1 -2
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/picrate.rb +1 -0
- data/lib/picrate/app.rb +4 -4
- data/lib/picrate/helper_methods.rb +0 -4
- data/lib/picrate/version.rb +1 -1
- data/library/color_group/color_group.rb +27 -0
- data/picrate.gemspec +1 -1
- data/pom.rb +5 -5
- data/pom.xml +5 -5
- data/src/main/java/monkstone/ColorUtil.java +57 -32
- data/src/main/java/processing/awt/PShapeJava2D.java +33 -9
- data/src/main/java/processing/awt/PSurfaceAWT.java +169 -76
- data/src/main/java/processing/core/PApplet.java +15921 -13981
- data/src/main/java/processing/core/PConstants.java +981 -475
- data/src/main/java/processing/core/PFont.java +202 -50
- data/src/main/java/processing/core/PGraphics.java +8470 -7323
- data/src/main/java/processing/core/PImage.java +212 -42
- data/src/main/java/processing/core/PMatrix.java +160 -21
- data/src/main/java/processing/core/PMatrix2D.java +178 -18
- data/src/main/java/processing/core/PMatrix3D.java +324 -48
- data/src/main/java/processing/core/PShape.java +42 -20
- data/src/main/java/processing/core/PShapeOBJ.java +91 -16
- data/src/main/java/processing/core/PShapeSVG.java +253 -53
- data/src/main/java/processing/core/PStyle.java +179 -34
- data/src/main/java/processing/core/PSurface.java +94 -13
- data/src/main/java/processing/core/PSurfaceNone.java +140 -35
- data/src/main/java/processing/core/PVector.java +87 -10
- data/src/main/java/processing/data/JSONObject.java +2 -2
- data/src/main/java/processing/event/Event.java +69 -86
- data/src/main/java/processing/event/MouseEvent.java +102 -102
- data/src/main/java/processing/opengl/PJOGL.java +3 -0
- data/test/color_group_test.rb +33 -0
- data/vendors/Rakefile +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d0093cb47f7b3da255af047a82056efb9ea6d3c4173c13c8336b98c7f4b3cfb
|
4
|
+
data.tar.gz: ea5b1e00ee24ca51bc0625ab261a6914b2c67624f5026a06a4c0283a31b07da0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50417839ec672bf61d8fc21f707612959ce3856dd7c85c4d6263308f00e09e209f9cfea4fa94a065232c41fa3a80f6bd715d2cf182a8f0d518e549a8f0ac4ec1
|
7
|
+
data.tar.gz: c852f333c965a5ec7152d312939fbfce171048079838e2e69e46984daa740a19c64e9a789a912f097fd110807864141f8104b0239ad82fce81e5212163cdeae2
|
data/.mvn/extensions.xml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ Requires maven, [jdk8][oracle] (but could be openjdk), and a jruby install.
|
|
16
16
|
```bash
|
17
17
|
cd PiCrate
|
18
18
|
rake # assumes an installed version of vanilla processing
|
19
|
-
jgem install picrate-0.
|
19
|
+
jgem install picrate-0.4.0-java.gem
|
20
20
|
```
|
21
21
|
To create a template sketch:-
|
22
22
|
```bash
|
data/Rakefile
CHANGED
@@ -22,13 +22,13 @@ task :init do
|
|
22
22
|
opengl = Dir.entries(jar_dir).grep(/amd64|armv6hf/).select { |jar| jar =~ /linux/ }
|
23
23
|
opengl.concat %w[jogl-all.jar gluegen-rt.jar]
|
24
24
|
opengl.each do |gl|
|
25
|
-
|
25
|
+
FileUtils.cp(File.join(jar_dir, gl), File.join('.', 'lib'))
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
desc 'Install'
|
30
30
|
task :install do
|
31
|
-
sh 'mv target/picrate-0.
|
31
|
+
sh 'mv target/picrate-0.4.0.jar lib'
|
32
32
|
end
|
33
33
|
|
34
34
|
desc 'Gem'
|
data/lib/picrate.rb
CHANGED
data/lib/picrate/app.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
require_relative 'helper_methods'
|
3
3
|
require_relative 'library_loader'
|
4
|
-
|
4
|
+
require 'jruby'
|
5
5
|
# A wrapper module for the processing App
|
6
6
|
module Processing
|
7
7
|
include_package 'processing.core' # imports the processing jar.
|
8
8
|
# Load vecmath, fastmath and mathtool modules
|
9
9
|
Java::Monkstone::PicrateLibrary.load(JRuby.runtime)
|
10
|
-
SKETCH_ROOT
|
11
|
-
|
12
|
-
# A utility to
|
10
|
+
SKETCH_ROOT ||= Dir.pwd
|
11
|
+
# JRuby::Util.load_ext('monkstone.PicrateLibrary')
|
12
|
+
# A utility to facilitate rendering of Vec2D and Vec3D as vertex
|
13
13
|
module Render
|
14
14
|
java_import 'monkstone.vecmath.AppRender'
|
15
15
|
java_import 'monkstone.vecmath.ShapeRender'
|
data/lib/picrate/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
java_import Java::Monkstone::ColorUtil
|
2
|
+
|
3
|
+
# class wraps a java color array (of signed int), supports shuffle!, last and
|
4
|
+
# ruby_code (string for use in ruby code). As well as ability to initialize
|
5
|
+
# with an ruby array of "web" color string
|
6
|
+
class ColorGroup
|
7
|
+
attr_reader :colors
|
8
|
+
def initialize(p5cols)
|
9
|
+
@colors = p5cols
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.from_web_array(web)
|
13
|
+
ColorGroup.new(ColorUtil.web_array(web))
|
14
|
+
end
|
15
|
+
|
16
|
+
def shuffle!
|
17
|
+
@colors = ColorUtil.shuffle(colors)
|
18
|
+
end
|
19
|
+
|
20
|
+
def ruby_code
|
21
|
+
ColorUtil.rubyString(colors)
|
22
|
+
end
|
23
|
+
|
24
|
+
def last
|
25
|
+
colors[0]
|
26
|
+
end
|
27
|
+
end
|
data/picrate.gemspec
CHANGED
@@ -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.
|
18
|
+
gem.files << 'lib/picrate-0.4.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.
|
4
|
+
id 'ruby-processing:picrate:0.4.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.'
|
@@ -24,7 +24,7 @@ project 'picrate', 'http://maven.apache.org' do
|
|
24
24
|
|
25
25
|
properties( 'jogl.version' => '2.3.2',
|
26
26
|
'jruby.api' => 'http://jruby.org/apidocs/',
|
27
|
-
'source.directory' => 'src',
|
27
|
+
'source.directory' => 'src/main',
|
28
28
|
'maven.compiler.target' => '1.8',
|
29
29
|
'processing.api' => 'http://processing.github.io/processing-javadocs/core/',
|
30
30
|
'picrate.basedir' => '${project.basedir}',
|
@@ -39,7 +39,7 @@ project 'picrate', 'http://maven.apache.org' do
|
|
39
39
|
|
40
40
|
plugin( :resources, '2.7',
|
41
41
|
'encoding' => 'UTF-8' )
|
42
|
-
plugin( :compiler, '3.
|
42
|
+
plugin( :compiler, '3.8.0',
|
43
43
|
'source' => '1.8',
|
44
44
|
'target' => '1.8' )
|
45
45
|
plugin( :pmd, '3.3',
|
@@ -48,12 +48,12 @@ project 'picrate', 'http://maven.apache.org' do
|
|
48
48
|
'targetJdk' => '${compileSource}' )
|
49
49
|
build do
|
50
50
|
resource do
|
51
|
-
directory '${source.directory}/
|
51
|
+
directory '${source.directory}/java'
|
52
52
|
includes ['**/**/*.glsl', '**/*.jnilib']
|
53
53
|
excludes '**/**/*.java'
|
54
54
|
end
|
55
55
|
resource do
|
56
|
-
directory '${source.directory}/
|
56
|
+
directory '${source.directory}/resources'
|
57
57
|
includes ['**/*.png', '*.txt']
|
58
58
|
end
|
59
59
|
end
|
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.
|
14
|
+
<version>0.4.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>
|
@@ -66,7 +66,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
66
66
|
<properties>
|
67
67
|
<jogl.version>2.3.2</jogl.version>
|
68
68
|
<jruby.api>http://jruby.org/apidocs/</jruby.api>
|
69
|
-
<source.directory>src</source.directory>
|
69
|
+
<source.directory>src/main</source.directory>
|
70
70
|
<maven.compiler.target>1.8</maven.compiler.target>
|
71
71
|
<processing.api>http://processing.github.io/processing-javadocs/core/</processing.api>
|
72
72
|
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
|
@@ -100,7 +100,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
100
100
|
<build>
|
101
101
|
<resources>
|
102
102
|
<resource>
|
103
|
-
<directory>${source.directory}/
|
103
|
+
<directory>${source.directory}/java</directory>
|
104
104
|
<includes>
|
105
105
|
<include>**/**/*.glsl</include>
|
106
106
|
<include>**/*.jnilib</include>
|
@@ -110,7 +110,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
110
110
|
</excludes>
|
111
111
|
</resource>
|
112
112
|
<resource>
|
113
|
-
<directory>${source.directory}/
|
113
|
+
<directory>${source.directory}/resources</directory>
|
114
114
|
<includes>
|
115
115
|
<include>**/*.png</include>
|
116
116
|
<include>*.txt</include>
|
@@ -127,7 +127,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
127
127
|
</plugin>
|
128
128
|
<plugin>
|
129
129
|
<artifactId>maven-compiler-plugin</artifactId>
|
130
|
-
<version>3.
|
130
|
+
<version>3.8.0</version>
|
131
131
|
<configuration>
|
132
132
|
<source>1.8</source>
|
133
133
|
<target>1.8</target>
|
@@ -1,24 +1,30 @@
|
|
1
1
|
/**
|
2
|
-
* This utility allows
|
3
|
-
* in their sketches. Includes a method to efficiently convert an
|
4
|
-
* strings to an
|
5
|
-
* int to a string that can be used in ruby code (to generate web color
|
6
|
-
* Copyright (c)
|
2
|
+
* This utility allows JRubyArt users to use the processing.org color method
|
3
|
+
* in their sketches. Includes a method to efficiently convert an cols of web
|
4
|
+
* strings to an cols of color int, and another to convert an cols of p5 color
|
5
|
+
* (int) to a string that can be used in ruby code (to generate web color cols).
|
6
|
+
* Copyright (c) 2015-18 Martin Prout.
|
7
7
|
* This utility is free software; you can redistribute it and/or modify
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
9
|
-
* the Free Software Foundation; either version
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
* the Free Software Foundation; either version 2.1 of the License, or (at
|
10
10
|
* your option) any later version.
|
11
11
|
*
|
12
|
-
* Obtain a copy of the license at http://www.gnu.org/licenses/
|
12
|
+
* Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html
|
13
13
|
*/
|
14
14
|
package monkstone;
|
15
15
|
|
16
|
+
import java.util.ArrayList;
|
17
|
+
import java.util.List;
|
18
|
+
import java.util.Random;
|
19
|
+
|
16
20
|
/**
|
17
21
|
*
|
18
|
-
*
|
22
|
+
* @author Martin Prout
|
19
23
|
*/
|
20
24
|
public class ColorUtil {
|
21
25
|
|
26
|
+
static final String TOO_BIG = "produces a line too long a line for code";
|
27
|
+
|
22
28
|
/**
|
23
29
|
* Returns hex long as a positive int unless greater than Integer.MAX_VALUE
|
24
30
|
* else return the complement as a negative integer or something like that
|
@@ -43,36 +49,55 @@ public class ColorUtil {
|
|
43
49
|
return java.awt.Color.decode(hexstring).getRGB();
|
44
50
|
}
|
45
51
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
/**
|
53
|
+
*
|
54
|
+
* @param web Array of web (hex) String
|
55
|
+
* @return cols of p5 color (int)
|
56
|
+
*/
|
57
|
+
static public int[] webArray(String... web) {
|
58
|
+
int[] result = new int[web.length];
|
59
|
+
for (int i = 0; i < web.length; i++) {
|
60
|
+
result[i] = java.awt.Color.decode(web[i]).getRGB();
|
61
|
+
}
|
62
|
+
return result;
|
63
|
+
}
|
58
64
|
|
59
65
|
/**
|
60
|
-
* Return a ruby string of the form "%w
|
66
|
+
* Return a ruby string of the form "%w[a b c]" where a, b, c are raw web
|
61
67
|
* strings. This string can be used in ruby code.
|
62
68
|
*
|
63
|
-
* @param
|
69
|
+
* @param p5colors cols of p5 colors (int)
|
64
70
|
* @return String for use in ruby
|
65
71
|
*/
|
66
|
-
static public String rubyString(int[]
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
static public String rubyString(int[] p5colors) {
|
73
|
+
if (p5colors.length > 8){ return TOO_BIG;}
|
74
|
+
StringBuilder sb = new StringBuilder("%w[");
|
75
|
+
for (int p5color : p5colors) {
|
76
|
+
sb.append(String.format("#%06X", (0xFFFFFF & p5color)));
|
77
|
+
sb.append(' ');
|
78
|
+
}
|
79
|
+
sb.deleteCharAt(sb.length() - 1);
|
80
|
+
sb.append("]\n");
|
81
|
+
return sb.toString();
|
82
|
+
}
|
83
|
+
|
84
|
+
static public String[] p5ToWeb(int[] p5colors) {
|
85
|
+
List<String> list = new ArrayList<>();
|
86
|
+
for (int p5color : p5colors) {
|
87
|
+
list.add(String.format("#%06X", (0xFFFFFF & p5color)));
|
88
|
+
}
|
89
|
+
return list.toArray(new String[0]);
|
90
|
+
}
|
91
|
+
|
92
|
+
static public int[] shuffle(int[] cols) {
|
93
|
+
Random rgen = new Random(); // Random number generator
|
94
|
+
for (int i = 0; i < cols.length; i++) {
|
95
|
+
int randomPosition = rgen.nextInt(cols.length);
|
96
|
+
int temp = cols[i];
|
97
|
+
cols[i] = cols[randomPosition];
|
98
|
+
cols[randomPosition] = temp;
|
73
99
|
}
|
74
|
-
|
75
|
-
return result.toString();
|
100
|
+
return cols;
|
76
101
|
}
|
77
102
|
|
78
103
|
/**
|
@@ -47,18 +47,29 @@ public class PShapeJava2D extends PShapeSVG {
|
|
47
47
|
Paint strokeGradientPaint;
|
48
48
|
Paint fillGradientPaint;
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
/**
|
51
|
+
*
|
52
|
+
* @param svg
|
53
|
+
*/
|
54
|
+
public PShapeJava2D(XML svg) {
|
52
55
|
super(svg);
|
53
56
|
}
|
54
57
|
|
55
|
-
|
56
|
-
|
58
|
+
/**
|
59
|
+
*
|
60
|
+
* @param parent
|
61
|
+
* @param properties
|
62
|
+
* @param parseKids
|
63
|
+
*/
|
64
|
+
public PShapeJava2D(PShapeSVG parent, XML properties, boolean parseKids) {
|
57
65
|
super(parent, properties, parseKids);
|
58
66
|
}
|
59
67
|
|
60
|
-
|
61
|
-
|
68
|
+
/**
|
69
|
+
*
|
70
|
+
* @param parent
|
71
|
+
*/
|
72
|
+
@Override
|
62
73
|
protected void setParent(PShapeSVG parent) {
|
63
74
|
super.setParent(parent);
|
64
75
|
|
@@ -74,7 +85,11 @@ public class PShapeJava2D extends PShapeSVG {
|
|
74
85
|
}
|
75
86
|
|
76
87
|
|
77
|
-
/** Factory method for subclasses.
|
88
|
+
/** Factory method for subclasses.
|
89
|
+
* @param parent
|
90
|
+
* @param properties
|
91
|
+
* @param parseKids
|
92
|
+
* @return */
|
78
93
|
@Override
|
79
94
|
protected PShapeSVG createShape(PShapeSVG parent, XML properties, boolean parseKids) {
|
80
95
|
return new PShapeJava2D(parent, properties, parseKids);
|
@@ -298,8 +313,12 @@ public class PShapeJava2D extends PShapeSVG {
|
|
298
313
|
}
|
299
314
|
}
|
300
315
|
|
301
|
-
|
302
|
-
|
316
|
+
/**
|
317
|
+
*
|
318
|
+
* @param gradient
|
319
|
+
* @return
|
320
|
+
*/
|
321
|
+
protected Paint calcGradientPaint(Gradient gradient) {
|
303
322
|
if (gradient instanceof LinearGradient) {
|
304
323
|
// System.out.println("creating linear gradient");
|
305
324
|
LinearGradient grad = (LinearGradient) gradient;
|
@@ -344,6 +363,11 @@ public class PShapeJava2D extends PShapeSVG {
|
|
344
363
|
|
345
364
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
346
365
|
|
366
|
+
/**
|
367
|
+
*
|
368
|
+
* @param g
|
369
|
+
*/
|
370
|
+
|
347
371
|
|
348
372
|
@Override
|
349
373
|
protected void styles(PGraphics g) {
|
@@ -57,7 +57,10 @@ import processing.core.PSurfaceNone;
|
|
57
57
|
import processing.event.KeyEvent;
|
58
58
|
import processing.event.MouseEvent;
|
59
59
|
|
60
|
-
|
60
|
+
/**
|
61
|
+
*
|
62
|
+
* @author tux
|
63
|
+
*/
|
61
64
|
public class PSurfaceAWT extends PSurfaceNone {
|
62
65
|
GraphicsDevice displayDevice;
|
63
66
|
|
@@ -92,8 +95,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
92
95
|
|
93
96
|
int windowScaleFactor;
|
94
97
|
|
95
|
-
|
96
|
-
|
98
|
+
/**
|
99
|
+
*
|
100
|
+
* @param graphics
|
101
|
+
*/
|
102
|
+
public PSurfaceAWT(PGraphics graphics) {
|
97
103
|
//this.graphics = graphics;
|
98
104
|
super(graphics);
|
99
105
|
|
@@ -183,6 +189,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
183
189
|
|
184
190
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
185
191
|
|
192
|
+
/**
|
193
|
+
*
|
194
|
+
*/
|
195
|
+
|
186
196
|
|
187
197
|
public class SmoothCanvas extends Canvas {
|
188
198
|
private Dimension oldSize = new Dimension(0, 0);
|
@@ -190,31 +200,47 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
190
200
|
|
191
201
|
|
192
202
|
// Turns out getParent() returns a JPanel on a JFrame. Yech.
|
203
|
+
|
204
|
+
/**
|
205
|
+
*
|
206
|
+
* @return
|
207
|
+
*/
|
193
208
|
public Frame getFrame() {
|
194
209
|
return frame;
|
195
210
|
}
|
196
211
|
|
197
|
-
|
198
|
-
|
212
|
+
/**
|
213
|
+
*
|
214
|
+
* @return
|
215
|
+
*/
|
216
|
+
@Override
|
199
217
|
public Dimension getPreferredSize() {
|
200
218
|
return new Dimension(sketchWidth, sketchHeight);
|
201
219
|
}
|
202
220
|
|
203
|
-
|
204
|
-
|
221
|
+
/**
|
222
|
+
*
|
223
|
+
* @return
|
224
|
+
*/
|
225
|
+
@Override
|
205
226
|
public Dimension getMinimumSize() {
|
206
227
|
return getPreferredSize();
|
207
228
|
}
|
208
229
|
|
209
|
-
|
210
|
-
|
230
|
+
/**
|
231
|
+
*
|
232
|
+
* @return
|
233
|
+
*/
|
234
|
+
@Override
|
211
235
|
public Dimension getMaximumSize() {
|
212
236
|
//return resizable ? super.getMaximumSize() : getPreferredSize();
|
213
237
|
return frame.isResizable() ? super.getMaximumSize() : getPreferredSize();
|
214
238
|
}
|
215
239
|
|
216
|
-
|
217
|
-
|
240
|
+
/**
|
241
|
+
*
|
242
|
+
*/
|
243
|
+
@Override
|
218
244
|
public void validate() {
|
219
245
|
super.validate();
|
220
246
|
newSize.width = getWidth();
|
@@ -235,15 +261,21 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
235
261
|
}
|
236
262
|
}
|
237
263
|
|
238
|
-
|
239
|
-
|
264
|
+
/**
|
265
|
+
*
|
266
|
+
* @param g
|
267
|
+
*/
|
268
|
+
@Override
|
240
269
|
public void update(Graphics g) {
|
241
270
|
// System.out.println("updating");
|
242
271
|
paint(g);
|
243
272
|
}
|
244
273
|
|
245
|
-
|
246
|
-
|
274
|
+
/**
|
275
|
+
*
|
276
|
+
* @param screen
|
277
|
+
*/
|
278
|
+
@Override
|
247
279
|
public void paint(Graphics screen) {
|
248
280
|
// System.out.println("painting");
|
249
281
|
// if (useStrategy) {
|
@@ -280,8 +312,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
280
312
|
}
|
281
313
|
*/
|
282
314
|
|
283
|
-
|
284
|
-
|
315
|
+
/**
|
316
|
+
*
|
317
|
+
*/
|
318
|
+
synchronized protected void render() {
|
285
319
|
if (canvas.isDisplayable() &&
|
286
320
|
graphics.image != null) {
|
287
321
|
if (canvas.getBufferStrategy() == null) {
|
@@ -357,6 +391,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
357
391
|
|
358
392
|
|
359
393
|
// what needs to happen here?
|
394
|
+
|
395
|
+
/**
|
396
|
+
*
|
397
|
+
* @param sketch
|
398
|
+
*/
|
360
399
|
@Override
|
361
400
|
public void initOffscreen(PApplet sketch) {
|
362
401
|
this.sketch = sketch;
|
@@ -384,8 +423,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
384
423
|
}
|
385
424
|
*/
|
386
425
|
|
387
|
-
|
388
|
-
|
426
|
+
/**
|
427
|
+
*
|
428
|
+
* @param sketch
|
429
|
+
*/
|
430
|
+
@Override
|
389
431
|
public void initFrame(final PApplet sketch) {/*, int backgroundColor,
|
390
432
|
int deviceIndex, boolean fullScreen, boolean spanDisplays) {*/
|
391
433
|
this.sketch = sketch;
|
@@ -558,7 +600,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
558
600
|
// }
|
559
601
|
|
560
602
|
|
561
|
-
/** Set the window (and dock, or whatever necessary) title.
|
603
|
+
/** Set the window (and dock, or whatever necessary) title.
|
604
|
+
* @param title */
|
562
605
|
@Override
|
563
606
|
public void setTitle(String title) {
|
564
607
|
frame.setTitle(title);
|
@@ -573,7 +616,8 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
573
616
|
}
|
574
617
|
|
575
618
|
|
576
|
-
/** Set true if we want to resize things (default is not resizable)
|
619
|
+
/** Set true if we want to resize things (default is not resizable)
|
620
|
+
* @param resizable */
|
577
621
|
@Override
|
578
622
|
public void setResizable(boolean resizable) {
|
579
623
|
//this.resizable = resizable; // really only used for canvas
|
@@ -583,26 +627,29 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
583
627
|
}
|
584
628
|
}
|
585
629
|
|
586
|
-
|
587
|
-
|
630
|
+
/**
|
631
|
+
*
|
632
|
+
* @param image
|
633
|
+
*/
|
634
|
+
@Override
|
588
635
|
public void setIcon(PImage image) {
|
589
636
|
Image awtImage = (Image) image.getNative();
|
590
|
-
|
591
|
-
if (PApplet.platform != PConstants.MACOSX) {
|
592
|
-
|
593
|
-
|
594
|
-
} else {
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
}
|
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
|
+
// }
|
606
653
|
}
|
607
654
|
|
608
655
|
|
@@ -611,8 +658,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
611
658
|
frame.setAlwaysOnTop(always);
|
612
659
|
}
|
613
660
|
|
614
|
-
|
615
|
-
|
661
|
+
/**
|
662
|
+
*
|
663
|
+
* @param x
|
664
|
+
* @param y
|
665
|
+
*/
|
666
|
+
@Override
|
616
667
|
public void setLocation(int x, int y) {
|
617
668
|
frame.setLocation(x, y);
|
618
669
|
}
|
@@ -620,10 +671,14 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
620
671
|
|
621
672
|
List<Image> iconImages;
|
622
673
|
|
623
|
-
|
674
|
+
/**
|
675
|
+
*
|
676
|
+
* @param frame
|
677
|
+
*/
|
678
|
+
protected void setProcessingIcon(Frame frame) {
|
624
679
|
// On OS X, this only affects what shows up in the dock when minimized.
|
625
680
|
// So replacing it is actually a step backwards. Brilliant.
|
626
|
-
if (PApplet.platform != PConstants.MACOSX) {
|
681
|
+
// if (PApplet.platform != PConstants.MACOSX) {
|
627
682
|
//Image image = Toolkit.getDefaultToolkit().createImage(ICON_IMAGE);
|
628
683
|
//frame.setIconImage(image);
|
629
684
|
try {
|
@@ -643,25 +698,25 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
643
698
|
|
644
699
|
} catch (Exception e) { } // harmless; keep this to ourselves
|
645
700
|
|
646
|
-
} else { // handle OS X differently
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
}
|
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
|
+
// }
|
665
720
|
}
|
666
721
|
|
667
722
|
|
@@ -712,6 +767,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
712
767
|
|
713
768
|
|
714
769
|
//public void placeFullScreen(boolean hideStop) {
|
770
|
+
|
771
|
+
/**
|
772
|
+
*
|
773
|
+
* @param stopColor
|
774
|
+
*/
|
715
775
|
@Override
|
716
776
|
public void placePresent(int stopColor) {
|
717
777
|
setFullFrame();
|
@@ -859,8 +919,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
859
919
|
//frame.setVisible(true); // re-add native resources
|
860
920
|
}
|
861
921
|
|
862
|
-
|
863
|
-
|
922
|
+
/**
|
923
|
+
*
|
924
|
+
* @param location
|
925
|
+
* @param editorLocation
|
926
|
+
*/
|
927
|
+
@Override
|
864
928
|
public void placeWindow(int[] location, int[] editorLocation) {
|
865
929
|
//Dimension window = setFrameSize(sketchWidth, sketchHeight);
|
866
930
|
Dimension window = setFrameSize(); //sketchWidth, sketchHeight);
|
@@ -943,6 +1007,12 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
943
1007
|
|
944
1008
|
|
945
1009
|
// needs to resize the frame, which will resize the canvas, and so on...
|
1010
|
+
|
1011
|
+
/**
|
1012
|
+
*
|
1013
|
+
* @param wide
|
1014
|
+
* @param high
|
1015
|
+
*/
|
946
1016
|
@Override
|
947
1017
|
public void setSize(int wide, int high) {
|
948
1018
|
// When the surface is set to resizable via surface.setResizable(true),
|
@@ -1235,6 +1305,7 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1235
1305
|
* Figure out how to process a mouse event. When loop() has been
|
1236
1306
|
* called, the events will be queued up until drawing is complete.
|
1237
1307
|
* If noLoop() has been called, then events will happen immediately.
|
1308
|
+
* @param nativeEvent
|
1238
1309
|
*/
|
1239
1310
|
protected void nativeMouseEvent(java.awt.event.MouseEvent nativeEvent) {
|
1240
1311
|
// the 'amount' is the number of button clicks for a click event,
|
@@ -1334,8 +1405,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1334
1405
|
peCount));
|
1335
1406
|
}
|
1336
1407
|
|
1337
|
-
|
1338
|
-
|
1408
|
+
/**
|
1409
|
+
*
|
1410
|
+
* @param event
|
1411
|
+
*/
|
1412
|
+
protected void nativeKeyEvent(java.awt.event.KeyEvent event) {
|
1339
1413
|
int peAction = 0;
|
1340
1414
|
switch (event.getID()) {
|
1341
1415
|
case java.awt.event.KeyEvent.KEY_PRESSED:
|
@@ -1367,6 +1441,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1367
1441
|
|
1368
1442
|
|
1369
1443
|
// listeners, for all my men!
|
1444
|
+
|
1445
|
+
/**
|
1446
|
+
*
|
1447
|
+
*/
|
1370
1448
|
protected void addListeners() {
|
1371
1449
|
|
1372
1450
|
canvas.addMouseListener(new MouseListener() {
|
@@ -1480,8 +1558,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1480
1558
|
boolean cursorVisible = true;
|
1481
1559
|
Cursor invisibleCursor;
|
1482
1560
|
|
1483
|
-
|
1484
|
-
|
1561
|
+
/**
|
1562
|
+
*
|
1563
|
+
* @param kind
|
1564
|
+
*/
|
1565
|
+
@Override
|
1485
1566
|
public void setCursor(int kind) {
|
1486
1567
|
// Swap the HAND cursor because MOVE doesn't seem to be available on OS X
|
1487
1568
|
// https://github.com/processing/processing/issues/2358
|
@@ -1493,8 +1574,13 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1493
1574
|
this.cursorType = kind;
|
1494
1575
|
}
|
1495
1576
|
|
1496
|
-
|
1497
|
-
|
1577
|
+
/**
|
1578
|
+
*
|
1579
|
+
* @param img
|
1580
|
+
* @param x
|
1581
|
+
* @param y
|
1582
|
+
*/
|
1583
|
+
@Override
|
1498
1584
|
public void setCursor(PImage img, int x, int y) {
|
1499
1585
|
// Don't set cursorType, instead use cursorType to save the last
|
1500
1586
|
// regular cursor type used for when cursor() is called.
|
@@ -1514,8 +1600,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1514
1600
|
cursorVisible = true;
|
1515
1601
|
}
|
1516
1602
|
|
1517
|
-
|
1518
|
-
|
1603
|
+
/**
|
1604
|
+
*
|
1605
|
+
*/
|
1606
|
+
@Override
|
1519
1607
|
public void showCursor() {
|
1520
1608
|
// Maybe should always set here? Seems dangerous, since it's likely that
|
1521
1609
|
// Java will set the cursor to something else on its own, and the sketch
|
@@ -1526,8 +1614,10 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1526
1614
|
}
|
1527
1615
|
}
|
1528
1616
|
|
1529
|
-
|
1530
|
-
|
1617
|
+
/**
|
1618
|
+
*
|
1619
|
+
*/
|
1620
|
+
@Override
|
1531
1621
|
public void hideCursor() {
|
1532
1622
|
// Because the OS may have shown the cursor on its own,
|
1533
1623
|
// don't return if 'cursorVisible' is set to true. [rev 0216]
|
@@ -1548,8 +1638,11 @@ public class PSurfaceAWT extends PSurfaceNone {
|
|
1548
1638
|
cursorVisible = false;
|
1549
1639
|
}
|
1550
1640
|
|
1551
|
-
|
1552
|
-
|
1641
|
+
/**
|
1642
|
+
*
|
1643
|
+
* @return
|
1644
|
+
*/
|
1645
|
+
@Override
|
1553
1646
|
public Thread createThread() {
|
1554
1647
|
return new AnimationThread() {
|
1555
1648
|
@Override
|