| 603 | } |
| 604 | |
| 605 | private static Image imageFromSVG(URL url, int width, int height) |
| 606 | throws TranscoderException { |
| 607 | Transcoder t = new PNGTranscoder(); |
| 608 | t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width)); |
| 609 | t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height)); |
| 610 | |
| 611 | TranscoderInput input = new TranscoderInput(url.toString()); |
| 612 | ByteArrayOutputStream ostream = new ByteArrayOutputStream(); |
| 613 | TranscoderOutput output = new TranscoderOutput(ostream); |
| 614 | t.transcode(input, output); |
| 615 | |
| 616 | byte[] imgData = ostream.toByteArray(); |
| 617 | return Toolkit.getDefaultToolkit().createImage(imgData); |
| 618 | } |
| 619 | |
| 620 | static public Graphics2D setupGraphics2D(Graphics graphics) { |
| 621 | Graphics2D g = (Graphics2D) graphics; |