|
44 | 44 |
|
45 | 45 |
|
46 | 46 |
|
| 47 | + |
47 | 48 | // used by loadImage() functions |
48 | 49 | import javax.imageio.ImageIO; |
49 | 50 | import javax.swing.ImageIcon; |
@@ -1489,23 +1490,34 @@ public void size(int w, int h) { |
1489 | 1490 | size(w, h, sketchRenderer(), null); |
1490 | 1491 | } |
1491 | 1492 |
|
| 1493 | + |
1492 | 1494 | /** |
1493 | 1495 | * @param renderer Either P2D, P3D, or PDF |
1494 | 1496 | */ |
1495 | 1497 | public void size(int w, int h, String renderer) { |
1496 | 1498 | size(w, h, renderer, null); |
1497 | 1499 | } |
1498 | 1500 |
|
1499 | | -/** |
1500 | | - * @nowebref |
1501 | | - */ |
| 1501 | + |
| 1502 | + /** |
| 1503 | + * @nowebref |
| 1504 | + */ |
1502 | 1505 | public void size(final int w, final int h, String renderer, String path) { |
1503 | 1506 | if (!renderer.equals(sketchRenderer())) { |
1504 | | - System.err.println("Because you're not running from the PDE, add this to your code:"); |
1505 | | - System.err.println("public String sketchRenderer() {"); |
1506 | | - System.err.println(" return \"" + renderer + "\";"); |
1507 | | - System.err.println("}"); |
1508 | | - throw new RuntimeException("The sketchRenderer() method is not implemented."); |
| 1507 | + if (external) { |
| 1508 | + // The PDE should have parsed it, but something still went wrong |
| 1509 | + final String msg = |
| 1510 | + String.format("Something bad happened when calling " + |
| 1511 | + "size(%d, %d, %s, %s)", w, h, renderer, path); |
| 1512 | + throw new RuntimeException(msg); |
| 1513 | + |
| 1514 | + } else { |
| 1515 | + System.err.println("Because you're not running from the PDE, add this to your code:"); |
| 1516 | + System.err.println("public String sketchRenderer() {"); |
| 1517 | + System.err.println(" return \"" + renderer + "\";"); |
| 1518 | + System.err.println("}"); |
| 1519 | + throw new RuntimeException("The sketchRenderer() method is not implemented."); |
| 1520 | + } |
1509 | 1521 | } |
1510 | 1522 | surface.setSize(w, h); |
1511 | 1523 | g.setPath(path); // finally, a path |
@@ -1700,6 +1712,7 @@ protected PGraphics makeGraphics(int w, int h, |
1700 | 1712 |
|
1701 | 1713 | pg.setParent(this); |
1702 | 1714 | pg.setPrimary(primary); |
| 1715 | + System.out.println("path is " + path); |
1703 | 1716 | if (path != null) { |
1704 | 1717 | pg.setPath(path); |
1705 | 1718 | } |
@@ -1770,7 +1783,8 @@ protected PGraphics makeGraphics(int w, int h, |
1770 | 1783 |
|
1771 | 1784 | /** Create default renderer, likely to be resized, but needed for surface init. */ |
1772 | 1785 | protected PGraphics createPrimaryGraphics() { |
1773 | | - return makeGraphics(sketchWidth(), sketchHeight(), sketchRenderer(), null, true); |
| 1786 | + return makeGraphics(sketchWidth(), sketchHeight(), |
| 1787 | + sketchRenderer(), sketchOutputPath(), true); |
1774 | 1788 | } |
1775 | 1789 |
|
1776 | 1790 |
|
@@ -9643,9 +9657,8 @@ private void deprecationWarning(String method) { |
9643 | 9657 | surface.initFrame(this, backgroundColor, displayIndex, present, spanDisplays); |
9644 | 9658 | surface.setTitle(getClass().getName()); |
9645 | 9659 | //frame.setTitle(getClass().getName()); |
9646 | | -// } else { |
9647 | | -// // TODO necessary? |
9648 | | -// surface.initOffscreen(this); |
| 9660 | + } else { |
| 9661 | + surface.initOffscreen(this); // for PDF, PSurfaceNone, and friends |
9649 | 9662 | } |
9650 | 9663 |
|
9651 | 9664 | init(); |
|
0 commit comments