/** * Load SVG from file. */ public static SvgImage loadSvgImage( InputStream in ) throws Exception { Document document = getSvgFactory().createDocument( null, in ); return new SvgImage( document ); }
protected RenderableSVG toRenderableSVG(String svgfile, URL svgUrl) throws SAXException, IOException { RenderableSVG svg; String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); String svgUri = svgfile; // Remove parameters from file URLs, as it is not supported by Windows if ("file".equals(svgUrl.getProtocol()) && svgUrl.getQuery() != null) { int idx = svgfile.indexOf('?'); if (idx > -1) { svgUri = svgfile.substring(0, idx); } } Document doc = f.createDocument(svgUri); Map<String, String> parameters = getParametersFromUrl(svgfile); if (!parameters.isEmpty() || hasParameters(doc.getDocumentElement())) { replaceParameters(doc.getDocumentElement(), parameters); } svg = new RenderableSVG(doc); return svg; }
if (svgfile.startsWith("file:/") && queryIdx > 0) { String localPath = svgfile.substring(0, queryIdx); doc = f.createDocument(localPath); } else { doc = f.createDocument(svgfile);
/** * Creates a SVG Document instance. * @param uri The document URI. * @param inp The document input stream. * @exception IOException if an error occured while reading the document. */ public SVGDocument createSVGDocument(String uri, InputStream inp) throws IOException { return (SVGDocument)createDocument(uri, inp); }
/** * Creates a SVG Document instance. * @param uri The document URI. * @param r The document reader. * @exception IOException if an error occured while reading the document. */ public SVGDocument createSVGDocument(String uri, Reader r) throws IOException { return (SVGDocument)createDocument(uri, r); }
/** * Creates a SVG Document instance. * @param uri The document URI. * @param inp The document input stream. * @exception IOException if an error occured while reading the document. */ public SVGDocument createSVGDocument(String uri, InputStream inp) throws IOException { return (SVGDocument)createDocument(uri, inp); }
/** * Creates a SVG Document instance. * @param uri The document URI. * @param inp The document input stream. * @exception IOException if an error occured while reading the document. */ public SVGDocument createSVGDocument(String uri, InputStream inp) throws IOException { return (SVGDocument)createDocument(uri, inp); }
/** * Creates a SVG Document instance. * @param uri The document URI. * @param r The document reader. * @exception IOException if an error occured while reading the document. */ public SVGDocument createSVGDocument(String uri, Reader r) throws IOException { return (SVGDocument)createDocument(uri, r); }
/** * Creates a SVG Document instance. * @param uri The document URI. * @param r The document reader. * @exception IOException if an error occured while reading the document. */ public SVGDocument createSVGDocument(String uri, Reader r) throws IOException { return (SVGDocument)createDocument(uri, r); }
public SVGDocument createSVGDocument(String uri) throws IOException { return (SVGDocument)createDocument(uri); }
public SVGDocument createSVGDocument(String uri) throws IOException { return (SVGDocument)createDocument(uri); }
/** * Creates a Document instance. * @param ns The namespace URI of the root element of the document. * @param root The name of the root element of the document. * @param uri The document URI. * @exception IOException if an error occured while reading the document. */ public Document createDocument(String ns, String root, String uri) throws IOException { if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) || !"svg".equals(root)) { throw new RuntimeException("Bad root element"); } return createDocument(uri); }
/** * Creates a Document instance. * @param ns The namespace URI of the root element of the document. * @param root The name of the root element of the document. * @param uri The document URI. * @exception IOException if an error occured while reading the document. */ public Document createDocument(String ns, String root, String uri) throws IOException { if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns) || !"svg".equals(root)) { throw new RuntimeException("Bad root element"); } return createDocument(uri); }
public static SVGDocument newDocumentFromInputStream(InputStream in) { SVGDocument ret = null; try { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); ret = (SVGDocument) factory.createDocument("",in); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; }
private SVGDocument getSVGDocument(QualifiedSVGResource svg) throws IOException { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); return (SVGDocument) f.createDocument(svg.toURI().toURL().toString()); }
private SVGDocument getSVGDocument(QualifiedSVGResource svg) throws IOException { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); return (SVGDocument) f.createDocument(svg.toURI().toURL().toString()); }
private Document createDocument() throws IOException { return new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName()).createDocument(null, this.input); }
public SVGImageProcessor(InputStream svg, boolean mapById) { try { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); factory.setValidating(false); Document svgDocument = factory.createDocument("http://jbpm.org", svg); svgProcessor = new SVGProcessorFactory().create(svgDocument, mapById); svgProcessor.processNodes(svgDocument.getChildNodes()); } catch (IOException e) { throw new RuntimeException("Could not parse svg", e); } }
private Document readSVG(String svgContent) throws IOException { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); factory.setValidating(false); Document svgDocument = factory.createDocument("http://jbpm.org", new StringReader(svgContent)); return svgDocument; } }
private Document readSVG(String svgContent) throws IOException { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); factory.setValidating(false); Document svgDocument = factory.createDocument("http://jbpm.org", new StringReader(svgContent)); return svgDocument; } }