21 July 2009

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);




That's it.
Pierre

1 comment:

Ivan said...

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!