| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ | |||
| 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(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,8 +27,6 @@ | |||
| 27 | 27 | import java.awt.Cursor; | |
| 28 | 28 | import java.awt.event.KeyEvent; | |
| 29 | 29 | ||
| 30 | - import processing.data.StringList; | ||
| 31 | - | ||
| 32 | 30 | ||
| 33 | 31 | /** | |
| 34 | 32 | * Numbers shared throughout processing.core. | |
@@ -48,6 +46,7 @@ public interface PConstants { | |||
| 48 | 46 | ||
| 49 | 47 | // renderers known to processing.core | |
| 50 | 48 | ||
| 49 | + /* | ||
| 51 | 50 | // List of renderers used inside PdePreprocessor | |
| 52 | 51 | static final StringList rendererList = new StringList(new String[] { | |
| 53 | 52 | "JAVA2D", "JAVA2D_2X", | |
@@ -56,6 +55,7 @@ public interface PConstants { | |||
| 56 | 55 | "LWJGL.P2D", "LWJGL.P3D", // hmm | |
| 57 | 56 | "PDF" // no DXF because that's only for beginRaw() | |
| 58 | 57 | }); | |
| 58 | + */ | ||
| 59 | 59 | ||
| 60 | 60 | static final String JAVA2D = "processing.core.PGraphicsJava2D"; | |
| 61 | 61 | static final String JAVA2D_2X = "processing.core.PGraphicsJava2D2X"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ public PSurfaceNone() { } | |||
| 46 | 46 | ||
| 47 | 47 | @Override | |
| 48 | 48 | public void initOffscreen(PApplet sketch) { | |
| 49 | - // TODO Auto-generated method stub | ||
| 49 | + this.sketch = sketch; | ||
| 50 | 50 | } | |
| 51 | 51 | ||
| 52 | 52 | ||
@@ -57,8 +57,9 @@ public void initOffscreen(PApplet sketch) { | |||
| 57 | 57 | ||
| 58 | 58 | @Override | |
| 59 | 59 | public void initFrame(PApplet sketch, int backgroundColor, | |
| 60 | - int deviceIndex, boolean fullScreen, | ||
| 61 | - boolean spanDisplays) { | ||
| 60 | + int deviceIndex, boolean fullScreen, | ||
| 61 | + boolean spanDisplays) { | ||
| 62 | + this.sketch = sketch; | ||
| 62 | 63 | } | |
| 63 | 64 | ||
| 64 | 65 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,13 +38,17 @@ _ implement frameRate() | |||
| 38 | 38 | _ implement external messages (moving the window) | |
| 39 | 39 | ||
| 40 | 40 | opengl | |
| 41 | + X deal with some performance issues | ||
| 42 | + X https://github.com/processing/processing/issues/3210 | ||
| 43 | + X Can't run sketches with offscreen PGraphics | ||
| 44 | + X https://github.com/processing/processing/issues/3259 | ||
| 45 | + _ Merge glw code into the OpenGL library | ||
| 46 | + _ https://github.com/processing/processing/issues/3284 | ||
| 41 | 47 | _ why is createShape() implemented 4x (for P2D, P3D, and 2x versions)? | |
| 42 | 48 | _ shouldn't be static, run it from the renderer, that's point of createXxx() | |
| 43 | 49 | _ when did setPath() sneak into PShape? API is nothing like anything else | |
| 44 | 50 | _ public createShape() method that takes another shape as param? | |
| 45 | 51 | _ should just be the constructor doing this, or copy() | |
| 46 | - _ drawing 100k lines is slow (example from Reas) | ||
| 47 | - _ figure out what the bottleneck is here | ||
| 48 | 52 | ||
| 49 | 53 | ||
| 50 | 54 | high priority | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,12 +118,14 @@ public void beginDraw() { | |||
| 118 | 118 | ||
| 119 | 119 | if (document == null) { | |
| 120 | 120 | document = new Document(new Rectangle(width, height)); | |
| 121 | + boolean missingPath = false; | ||
| 121 | 122 | try { | |
| 122 | 123 | if (file != null) { | |
| 123 | 124 | //BufferedOutputStream output = new BufferedOutputStream(stream, 16384); | |
| 124 | 125 | output = new BufferedOutputStream(new FileOutputStream(file), 16384); | |
| 125 | 126 | ||
| 126 | 127 | } else if (output == null) { | |
| 128 | + missingPath = true; | ||
| 127 | 129 | throw new RuntimeException("PGraphicsPDF requires a path " + | |
| 128 | 130 | "for the location of the output file."); | |
| 129 | 131 | } | |
@@ -132,25 +134,26 @@ public void beginDraw() { | |||
| 132 | 134 | content = writer.getDirectContent(); | |
| 133 | 135 | // template = content.createTemplate(width, height); | |
| 134 | 136 | ||
| 135 | - } catch (Exception e) { | ||
| 136 | - e.printStackTrace(); | ||
| 137 | - throw new RuntimeException("Problem saving the PDF file."); | ||
| 137 | + } catch (RuntimeException re) { | ||
| 138 | + if (missingPath) { | ||
| 139 | + throw re; // don't re-package our own error | ||
| 140 | + } else { | ||
| 141 | + throw new RuntimeException("Problem saving the PDF file.", re); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + } catch (FileNotFoundException fnfe) { | ||
| 145 | + throw new RuntimeException("Can't save the PDF file to " + path, fnfe); | ||
| 146 | + | ||
| 147 | + } catch (DocumentException de) { | ||
| 148 | + throw new RuntimeException("Error inside the PDF library.", de); | ||
| 138 | 149 | } | |
| 139 | 150 | ||
| 140 | - // System.out.println("beginDraw fonts " + (System.currentTimeMillis() - t)); | ||
| 141 | - // g2 = content.createGraphics(width, height, getMapper()); | ||
| 142 | - // if (textMode == SHAPE) { | ||
| 143 | 151 | g2 = content.createGraphicsShapes(width, height); | |
| 144 | - // } else if (textMode == MODEL) { | ||
| 145 | - // g2 = content.createGraphics(width, height, getMapper()); | ||
| 146 | - // } | ||
| 147 | - // g2 = createGraphics(); | ||
| 148 | - // g2 = template.createGraphics(width, height, mapper); | ||
| 149 | 152 | } | |
| 150 | - // System.out.println("beginDraw " + (System.currentTimeMillis() - t0)); | ||
| 151 | 153 | ||
| 152 | 154 | // super in Java2D now creates an image buffer, don't do that | |
| 153 | - // super.beginDraw(); | ||
| 155 | + //super.beginDraw(); | ||
| 156 | + | ||
| 154 | 157 | checkSettings(); | |
| 155 | 158 | resetMatrix(); // reset model matrix | |
| 156 | 159 | vertexCount = 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments