Skip to content

Commit 065793f

Browse files
committed
JRubyArt-3.1.0 ready
1 parent 4066acd commit 065793f

File tree

2 files changed

+71
-59
lines changed

2 files changed

+71
-59
lines changed

lib/propane/helper_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def find_method(method_name)
116116
# some methods. Add to this list as needed.
117117
def proxy_java_fields
118118
fields = %w[key frameRate mousePressed keyPressed]
119-
methods = fields.map { |field| java_class.declared_field(field) }
119+
methods = fields.map { |field| java_class.field(field) }
120120
@declared_fields = Hash[fields.zip(methods)]
121121
end
122122

src/main/java/processing/core/PApplet.java

Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,17 +1337,19 @@ protected int findIndex(Object object) {
13371337
* @param target the target object that should receive the event
13381338
*/
13391339
public void registerMethod(String methodName, Object target) {
1340-
if (methodName.equals("mouseEvent")) {
1341-
registerWithArgs("mouseEvent", target, new Class[]{processing.event.MouseEvent.class});
1342-
1343-
} else if (methodName.equals("keyEvent")) {
1344-
registerWithArgs("keyEvent", target, new Class[]{processing.event.KeyEvent.class});
1345-
1346-
} else if (methodName.equals("touchEvent")) {
1347-
registerWithArgs("touchEvent", target, new Class[]{processing.event.TouchEvent.class});
1348-
1349-
} else {
1350-
registerNoArgs(methodName, target);
1340+
switch (methodName) {
1341+
case "mouseEvent":
1342+
registerWithArgs("mouseEvent", target, new Class[]{processing.event.MouseEvent.class});
1343+
break;
1344+
case "keyEvent":
1345+
registerWithArgs("keyEvent", target, new Class[]{processing.event.KeyEvent.class});
1346+
break;
1347+
case "touchEvent":
1348+
registerWithArgs("touchEvent", target, new Class[]{processing.event.TouchEvent.class});
1349+
break;
1350+
default:
1351+
registerNoArgs(methodName, target);
1352+
break;
13511353
}
13521354
}
13531355

@@ -2086,7 +2088,7 @@ protected PGraphics makeGraphics(int w, int h,
20862088
+ " renderer is not in the class path.");
20872089
}
20882090

2089-
} catch (Exception e) {
2091+
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException e) {
20902092
if ((e instanceof IllegalArgumentException)
20912093
|| (e instanceof NoSuchMethodException)
20922094
|| (e instanceof IllegalAccessException)) {
@@ -2116,6 +2118,7 @@ protected PGraphics makeGraphics(int w, int h,
21162118
/**
21172119
* Create default renderer, likely to be resized, but needed for surface
21182120
* init.
2121+
* @return
21192122
*/
21202123
protected PGraphics createPrimaryGraphics() {
21212124
return makeGraphics(sketchWidth(), sketchHeight(),
@@ -2125,9 +2128,9 @@ protected PGraphics createPrimaryGraphics() {
21252128
/**
21262129
* ( begin auto-generated from createImage.xml )
21272130
*
2128-
* Creates a new PImage (the datatype for storing images). This provides a
2129-
* fresh buffer of pixels to play with. Set the size of the buffer with the
2130-
* <b>width</b> and <b>height</b> parameters. The <b>format</b> parameter
2131+
* Creates a new PImage (the datatype for storing images).This provides a
2132+
fresh buffer of pixels to play with. Set the size of the buffer with the
2133+
<b>width</b> and <b>height</b> parameters. The <b>format</b> parameter
21312134
* defines how the pixels are stored. See the PImage reference for more
21322135
* information.
21332136
*
@@ -2143,6 +2146,7 @@ protected PGraphics createPrimaryGraphics() {
21432146
* to the parent PApplet is included, which makes save() work without
21442147
* needing an absolute path.
21452148
*
2149+
* @return
21462150
* @webref image
21472151
* @param w width in pixels
21482152
* @param h height in pixels
@@ -2401,6 +2405,7 @@ public boolean isLooping() {
24012405
/**
24022406
* Add an event to the internal event queue, or process it immediately if
24032407
* the sketch is not currently looping.
2408+
* @param pe
24042409
*/
24052410
public void postEvent(processing.event.Event pe) {
24062411
eventQueue.add(pe);
@@ -3187,14 +3192,14 @@ public void link(String url) {
31873192
/**
31883193
* ( begin auto-generated from launch.xml )
31893194
*
3190-
* Attempts to open an application or file using your platform's launcher.
3191-
* The <b>file</b> parameter is a String specifying the file name and
3192-
* location. The location parameter must be a full path name, or the name of
3193-
* an executable in the system's PATH. In most cases, using a full path is
3194-
* the best option, rather than relying on the system PATH. Be sure to make
3195-
* the file executable before attempting to open it (chmod +x).
3196-
*
3197-
* The <b>args</b> parameter is a String or String array which is passed to
3195+
* Attempts to open an application or file using your platform's launcher.The <b>file</b> parameter is a String specifying the file name and
3196+
location.
3197+
* The location parameter must be a full path name, or the name of
3198+
an executable in the system's PATH. In most cases, using a full path is
3199+
the best option, rather than relying on the system PATH. Be sure to make
3200+
the file executable before attempting to open it (chmod +x).
3201+
3202+
The <b>args</b> parameter is a String or String array which is passed to
31983203
* the command line. If you have multiple parameters, e.g. an application
31993204
* and a document, or a command with multiple switches, use the version that
32003205
* takes a String array, and place each individual item in a separate
@@ -3219,49 +3224,52 @@ public void link(String url) {
32193224
*
32203225
* ( end auto-generated )
32213226
*
3227+
* @return
32223228
* @webref input:files
32233229
* @param args arguments to the launcher, eg. a filename.
32243230
* @usage Application
32253231
*/
32263232
static public Process launch(String... args) {
32273233
String[] params = null;
32283234

3229-
if (platform == WINDOWS) {
3230-
// just launching the .html file via the shell works
3231-
// but make sure to chmod +x the .html files first
3232-
// also place quotes around it in case there's a space
3233-
// in the user.dir part of the url
3234-
params = new String[]{"cmd", "/c"};
3235-
3236-
} else if (platform == MACOS) {
3237-
params = new String[]{"open"};
3238-
3239-
} else if (platform == LINUX) {
3240-
// xdg-open is in the Free Desktop Specification and really should just
3241-
// work on desktop Linux. Not risking it though.
3242-
final String[] launchers = {"xdg-open", "gnome-open", "kde-open"};
3243-
for (String launcher : launchers) {
3244-
if (openLauncher != null) {
3245-
break;
3246-
}
3247-
try {
3248-
Process p = Runtime.getRuntime().exec(new String[]{launcher});
3249-
/*int result =*/ p.waitFor();
3250-
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3251-
openLauncher = launcher;
3252-
} catch (Exception e) {
3235+
switch (platform) {
3236+
case WINDOWS:
3237+
// just launching the .html file via the shell works
3238+
// but make sure to chmod +x the .html files first
3239+
// also place quotes around it in case there's a space
3240+
// in the user.dir part of the url
3241+
params = new String[]{"cmd", "/c"};
3242+
break;
3243+
case MACOS:
3244+
params = new String[]{"open"};
3245+
break;
3246+
case LINUX:
3247+
// xdg-open is in the Free Desktop Specification and really should just
3248+
// work on desktop Linux. Not risking it though.
3249+
final String[] launchers = {"xdg-open", "gnome-open", "kde-open"};
3250+
for (String launcher : launchers) {
3251+
if (openLauncher != null) {
3252+
break;
3253+
}
3254+
try {
3255+
Process p = Runtime.getRuntime().exec(new String[]{launcher});
3256+
/*int result =*/ p.waitFor();
3257+
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3258+
openLauncher = launcher;
3259+
} catch (Exception e) {
3260+
}
3261+
} if (openLauncher == null) {
3262+
System.err.println("Could not find xdg-open, gnome-open, or kde-open: "
3263+
+ "the open() command may not work.");
3264+
} if (openLauncher != null) {
3265+
params = new String[]{openLauncher};
32533266
}
3254-
}
3255-
if (openLauncher == null) {
3256-
System.err.println("Could not find xdg-open, gnome-open, or kde-open: "
3257-
+ "the open() command may not work.");
3258-
}
3259-
if (openLauncher != null) {
3260-
params = new String[]{openLauncher};
3261-
}
3262-
//} else { // give up and just pass it to Runtime.exec()
3263-
//open(new String[] { filename });
3264-
//params = new String[] { filename };
3267+
//} else { // give up and just pass it to Runtime.exec()
3268+
//open(new String[] { filename });
3269+
//params = new String[] { filename };
3270+
break;
3271+
default:
3272+
break;
32653273
}
32663274
if (params != null) {
32673275
// If the 'open', 'gnome-open' or 'cmd' are already included
@@ -7527,6 +7535,7 @@ static public String[] expand(String[] list, int newSize) {
75277535
}
75287536

75297537
/**
7538+
* @param array
75307539
* @nowebref
75317540
*/
75327541
static public Object expand(Object array) {
@@ -9649,6 +9658,7 @@ public void frameResized(int w, int h) {
96499658
* All parameters *after* the sketch class name are passed to the sketch
96509659
* itself and available from its 'args' array while the sketch is running.
96519660
*
9661+
* @param args
96529662
* @see PApplet#args
96539663
* </PRE>
96549664
*/
@@ -9659,6 +9669,8 @@ static public void main(final String[] args) {
96599669
/**
96609670
* Convenience method so that PApplet.main(YourSketch.class) launches a
96619671
* sketch, rather than having to call getName() on it.
9672+
* @param mainClass
9673+
* @param args
96629674
*/
96639675
static public void main(final Class<?> mainClass, String... args) {
96649676
main(mainClass.getName(), args);

0 commit comments

Comments
 (0)