Hi Maria,

maria teresa wrote:

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 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.

I would suspect that the nodes you are getting from the 'overlay' drawing are not in the SVG namespace. It is also possible that the coordinate systems do not line up.

   You can find out what namespace the elements from the
'user' document are in with 'getNamespaceURI()'.

Also a few other points,

        1) Calling setDocument twice in close succession
           has only worked relyably very recently.
        2) calling setDocumentState should be done before
           setting the document to have effect.
        3) Modifications of the 'currently displayed' document
           should only be done in the updateManager's runnable
           queue.

    So you might try just commenting out the first 'setDocument' call,
this way you can avoid all the above issues.

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]





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



Reply via email to