1 51 package org.apache.fop.image; 52 53 import java.net.URL ; 55 56 import org.w3c.dom.svg.SVGDocument; 58 59 import org.apache.fop.messaging.*; 61 import org.apache.fop.image.analyser.ImageReader; 62 63 import org.apache.batik.dom.svg.SAXSVGDocumentFactory; 65 66 70 public class SVGImage extends AbstractFopImage { 71 72 private SVGDocument doc; 73 74 public SVGImage(URL href) throws FopImageException { 75 super(href); 76 } 77 78 public SVGImage(URL href, 79 ImageReader imgReader) throws FopImageException { 80 super(href, imgReader); 81 } 82 83 88 public static String getParserName() { 89 return org.apache.fop.apps.Driver.getParserClassName(); 90 } 91 92 protected void loadImage() throws FopImageException { 93 try { 94 SAXSVGDocumentFactory factory = 95 new SAXSVGDocumentFactory(SVGImage.getParserName()); 96 doc = factory.createSVGDocument(this.m_href.toExternalForm()); 97 } catch (Exception e) { 98 MessageHandler.errorln("Could not load external SVG: " 99 + e.getMessage()); 100 } 101 } 102 103 public SVGDocument getSVGDocument() throws FopImageException { 104 if (doc == null) 105 this.loadImage(); 106 return doc; 107 } 108 109 } 110 | Popular Tags |