Hi,
I am having a problem using Batik and I hope you can help me
solve it.
I have two svg files stored in a certain directory in my
hard disk; one of them is a background image, while the other
contains all the drawings that two different users dynamically
add to the background.
In my application I use a JFrame containing a JSVGCanvas,
a FileChooser to load the svg background and two buttons,
 each one of which should load onto the background the drawings
of the corresponding user.
In order to extract the drawings of a single user, I parse the drawings file
and extract only the nodes of interest by means of a node iterator and
 a custom filter. Each node extracted is appended to the DOM tree of
the background.
This actually works!
I mean, the svg doc I obtain is exactly how I expected, but it is not
rendered correctly: the canvas displays only the background.

Any suggestion is really appreciated!
Thank you,
maria teresa.

PS:
Here is an excerpt from my code:
                        //f is the background svg file
                        //svgCan the JSVGCanvas
                        
                        Document svgDoc = parser.parse(f.toURL().toString());
                        svgCan.setDocument(svgDoc); // cosi'becco Xray "pulito"
                        
                        svgCan.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
                        
                        //creating the node iterator:
                        DocumentTraversal trav = (DocumentTraversal)doc;
                        NodeIterator ni = trav.createNodeIterator(
                        doc,
                        NodeFilter.SHOW_ELEMENT,
                        new FilterId(),//my custom filter
                        true);  
                        
                        Element docRoot = svgDoc.getDocumentElement();
                //iterate over the elements
                        Node node;
                        while((node = ni.nextNode()) != null){
                                        //adding all the filtered nodes to the 
background
                            System.out.println(node.getNodeValue());
                                Node importedNode = svgDoc.importNode(node, true);
                docRoot.appendChild(importedNode);
                }

svgCan.setDocument(svgDoc); //why this does not work?



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to