String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); URL url = new URL(getCodeBase(), "fileName.svg"); Document doc = f.createDocument(url.toString()); Element svg = doc.getDocumentElement(); if (svg.hasAttribute("viewBox")) { // notify the user somehow }
String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); SVGDocument document = factory.createSVGDocument("", new ByteArrayInputStream(svg.getBytes("UTF-8"))); canvas.setSVGDocument(document);
/** * mini cache to stop re-loading SVG files. * Dont know how effective this is, but... */ private Document getDocument(URL url) throws Exception { if (cache.contains(url)) return (Document) cache.get(url); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); Document doc = f.createDocument(url.toString()); cache.put(url,doc); return doc; }
public Icon getIcon(Feature feature, Expression url, String format, int size) throws Exception { // check we do support the declared format if (format == null || !formats.contains(format.toLowerCase())) return null; // grab the url URL svgfile = url.evaluate(feature, URL.class); if (svgfile == null) throw new IllegalArgumentException( "The specified expression could not be turned into an URL"); // turn the svg into a document and cache results RenderableSVG svg = glyphCache.get(svgfile); if(svg == null) { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); Document doc = f.createDocument(svgfile.toString()); svg = new RenderableSVG(doc); glyphCache.put(svgfile, svg); } return new SVGIcon(svg, size); }
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); doc = f.createSVGDocument(null, in);
/** * Reads an SVG Image file into an com.itextpdf.text.Image instance to embed it into a PDF * @param svgPath SVG filepath * @param writer PdfWriter instance * @return Instance of com.itextpdf.text.Image holding the SVG file * @throws IOException * @throws BadElementException */ private static Image getSVGImage(String svgPath, PdfWriter writer) throws IOException, BadElementException { SVGDocument svgDoc = new SAXSVGDocumentFactory(null).createSVGDocument(null, new FileReader(svgPath)); // Try to read embedded height and width float svgWidth = Float.parseFloat(svgDoc.getDocumentElement().getAttribute("width").replaceAll("[^0-9.,]","")); float svgHeight = Float.parseFloat(svgDoc.getDocumentElement().getAttribute("height").replaceAll("[^0-9.,]","")); PdfTemplate svgTempl = PdfTemplate.createTemplate(writer, svgWidth, svgHeight); Graphics2D g2d = new PdfGraphics2D(svgTempl, svgTempl.getWidth(), svgTempl.getHeight()); GraphicsNode chartGfx = (new GVTBuilder()).build(new BridgeContext(new UserAgentAdapter()), svgDoc); chartGfx.paint(g2d); g2d.dispose(); return new ImgTemplate(svgTempl); }
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); Document doc = f.createDocument("http://example.com/stuff", MapMaker.class.getClassLoader().getResourceAsStream(MAP_ROUND));
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); doc = f.createSVGDocument("http://www.w3.org/2000/svg", reader);
SAXSVGDocumentFactory documentFactory = new SAXSVGDocumentFactory(cn); documentFactory.setValidating(false); SVGDocument doc;
svgDocumentFactory = new SAXSVGDocumentFactory(parser); doc = svgDocumentFactory.createDocument(svgEditFile.toURI().toString()); File file = new File("C:\\Users\\neda.danilovic\\Desktop\\batik 1.7\\miscPOC-master\\batik-poc1\\src\\main\\java\\glasspane\\Blank_map_of_Europe.svg"); String parser = XMLResourceDescriptor.getXMLParserClassName(); svgDocumentFactory = new SAXSVGDocumentFactory(parser); canvas.setDocument(svgDocumentFactory.createDocument(file.toURI().toString())); panel.add(canvas); svgDocumentFactory = new SAXSVGDocumentFactory(parser); doc = svgDocumentFactory.createDocument(svgEditFile.toURI().toString());
try { String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); svgDocument = (SVGDocument)factory.createDocument(clpFile.toURI().toString(), new InputStreamReader(in, "ISO-8859-1")); rootSvgNode = getRootNode(svgDocument, bridgeContext);
SAXSVGDocumentFactory fac = new SAXSVGDocumentFactory( "org.apache.xerces.parsers.SAXParser" ); SVGDocument doc = fac.createSVGDocument( url, in ); GVTBuilder builder = new GVTBuilder();
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory( parser ); return factory.createDocument( uri );
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser); UserAgent userAgent = new UserAgentAdapter(); DocumentLoader loader = new DocumentLoader(userAgent);
new SAXSVGDocumentFactory(userAgent.getXMLParserClassName(), true); documentFactory.setValidating(userAgent.isXMLParserValidating());