Skip to content

Commit 753c599

Browse files
committed
move loadImage() into PSurface
1 parent 05f3cb0 commit 753c599

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

core/src/processing/awt/ShimAWT.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ public ShimAWT(PApplet sketch) {
4747
*/
4848

4949

50-
static public PImage loadImage(PApplet sketch, String filename, String extension) {
50+
static public PImage loadImage(PApplet sketch, String filename, Object... args) {
51+
String extension = null;
52+
if (args != null && args.length > 0) {
53+
// the only one that's supported for now
54+
extension = (String) args[0];
55+
}
56+
5157
if (extension == null) {
5258
String lower = filename.toLowerCase();
5359
int dot = filename.lastIndexOf('.');

core/src/processing/core/PApplet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5322,7 +5322,7 @@ public PImage loadImage(String filename, String extension) {
53225322
g.awaitAsyncSaveCompletion(filename);
53235323
}
53245324

5325-
return ShimAWT.loadImage(this, filename, extension);
5325+
return surface.loadImage(filename, extension);
53265326
}
53275327

53285328

core/src/processing/core/PSurface.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public interface PSurface {
5555

5656
//
5757

58+
public PImage loadImage(String path, Object... args);
59+
60+
//
61+
5862
public void selectInput(String prompt, String callback,
5963
File file, Object callbackObject);
6064

core/src/processing/core/PSurfaceNone.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import java.io.File;
2626

27+
import processing.awt.ShimAWT;
28+
2729
/**
2830
* Surface that's not really visible. Used for PDF and friends, or as a base
2931
* class for other drawing surfaces. It includes the standard rendering loop.
@@ -55,6 +57,11 @@ public int displayDensity(int display) {
5557
}
5658

5759

60+
public PImage loadImage(String path, Object... args) {
61+
return ShimAWT.loadImage(sketch, path, args);
62+
}
63+
64+
5865
public void selectInput(String prompt, String callback, File file,
5966
Object callbackObject) {
6067
}

core/src/processing/javafx/PSurfaceFX.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ public double prefHeight(double width) {
224224
}
225225

226226

227+
// TODO rewrite before 4.0 release
228+
public PImage loadImage(String path, Object... args) {
229+
return ShimAWT.loadImage(sketch, path, args);
230+
}
231+
232+
227233
@Override
228234
public void selectInput(String prompt, String callbackMethod,
229235
File file, Object callbackObject) {

core/src/processing/opengl/PSurfaceJOGL.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import com.jogamp.newt.opengl.GLWindow;
7070
import com.jogamp.opengl.util.FPSAnimator;
7171

72-
import processing.awt.ShimAWT;
7372
import processing.core.PApplet;
7473
import processing.core.PConstants;
7574
import processing.core.PGraphics;
@@ -78,13 +77,14 @@
7877
import processing.event.KeyEvent;
7978
import processing.event.MouseEvent;
8079

80+
// have this removed by 4.0 final
81+
import processing.awt.ShimAWT;
82+
8183

8284
public class PSurfaceJOGL implements PSurface {
8385
/** Selected GL profile */
8486
public static GLProfile profile;
8587

86-
ShimAWT shim;
87-
8888
public PJOGL pgl;
8989

9090
protected GLWindow window;
@@ -136,6 +136,12 @@ public int displayDensity(int display) {
136136
*/
137137

138138

139+
// TODO rewrite before 4.0 release
140+
public PImage loadImage(String path, Object... args) {
141+
return ShimAWT.loadImage(sketch, path, args);
142+
}
143+
144+
139145
@Override
140146
public void selectInput(String prompt, String callbackMethod,
141147
File file, Object callbackObject) {

core/todo.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ X move selectInput/Output/Folder to ShimAWT class
1313
X remove the java.awt.Frame object from PApplet
1414
X move loadImage() into ShimAWT
1515
X desktopFile() and desktopPath() methods are supported, unless we find they're trouble
16-
17-
_ move ShimAWT.loadImage() to the PSurface subclasses
16+
X move ShimAWT.loadImage() to the PSurface subclasses
1817

1918
api changes
2019
_ static versions of selectInput/selectOutput/selectFolder in PApplet have been removed

0 commit comments

Comments
 (0)