Render an SVG, passed in as a String, into an AWT Image at the specified width and height. Used for interface buttons.
(String xmlStr, int wide, int high)
| 818 | * the specified width and height. Used for interface buttons. |
| 819 | */ |
| 820 | static private Image svgToImage(String xmlStr, int wide, int high) { |
| 821 | PGraphicsJava2D pg = new PGraphicsJava2D(); |
| 822 | pg.setPrimary(false); |
| 823 | pg.setSize(wide, high); |
| 824 | pg.smooth(); |
| 825 | |
| 826 | pg.beginDraw(); |
| 827 | |
| 828 | try { |
| 829 | XML xml = XML.parse(xmlStr); |
| 830 | PShape shape = new PShapeJava2D(xml); |
| 831 | pg.shape(shape, 0, 0, wide, high); |
| 832 | |
| 833 | } catch (Exception e) { |
| 834 | e.printStackTrace(); |
| 835 | } |
| 836 | |
| 837 | pg.endDraw(); |
| 838 | return pg.image; |
| 839 | } |
| 840 | |
| 841 | |
| 842 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
no test coverage detected