A simple java-based SVG renderer.
A short post. I've just implemented a simple and small SVG renderer. It works fine with simple Documents.
DocumentBuilderFactory domFactory= DocumentBuilderFactory.newInstance();
domFactory.setCoalescing(true);
domFactory.setExpandEntityReferences(true);
domFactory.setIgnoringComments(true);
domFactory.setNamespaceAware(true);
domFactory.setValidating(false);
domFactory.setNamespaceAware(true);
DocumentBuilder domBuilder= domFactory.newDocumentBuilder();
Document dom=domBuilder.parse("http://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg");
SVGIcon icon= new SVGIcon(dom,256,256);
JOptionPane.showMessageDialog(null, new JLabel(icon),"SVG Icon",JOptionPane.PLAIN_MESSAGE);
domFactory.setCoalescing(true);
domFactory.setExpandEntityReferences(true);
domFactory.setIgnoringComments(true);
domFactory.setNamespaceAware(true);
domFactory.setValidating(false);
domFactory.setNamespaceAware(true);
DocumentBuilder domBuilder= domFactory.newDocumentBuilder();
Document dom=domBuilder.parse("http://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg");
SVGIcon icon= new SVGIcon(dom,256,256);
JOptionPane.showMessageDialog(null, new JLabel(icon),"SVG Icon",JOptionPane.PLAIN_MESSAGE);
Source code is available at
http://code.google.com/p/lindenb/source/browse/trunk/src/java/org/lindenb/svg/SVGRenderer.java
http://code.google.com/p/lindenb/source/browse/trunk/src/java/org/lindenb/svg/SVGRenderer.java
That's it.
Pierre
1 comment:
A - thanks was exactly looking for this (this meaning a simple class example to create a renderer for lwjgl).
While I'm not a phd, I studied genetics in college and I'm also a java geek now.
Cheers!
Post a Comment