@@ -203,7 +203,8 @@ public void addNotify() {
203203 protected synchronized void render () {
204204 if (!EventQueue .isDispatchThread ()) {
205205 //throw new IllegalStateException("render() called outside the EDT");
206- System .err .println ("render() called outside the EDT" );
206+ //System.err.println("render() called outside the EDT");
207+ new Exception ("render() called outside the EDT" ).printStackTrace ();
207208 }
208209// if (canvas == null) {
209210// removeListeners(this);
@@ -739,6 +740,18 @@ public void setSize(int wide, int high) {
739740// frame.setLocationRelativeTo(null);
740741// }
741742
743+ initImage (graphics , wide , high );
744+
745+ //throw new RuntimeException("implement me, see readme.md");
746+ sketch .width = wide ;
747+ sketch .height = high ;
748+
749+ // set PGraphics variables for width/height/pixelWidth/pixelHeight
750+ graphics .setSize (wide , high );
751+ }
752+
753+
754+ public void initImage (PGraphics gr , int wide , int high ) {
742755 GraphicsConfiguration gc = canvas .getGraphicsConfiguration ();
743756 // If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
744757 if (gc == null ) {
@@ -749,15 +762,8 @@ public void setSize(int wide, int high) {
749762
750763 // Formerly this was broken into separate versions based on offscreen or
751764 // not, but we may as well create a compatible image; it won't hurt, right?
752- int factor = graphics .pixelFactor ;
753- graphics .image = gc .createCompatibleImage (wide * factor , high * factor );
754-
755- //throw new RuntimeException("implement me, see readme.md");
756- sketch .width = wide ;
757- sketch .height = high ;
758-
759- // sets internal variables for width/height/pixelWidth/pixelHeight
760- graphics .setSize (wide , high );
765+ int factor = gr .pixelFactor ;
766+ gr .image = gc .createCompatibleImage (wide * factor , high * factor );
761767 }
762768
763769
0 commit comments