diff --git a/core/src/processing/core/PSurfaceAWT.java b/core/src/processing/core/PSurfaceAWT.java index 4c5e119c9..48657b1a2 100644 --- a/core/src/processing/core/PSurfaceAWT.java +++ b/core/src/processing/core/PSurfaceAWT.java @@ -61,7 +61,8 @@ public class PSurfaceAWT extends PSurfaceNone { public PSurfaceAWT(PGraphics graphics) { - this.graphics = graphics; + //this.graphics = graphics; + super(graphics); if (checkRetina()) { // System.out.println("retina in use"); diff --git a/core/src/processing/core/PSurfaceNone.java b/core/src/processing/core/PSurfaceNone.java index 66fe993a1..8d422548f 100644 --- a/core/src/processing/core/PSurfaceNone.java +++ b/core/src/processing/core/PSurfaceNone.java @@ -22,9 +22,6 @@ package processing.core; -//import java.awt.Color; -//import java.awt.Component; - /** * Surface that's not really visible. Used for PDF and friends, or as a base @@ -32,6 +29,7 @@ package processing.core; */ public class PSurfaceNone implements PSurface { PApplet sketch; + PGraphics graphics; Thread thread; boolean paused; @@ -41,7 +39,9 @@ public class PSurfaceNone implements PSurface { protected long frameRatePeriod = 1000000000L / 60L; - public PSurfaceNone() { } + public PSurfaceNone(PGraphics graphics) { + this.graphics = graphics; + } @Override @@ -98,9 +98,27 @@ public class PSurfaceNone implements PSurface { // - public void setSize(int width, int height) { - // TODO Auto-generated method stub + @Override + public void setSize(int wide, int high) { + if (PApplet.DEBUG) { + //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high); + new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out); + } + //if (wide == sketchWidth && high == sketchHeight) { // doesn't work on launch + if (wide == sketch.width && high == sketch.height) { + if (PApplet.DEBUG) { + new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out); + } + return; // unchanged, don't rebuild everything + } + + //throw new RuntimeException("implement me, see readme.md"); + sketch.width = wide; + sketch.height = high; + + // set PGraphics variables for width/height/pixelWidth/pixelHeight + graphics.setSize(wide, high); } diff --git a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java index 058e938fd..a25452bc1 100644 --- a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java @@ -104,7 +104,7 @@ public class PGraphicsPDF extends PGraphicsJava2D { @Override public PSurface createSurface() { - return surface = new PSurfaceNone(); + return surface = new PSurfaceNone(this); }