Skip to content

Commit ef9d4c4

Browse files
committed
more package movement for the separate renderers
1 parent 44c05ee commit ef9d4c4

File tree

10 files changed

+43
-22
lines changed

10 files changed

+43
-22
lines changed

core/src/processing/core/PGraphicsJava2D.java renamed to core/src/processing/awt/PGraphicsJava2D.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Boston, MA 02111-1307 USA
2323
*/
2424

25-
package processing.core;
25+
package processing.awt;
2626

2727
import java.awt.*;
2828
import java.awt.font.TextAttribute;
@@ -32,6 +32,8 @@
3232
import java.util.HashMap;
3333
import java.util.Map;
3434

35+
import processing.core.*;
36+
3537

3638
/**
3739
* Subclass for PGraphics that implements the graphics API using Java2D.
@@ -1571,7 +1573,7 @@ protected void imageImpl(PImage who,
15711573
cash = new ImageCache(); //who);
15721574
setCache(who, cash);
15731575
who.updatePixels(); // mark the whole thing for update
1574-
who.modified = true;
1576+
who.setModified();
15751577
}
15761578

15771579
// If image previously was tinted, or the color changed
@@ -1583,15 +1585,15 @@ protected void imageImpl(PImage who,
15831585
who.updatePixels();
15841586
}
15851587

1586-
if (who.modified) {
1588+
if (who.isModified()) {
15871589
if (who.pixels == null) {
15881590
// This might be a PGraphics that hasn't been drawn to yet.
15891591
// Can't just bail because the cache has been created above.
15901592
// https://github.com/processing/processing/issues/2208
15911593
who.pixels = new int[who.width * who.height];
15921594
}
15931595
cash.update(who, tint, tintColor);
1594-
who.modified = false;
1596+
who.setModified(false);
15951597
}
15961598

15971599
g2.drawImage(((ImageCache) getCache(who)).image,
@@ -2030,7 +2032,7 @@ protected void textLineImpl(char buffer[], int start, int stop,
20302032
// also changes global setting for antialiasing, but this is because it's
20312033
// not possible to enable/disable them independently in some situations.
20322034
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
2033-
textFont.smooth ?
2035+
textFont.isSmooth() ?
20342036
RenderingHints.VALUE_ANTIALIAS_ON :
20352037
RenderingHints.VALUE_ANTIALIAS_OFF);
20362038

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Boston, MA 02111-1307 USA
2121
*/
2222

23-
package processing.core;
23+
package processing.awt;
2424

2525
import java.awt.*;
2626
import java.awt.event.*;
@@ -32,6 +32,11 @@
3232

3333
import javax.swing.JFrame;
3434

35+
import processing.core.PApplet;
36+
import processing.core.PConstants;
37+
import processing.core.PGraphics;
38+
import processing.core.PImage;
39+
import processing.core.PSurfaceNone;
3540
import processing.event.KeyEvent;
3641
import processing.event.MouseEvent;
3742

@@ -101,7 +106,7 @@ public PSurfaceAWT(PGraphics graphics) {
101106
canvas.addComponentListener(new ComponentAdapter() {
102107
@Override
103108
public void componentResized(ComponentEvent e) {
104-
if (!sketch.looping) {
109+
if (!sketch.isLooping()) {
105110
// make sure this is a real resize event, not just initial setup
106111
// https://github.com/processing/processing/issues/3310
107112
Dimension canvasSize = canvas.getSize();
@@ -792,16 +797,16 @@ public void placeWindow(int[] location, int[] editorLocation) {
792797
// needs to resize the frame, which will resize the canvas, and so on...
793798
@Override
794799
public void setSize(int wide, int high) {
795-
if (PApplet.DEBUG) {
796-
//System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
797-
new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
798-
}
800+
// if (PApplet.DEBUG) {
801+
// //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
802+
// new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out);
803+
// }
799804

800805
//if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch
801806
if (wide == sketch.width && high == sketch.height) {
802-
if (PApplet.DEBUG) {
803-
new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
804-
}
807+
// if (PApplet.DEBUG) {
808+
// new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out);
809+
// }
805810
return; // unchanged, don't rebuild everything
806811
}
807812

core/src/processing/core/PApplet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,11 @@ synchronized public void noLoop() {
25262526
}
25272527

25282528

2529+
public boolean isLooping() {
2530+
return looping;
2531+
}
2532+
2533+
25292534
//////////////////////////////////////////////////////////////
25302535

25312536

core/src/processing/core/PConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public interface PConstants {
5757
});
5858
*/
5959

60-
static final String JAVA2D = "processing.core.PGraphicsJava2D";
60+
static final String JAVA2D = "processing.awt.PGraphicsJava2D";
6161

6262
static final String P2D = "processing.opengl.PGraphics2D";
6363
static final String P3D = "processing.opengl.PGraphics3D";
@@ -70,7 +70,7 @@ public interface PConstants {
7070
// static final String E2D = PGraphicsDanger2D.class.getName();
7171

7272
// Experimental JavaFX renderer; even better 2D performance
73-
static final String FX2D = "processing.core.PGraphicsFX2D";
73+
static final String FX2D = "processing.javafx.PGraphicsFX2D";
7474

7575
static final String PDF = "processing.pdf.PGraphicsPDF";
7676
static final String SVG = "processing.svg.PGraphicsSVG";

core/src/processing/core/PFont.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ public int getDefaultSize() {
560560
}
561561

562562

563+
public boolean isSmooth() {
564+
return smooth;
565+
}
566+
567+
563568
public boolean isStream() {
564569
return stream;
565570
}

core/src/processing/core/PGraphics.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.HashMap;
3636
import java.util.WeakHashMap;
3737

38+
import processing.awt.PSurfaceAWT;
3839
import processing.opengl.PGL;
3940
import processing.opengl.PShader;
4041

core/src/processing/core/PShapeSVG.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
package processing.core;
2525

26+
import processing.awt.PGraphicsJava2D;
2627
import processing.data.*;
2728

2829
import java.awt.Paint;

core/src/processing/core/PSurfaceNone.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
* class for other drawing surfaces. It includes the standard rendering loop.
2929
*/
3030
public class PSurfaceNone implements PSurface {
31-
PApplet sketch;
32-
PGraphics graphics;
31+
protected PApplet sketch;
32+
protected PGraphics graphics;
3333

34-
Thread thread;
35-
boolean paused;
36-
Object pauseObject = new Object();
34+
protected Thread thread;
35+
protected boolean paused;
36+
protected Object pauseObject = new Object();
3737

3838
protected float frameRateTarget = 60;
3939
protected long frameRatePeriod = 1000000000L / 60L;
@@ -245,7 +245,7 @@ public void setFrameRate(float fps) {
245245
}
246246

247247

248-
class AnimationThread extends Thread {
248+
public class AnimationThread extends Thread {
249249

250250
public AnimationThread() {
251251
super("Animation Thread");

java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.lowagie.text.*;
3030
import com.lowagie.text.pdf.*;
3131

32+
import processing.awt.PGraphicsJava2D;
3233
import processing.core.*;
3334

3435

java/libraries/svg/src/processing/svg/PGraphicsSVG.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.w3c.dom.Document;
3131
import org.w3c.dom.DOMImplementation;
3232

33+
import processing.awt.PGraphicsJava2D;
3334
import processing.core.*;
3435

3536

0 commit comments

Comments
 (0)