You can Load your SVG into a JSVGComponent, and once the GVTTree is build, you can get a TreeWalker to paint your graphics2D objects in whatever swing component you like.
JSVGComponent extends a JComponent, so it should work for you. I have a custom SVG to DXF converter that works in the following manner:
I load my SVG into a JSVGComponent, and i register a listener to wait for a gvtTreeBuildCompleted event. Once this event is called, i create a GVTTreeWalker, that holds all the SVG objects converted into Graphics2D representations.
I then walk the GVTTree to parse all the Graphics 2D objects into DXF.
Another idea:
You may want to implement the actions done by the "org.apache.batik.gvt.GraphicsNode" in a custom JComponent of yours to paint() your graphics2D content into your exporter. You can then simply "paint()" the gvtRoot.
I'm not entirely sure what you mean here. I've made a class that extends JComponent:
class Foo extends JComponent implements GVTTreeBuilderListener { private Graphics2D g = null; JSVGCanvas svgCanvas = new JSVGCanvas(); GVTTreeWalker gvtTreeWalker = null; ... ... public void paint(Graphics g) { this.g = (Graphics2D) g; } public void gvtBuildCompleted(GVTTreeBuilderEvent e) { gvtTreeWalker = new GVTTreeWalker(svgCanvas.getGraphicsNode()); gvtTreeWalker.getRoot().paint(this.g); }
But the call to paint in gvtBuildCompleted does not produce any visible results in the JFrame that has this class added.
The idea sound good and if you could provide me with some more details on how to do this I'd really appreciate it.
Glenn Thomas Hvidsten
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]