| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,6 +55,8 @@ inside main, will know the screen that's being used for the app | |||
| 55 | 55 | - The size() JavaDoc in PApplet is comically old | |
| 56 | 56 | - Does createFont() need to run through PGraphics? | |
| 57 | 57 | - Need to fix sketch placement issues (default size with long setup(), etc) Actually, the default size with long setup() is probably that defaultSize is set false, but the initial render doesn't finish before width/height are set to something useful. | |
| 58 | + - selectInput(), selectOutput(), selectFolder() now passing 'null' as parent Window. Should just leave them un-anchored, but need to test to make this doesn't break anything else. | ||
| 59 | + - do we need sketchOutputPath() and sketchOutputStream()? | ||
| 58 | 60 | ||
| 59 | 61 | #### Removed functions (not final, just notes) | |
| 60 | 62 | param() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ | |||
| 30 | 30 | import java.awt.Desktop; | |
| 31 | 31 | import java.awt.EventQueue; | |
| 32 | 32 | import java.awt.FileDialog; | |
| 33 | + import java.awt.Font; | ||
| 33 | 34 | // for the Frame object (deprecate?) | |
| 34 | 35 | import java.awt.Frame; | |
| 35 | 36 | import java.awt.GraphicsConfiguration; | |
@@ -54,7 +55,6 @@ | |||
| 54 | 55 | // used by loadImage() functions | |
| 55 | 56 | import javax.imageio.ImageIO; | |
| 56 | 57 | import javax.swing.ImageIcon; | |
| 57 | - | ||
| 58 | 58 | import javax.swing.JFrame; | |
| 59 | 59 | import javax.swing.JFileChooser; | |
| 60 | 60 | import javax.swing.filechooser.FileSystemView; | |
@@ -788,6 +788,16 @@ public boolean sketchSpanScreens() { | |||
| 788 | 788 | } | |
| 789 | 789 | ||
| 790 | 790 | ||
| 791 | + public String sketchOutputPath() { | ||
| 792 | + return null; | ||
| 793 | + } | ||
| 794 | + | ||
| 795 | + | ||
| 796 | + public OutputStream sketchOutputStream() { | ||
| 797 | + return null; | ||
| 798 | + } | ||
| 799 | + | ||
| 800 | + | ||
| 791 | 801 | public void orientation(int which) { | |
| 792 | 802 | // ignore calls to the orientation command | |
| 793 | 803 | } | |
@@ -1336,6 +1346,7 @@ public void draw() { | |||
| 1336 | 1346 | ////////////////////////////////////////////////////////////// | |
| 1337 | 1347 | ||
| 1338 | 1348 | ||
| 1349 | + /* | ||
| 1339 | 1350 | protected void resizeRenderer(int newWidth, int newHeight) { | |
| 1340 | 1351 | debug("resizeRenderer request for " + newWidth + " " + newHeight); | |
| 1341 | 1352 | if (width != newWidth || height != newHeight) { | |
@@ -1345,6 +1356,7 @@ protected void resizeRenderer(int newWidth, int newHeight) { | |||
| 1345 | 1356 | height = newHeight; | |
| 1346 | 1357 | } | |
| 1347 | 1358 | } | |
| 1359 | + */ | ||
| 1348 | 1360 | ||
| 1349 | 1361 | ||
| 1350 | 1362 | /** | |
@@ -1435,49 +1447,58 @@ public void size(int w, int h, String renderer) { | |||
| 1435 | 1447 | /** | |
| 1436 | 1448 | * @nowebref | |
| 1437 | 1449 | */ | |
| 1438 | - public void size(final int w, final int h, | ||
| 1439 | - String renderer, String path) { | ||
| 1440 | - // Run this from the EDT, just cuz it's AWT stuff (or maybe later Swing) | ||
| 1441 | - EventQueue.invokeLater(new Runnable() { | ||
| 1442 | - public void run() { | ||
| 1443 | - // Set the preferred size so that the layout managers can handle it | ||
| 1444 | - setPreferredSize(new Dimension(w, h)); | ||
| 1445 | - setSize(w, h); | ||
| 1446 | - } | ||
| 1447 | - }); | ||
| 1448 | - | ||
| 1449 | - // ensure that this is an absolute path | ||
| 1450 | - if (path != null) path = savePath(path); | ||
| 1451 | - | ||
| 1452 | - String currentRenderer = g.getClass().getName(); | ||
| 1453 | - if (currentRenderer.equals(renderer)) { | ||
| 1454 | - // // Avoid infinite loop of throwing exception to reset renderer | ||
| 1455 | - // resizeRenderer(w, h); | ||
| 1456 | - surface.setSize(w, h); | ||
| 1457 | - | ||
| 1458 | - } else { // renderer change attempted | ||
| 1459 | - // no longer kosher with 3.0a5 | ||
| 1460 | - throw new RuntimeException("Y'all need to implement sketchRenderer()"); | ||
| 1461 | - /* | ||
| 1462 | - // otherwise ok to fall through and create renderer below | ||
| 1463 | - // the renderer is changing, so need to create a new object | ||
| 1464 | - g = makeGraphics(w, h, renderer, path, true); | ||
| 1465 | - this.width = w; | ||
| 1466 | - this.height = h; | ||
| 1467 | - | ||
| 1468 | - // fire resize event to make sure the applet is the proper size | ||
| 1469 | - // setSize(iwidth, iheight); | ||
| 1470 | - // this is the function that will run if the user does their own | ||
| 1471 | - // size() command inside setup, so set defaultSize to false. | ||
| 1472 | - defaultSize = false; | ||
| 1473 | - | ||
| 1474 | - // throw an exception so that setup() is called again | ||
| 1475 | - // but with a properly sized render | ||
| 1476 | - // this is for opengl, which needs a valid, properly sized | ||
| 1477 | - // display before calling anything inside setup(). | ||
| 1478 | - throw new RendererChangeException(); | ||
| 1479 | - */ | ||
| 1480 | - } | ||
| 1450 | + public void size(final int w, final int h, String renderer, String path) { | ||
| 1451 | + if (!renderer.equals(sketchRenderer())) { | ||
| 1452 | + System.err.println("Because you're not running from the PDE, add this to your code:"); | ||
| 1453 | + System.err.println("public String sketchRenderer() {"); | ||
| 1454 | + System.err.println(" return " + renderer + ";"); | ||
| 1455 | + System.err.println("}"); | ||
| 1456 | + throw new RuntimeException("The sketchRenderer() method is not implemented."); | ||
| 1457 | + } | ||
| 1458 | + surface.setSize(w, h); | ||
| 1459 | + g.setPath(path); // finally, a path | ||
| 1460 | + | ||
| 1461 | + // // Run this from the EDT, just cuz it's AWT stuff (or maybe later Swing) | ||
| 1462 | + // EventQueue.invokeLater(new Runnable() { | ||
| 1463 | + // public void run() { | ||
| 1464 | + // // Set the preferred size so that the layout managers can handle it | ||
| 1465 | + // setPreferredSize(new Dimension(w, h)); | ||
| 1466 | + // setSize(w, h); | ||
| 1467 | + // } | ||
| 1468 | + // }); | ||
| 1469 | + // | ||
| 1470 | + // // ensure that this is an absolute path | ||
| 1471 | + // if (path != null) path = savePath(path); | ||
| 1472 | + // | ||
| 1473 | + // String currentRenderer = g.getClass().getName(); | ||
| 1474 | + // if (currentRenderer.equals(renderer)) { | ||
| 1475 | + //// // Avoid infinite loop of throwing exception to reset renderer | ||
| 1476 | + //// resizeRenderer(w, h); | ||
| 1477 | + // surface.setSize(w, h); | ||
| 1478 | + // | ||
| 1479 | + // } else { // renderer change attempted | ||
| 1480 | + // // no longer kosher with 3.0a5 | ||
| 1481 | + // throw new RuntimeException("Y'all need to implement sketchRenderer()"); | ||
| 1482 | + // /* | ||
| 1483 | + // // otherwise ok to fall through and create renderer below | ||
| 1484 | + // // the renderer is changing, so need to create a new object | ||
| 1485 | + // g = makeGraphics(w, h, renderer, path, true); | ||
| 1486 | + // this.width = w; | ||
| 1487 | + // this.height = h; | ||
| 1488 | + // | ||
| 1489 | + // // fire resize event to make sure the applet is the proper size | ||
| 1490 | + //// setSize(iwidth, iheight); | ||
| 1491 | + // // this is the function that will run if the user does their own | ||
| 1492 | + // // size() command inside setup, so set defaultSize to false. | ||
| 1493 | + // defaultSize = false; | ||
| 1494 | + // | ||
| 1495 | + // // throw an exception so that setup() is called again | ||
| 1496 | + // // but with a properly sized render | ||
| 1497 | + // // this is for opengl, which needs a valid, properly sized | ||
| 1498 | + // // display before calling anything inside setup(). | ||
| 1499 | + // throw new RendererChangeException(); | ||
| 1500 | + // */ | ||
| 1501 | + // } | ||
| 1481 | 1502 | } | |
| 1482 | 1503 | ||
| 1483 | 1504 | ||
@@ -1585,17 +1606,22 @@ public PGraphics createGraphics(int w, int h, | |||
| 1585 | 1606 | } | |
| 1586 | 1607 | ||
| 1587 | 1608 | ||
| 1588 | - /** | ||
| 1589 | - * Version of createGraphics() used internally. | ||
| 1590 | - */ | ||
| 1609 | + public PGraphics makePrimaryGraphics(int wide, int high) { | ||
| 1610 | + return makeGraphics(wide, high, sketchRenderer(), null, true); | ||
| 1611 | + } | ||
| 1612 | + | ||
| 1613 | + | ||
| 1614 | + /** Version of createGraphics() used internally. */ | ||
| 1591 | 1615 | protected PGraphics makeGraphics(int w, int h, | |
| 1592 | 1616 | String renderer, String path, | |
| 1593 | 1617 | boolean primary) { | |
| 1594 | - String openglError = external ? | ||
| 1595 | - "Before using OpenGL, first select " + | ||
| 1596 | - "Import Library > OpenGL from the Sketch menu." : | ||
| 1597 | - "The Java classpath and native library path is not " + // welcome to Java programming! | ||
| 1598 | - "properly set for using the OpenGL library."; | ||
| 1618 | + // String openglError = external ? | ||
| 1619 | + // // This first one should no longer be possible | ||
| 1620 | + // "Before using OpenGL, first select " + | ||
| 1621 | + // "Import Library > OpenGL from the Sketch menu." : | ||
| 1622 | + // // Welcome to Java programming! The training wheels are off. | ||
| 1623 | + // "The Java classpath and native library path is not " + | ||
| 1624 | + // "properly set for using the OpenGL library."; | ||
| 1599 | 1625 | ||
| 1600 | 1626 | if (!primary && !g.isGL()) { | |
| 1601 | 1627 | if (renderer.equals(P2D)) { | |
@@ -1625,26 +1651,30 @@ protected PGraphics makeGraphics(int w, int h, | |||
| 1625 | 1651 | String msg = ite.getTargetException().getMessage(); | |
| 1626 | 1652 | if ((msg != null) && | |
| 1627 | 1653 | (msg.indexOf("no jogl in java.library.path") != -1)) { | |
| 1628 | - throw new RuntimeException(openglError + | ||
| 1629 | - " (The native library is missing.)"); | ||
| 1654 | + // Is this true anymore, since the JARs contain the native libs? | ||
| 1655 | + throw new RuntimeException("The jogl library folder needs to be " + | ||
| 1656 | + "specified with -Djava.library.path=/path/to/jogl"); | ||
| 1657 | + | ||
| 1630 | 1658 | } else { | |
| 1631 | 1659 | ite.getTargetException().printStackTrace(); | |
| 1632 | 1660 | Throwable target = ite.getTargetException(); | |
| 1633 | - if (platform == MACOSX) target.printStackTrace(System.out); // bug | ||
| 1634 | - // neither of these help, or work | ||
| 1635 | - //target.printStackTrace(System.err); | ||
| 1636 | - //System.err.flush(); | ||
| 1637 | - //System.out.println(System.err); // and the object isn't null | ||
| 1661 | + if (platform == MACOSX) { | ||
| 1662 | + target.printStackTrace(System.out); // OS X bug (still true?) | ||
| 1663 | + } | ||
| 1638 | 1664 | throw new RuntimeException(target.getMessage()); | |
| 1639 | 1665 | } | |
| 1640 | 1666 | ||
| 1641 | 1667 | } catch (ClassNotFoundException cnfe) { | |
| 1642 | - if (cnfe.getMessage().indexOf("processing.opengl.PGraphicsOpenGL") != -1) { | ||
| 1643 | - throw new RuntimeException(openglError + | ||
| 1644 | - " (The library .jar file is missing.)"); | ||
| 1645 | - } else { | ||
| 1668 | + // if (cnfe.getMessage().indexOf("processing.opengl.PGraphicsOpenGL") != -1) { | ||
| 1669 | + // throw new RuntimeException(openglError + | ||
| 1670 | + // " (The library .jar file is missing.)"); | ||
| 1671 | + // } else { | ||
| 1672 | + if (external) { | ||
| 1646 | 1673 | throw new RuntimeException("You need to use \"Import Library\" " + | |
| 1647 | 1674 | "to add " + renderer + " to your sketch."); | |
| 1675 | + } else { | ||
| 1676 | + throw new RuntimeException("The " + renderer + | ||
| 1677 | + " renderer is not in the class path."); | ||
| 1648 | 1678 | } | |
| 1649 | 1679 | ||
| 1650 | 1680 | } catch (Exception e) { | |
@@ -1663,7 +1693,9 @@ protected PGraphics makeGraphics(int w, int h, | |||
| 1663 | 1693 | throw new RuntimeException(msg); | |
| 1664 | 1694 | } | |
| 1665 | 1695 | } else { | |
| 1666 | - if (platform == MACOSX) e.printStackTrace(System.out); | ||
| 1696 | + if (platform == MACOSX) { | ||
| 1697 | + e.printStackTrace(System.out); // OS X bug (still true?) | ||
| 1698 | + } | ||
| 1667 | 1699 | throw new RuntimeException(e.getMessage()); | |
| 1668 | 1700 | } | |
| 1669 | 1701 | } | |
@@ -1732,7 +1764,8 @@ public void handleDraw() { | |||
| 1732 | 1764 | long now = System.nanoTime(); | |
| 1733 | 1765 | ||
| 1734 | 1766 | if (frameCount == 0) { | |
| 1735 | - surface.checkDisplaySize(); | ||
| 1767 | + // 3.0a5 should be no longer needed; handled by PSurface | ||
| 1768 | + //surface.checkDisplaySize(); | ||
| 1736 | 1769 | ||
| 1737 | 1770 | // try { | |
| 1738 | 1771 | //println("Calling setup()"); | |
@@ -5466,6 +5499,7 @@ public PFont createFont(String name, float size, | |||
| 5466 | 5499 | // FILE/FOLDER SELECTION | |
| 5467 | 5500 | ||
| 5468 | 5501 | ||
| 5502 | + /* | ||
| 5469 | 5503 | private Frame selectFrame; | |
| 5470 | 5504 | ||
| 5471 | 5505 | private Frame selectFrame() { | |
@@ -5488,6 +5522,7 @@ private Frame selectFrame() { | |||
| 5488 | 5522 | } | |
| 5489 | 5523 | return selectFrame; | |
| 5490 | 5524 | } | |
| 5525 | + */ | ||
| 5491 | 5526 | ||
| 5492 | 5527 | ||
| 5493 | 5528 | /** | |
@@ -5531,7 +5566,7 @@ public void selectInput(String prompt, String callback, File file) { | |||
| 5531 | 5566 | ||
| 5532 | 5567 | public void selectInput(String prompt, String callback, | |
| 5533 | 5568 | File file, Object callbackObject) { | |
| 5534 | - selectInput(prompt, callback, file, callbackObject, selectFrame()); | ||
| 5569 | + selectInput(prompt, callback, file, callbackObject, null); //selectFrame()); | ||
| 5535 | 5570 | } | |
| 5536 | 5571 | ||
| 5537 | 5572 | ||
@@ -5559,7 +5594,7 @@ public void selectOutput(String prompt, String callback, File file) { | |||
| 5559 | 5594 | ||
| 5560 | 5595 | public void selectOutput(String prompt, String callback, | |
| 5561 | 5596 | File file, Object callbackObject) { | |
| 5562 | - selectOutput(prompt, callback, file, callbackObject, selectFrame()); | ||
| 5597 | + selectOutput(prompt, callback, file, callbackObject, null); //selectFrame()); | ||
| 5563 | 5598 | } | |
| 5564 | 5599 | ||
| 5565 | 5600 | ||
@@ -5634,7 +5669,7 @@ public void selectFolder(String prompt, String callback, File file) { | |||
| 5634 | 5669 | ||
| 5635 | 5670 | public void selectFolder(String prompt, String callback, | |
| 5636 | 5671 | File file, Object callbackObject) { | |
| 5637 | - selectFolder(prompt, callback, file, callbackObject, selectFrame()); | ||
| 5672 | + selectFolder(prompt, callback, file, callbackObject, null); //selectFrame()); | ||
| 5638 | 5673 | } | |
| 5639 | 5674 | ||
| 5640 | 5675 | ||
@@ -6081,34 +6116,6 @@ public InputStream createInputRaw(String filename) { | |||
| 6081 | 6116 | } | |
| 6082 | 6117 | } | |
| 6083 | 6118 | ||
| 6084 | - // Finally, something special for the Internet Explorer users. Turns out | ||
| 6085 | - // that we can't get files that are part of the same folder using the | ||
| 6086 | - // methods above when using IE, so we have to resort to the old skool | ||
| 6087 | - // getDocumentBase() from teh applet dayz. 1996, my brotha. | ||
| 6088 | - try { | ||
| 6089 | - URL base = getDocumentBase(); | ||
| 6090 | - if (base != null) { | ||
| 6091 | - URL url = new URL(base, filename); | ||
| 6092 | - URLConnection conn = url.openConnection(); | ||
| 6093 | - return conn.getInputStream(); | ||
| 6094 | - // if (conn instanceof HttpURLConnection) { | ||
| 6095 | - // HttpURLConnection httpConnection = (HttpURLConnection) conn; | ||
| 6096 | - // // test for 401 result (HTTP only) | ||
| 6097 | - // int responseCode = httpConnection.getResponseCode(); | ||
| 6098 | - // } | ||
| 6099 | - } | ||
| 6100 | - } catch (Exception e) { } // IO or NPE or... | ||
| 6101 | - | ||
| 6102 | - // Now try it with a 'data' subfolder. getting kinda desperate for data... | ||
| 6103 | - try { | ||
| 6104 | - URL base = getDocumentBase(); | ||
| 6105 | - if (base != null) { | ||
| 6106 | - URL url = new URL(base, "data/" + filename); | ||
| 6107 | - URLConnection conn = url.openConnection(); | ||
| 6108 | - return conn.getInputStream(); | ||
| 6109 | - } | ||
| 6110 | - } catch (Exception e) { } | ||
| 6111 | - | ||
| 6112 | 6119 | try { | |
| 6113 | 6120 | // attempt to load from a local file, used when running as | |
| 6114 | 6121 | // an application, or as a signed applet | |
@@ -9266,11 +9273,15 @@ static public void runSketch(final String args[], final PApplet constructedApple | |||
| 9266 | 9273 | } | |
| 9267 | 9274 | } | |
| 9268 | 9275 | ||
| 9269 | - String renderer = applet.sketchRenderer(); | ||
| 9270 | - Class<?> rendererClass = | ||
| 9271 | - Thread.currentThread().getContextClassLoader().loadClass(renderer); | ||
| 9272 | - Method surfaceMethod = rendererClass.getMethod("createSurface"); | ||
| 9273 | - PSurface surface = (PSurface) surfaceMethod.invoke(null, new Object[] { }); | ||
| 9276 | + try { | ||
| 9277 | + String renderer = applet.sketchRenderer(); | ||
| 9278 | + Class<?> rendererClass = | ||
| 9279 | + Thread.currentThread().getContextClassLoader().loadClass(renderer); | ||
| 9280 | + Method surfaceMethod = rendererClass.getMethod("createSurface"); | ||
| 9281 | + PSurface surface = (PSurface) surfaceMethod.invoke(null, new Object[] { }); | ||
| 9282 | + } catch (Exception e) { | ||
| 9283 | + throw new RuntimeException(e); | ||
| 9284 | + } | ||
| 9274 | 9285 | ||
| 9275 | 9286 | // A handful of things that need to be set before init/start. | |
| 9276 | 9287 | applet.sketchPath = folder; | |
@@ -9319,7 +9330,7 @@ static public void runSketch(final String args[], final PApplet constructedApple | |||
| 9319 | 9330 | } | |
| 9320 | 9331 | surface.placePresent(stopColor); | |
| 9321 | 9332 | } else { | |
| 9322 | - surface.placeWindow(); | ||
| 9333 | + surface.placeWindow(external, location, editorLocation); | ||
| 9323 | 9334 | } | |
| 9324 | 9335 | // not always running externally when in present mode | |
| 9325 | 9336 | if (external) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments