File f = new File(mysvgfile); SVGUniverse svgUniverse = new SVGUniverse(); SVGDiagram diagram = svgUniverse.getDiagram(svgUniverse.loadSVG(f.toURL()));
public static void clearResourceMemoryCache() { SVGCache.getSVGUniverse().clear(); }
public URI loadSVG(InputStream is, String name, boolean forceLoad) throws IOException { URI uri = getStreamBuiltURI(name); if (uri == null) return null; if (loadedDocs.containsKey(uri) && !forceLoad) return uri; return loadSVG(uri, new InputSource(createDocumentInputStream(is))); }
public static BufferedImage getResourceBitmap(InputStream inputStream, String name, float scaleFactor, float defaultSize, int width, int height, int percent) throws IOException { try { URI uri = SVGCache.getSVGUniverse().loadSVG(inputStream, name); SVGDiagram diagram = SVGCache.getSVGUniverse().getDiagram(uri); double scale = scaleFactor / Math.sqrt((diagram.getHeight() * diagram.getWidth()) / defaultSize); float[] bmpSize = GraphicUtils.imageSize(diagram.getWidth(), diagram.getHeight(), (float) scale, width, height, percent); SVGIcon icon = new SVGIcon(); icon.setAntiAlias(true); icon.setAutosize(SVGIcon.AUTOSIZE_STRETCH); icon.setPreferredSize(new Dimension((int) bmpSize[0], (int) bmpSize[1])); icon.setSvgURI(uri); BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); icon.paintIcon(null, bufferedImage.createGraphics(), 0, 0); return bufferedImage; } catch (Exception e) { throw new IOException(e); } }
universe = new SVGUniverse(); universe.setVerbose(verbose); SVGDiagram diagram = null; URI uri = universe.loadSVG(url); diagram = universe.getDiagram(uri); URI uri = universe.loadSVG(is, "defaultName"); diagram = universe.getDiagram(uri);
public SVGDiagram getDiagram(URI xmlBase) { return getDiagram(xmlBase, true); }
URI uri = SVGCache.getSVGUniverse().loadSVG(reader, frameSeed + "_" + strokeSize + "_" + strokeColor + "_" + fillColor + "_" + this.hashCode() + "_svg_frame"+step); svg.setSvgURI(uri);
/** * Loads an SVG file and all the files it references from the URL provided. * If a referenced file already exists in the SVG universe, it is not * reloaded. * @param docRoot - URL to the location where this SVG file can be found. * @param forceLoad - if true, ignore cached diagram and reload * @return - The URI that refers to the loaded document */ public URI loadSVG(URL docRoot, boolean forceLoad) { try { URI uri = new URI(docRoot.toString()); if (loadedDocs.containsKey(uri) && !forceLoad) return uri; InputStream is = docRoot.openStream(); return loadSVG(uri, new InputSource(createDocumentInputStream(is))); } catch (URISyntaxException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } return null; }
public SVGElement getElement(URL path) { try { URI uri = new URI(path.toString()); return getElement(uri, true); } catch (Exception e) { e.printStackTrace(); } return null; }
else if (!diagram.getUniverse().isImageDataInlineOnly()) diagram.getUniverse().registerImage(imageSrc); BufferedImage img = diagram.getUniverse().getImage(imageSrc); if (img == null)
for (int i = 0; i < families.length; ++i) font = diagram.getUniverse().getFont(families[i]); if (font != null)
/** * Copies the presentation attribute into the passed one. * @return - True if attribute was read successfully */ public boolean getPres(StyleAttribute attrib) throws SVGException { String presName = attrib.getName(); //Make sure we have a coresponding presentation attribute StyleAttribute presAttr = (StyleAttribute)presAttribs.get(presName); //Copy presentation value directly attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue()); //Evalutate coresponding track, if one exists TrackBase track = trackManager.getTrack(presName, AnimationElement.AT_XML); if (track != null) { track.getValue(attrib, diagram.getUniverse().getCurTime()); return true; } //Return if we found presentation attribute if (presAttr != null) return true; return false; }
diagram.getUniverse().registerImage(imageSrc); BufferedImage img = diagram.getUniverse().getImage(imageSrc); if (img == null)
public IconPanel(String name, int scalex, int scaley) { icon = new SVGIcon(); icon.setSvgURI(new SVGUniverse().loadSVG(getClass().getResource(name))); icon.setPreferredSize(new Dimension(scalex, scaley)); icon.setScaleToFit(true);
BufferedImage img = diagram.getUniverse().getImage(imageSrc); if (img == null) return;
universe = new SVGUniverse(); universe.setVerbose(verbose); SVGDiagram diagram = null; URI uri = universe.loadSVG(url); diagram = universe.getDiagram(uri); URI uri = universe.loadSVG(is, "defaultName"); diagram = universe.getDiagram(uri);
public SVGDiagram getDiagram(URI xmlBase) { return getDiagram(xmlBase, true); }
@Override public SVGDiagram readObject(InputStream inputStream) throws IOException { SVGUniverse universe = SVGCache.getSVGUniverse(); URI location = universe.loadSVG(inputStream, NAME_PREFIX + (index++)); return universe.getDiagram(location, true); }
public URI loadSVG(InputStream is, String name) throws IOException { return loadSVG(is, name, false); }
return loadSVG(uri, new InputSource(createDocumentInputStream(is))); } catch (URISyntaxException ex)