I\'m toying with Java and SVG Salamander but can\'t quite get how to render a simple SVG file into a JPanel.
Could someone give me a brief example? Trie
First, you need to somehow create the diagram (com.kitfox.svg.SVGDiagram).
File f = new File(mysvgfile);
SVGUniverse svgUniverse = new SVGUniverse();
SVGDiagram diagram = svgUniverse.getDiagram(svgUniverse.loadSVG(f.toURL()));
Now, when you want to render your file - typically from the panel's paintComponent() method - you only need to do (with g being the Graphics2D instance):
diagram.render(g);
And (as usual?), if you want to draw it in some modified way:
AffineTransform oldTransform = g.getTransform();
g.scale(...);
g.translate(...);
...
diagram.render(g);
g.setTransform(oldTransform);