Hi Mark,

Mark McKay wrote:

I'm new to Batik and SVG, but have worked a lot with DOM and Java2D. I'm confused about the unusual process needed to update the document to cause the JSVGCanvas to display a different image.

This is the same basic approach taken by AWT and Swing for modifying GUI components (see SwingUtilities.invokeLater).

In particular, in the FAQ it says to use:

UpdateManager um = JSVGCanvas.getUpdateManager();
um.getUpdateRunnableQueue().invokeLater(Runnable);

What is 'Runnable'? A pointer to some other currently running thread? What on that thread object is called?

Runnable is the interface 'java.lang.Runnable'. This interface has one method 'run'. You put your code to modify the DOM in your implementation of this method. The run method will then be called at a point in time that you have exclusive access to the DOM, you will continue to have exclusive access to the DOM until the run method returns.

What I need to do is read in an SVG file, and then change the text of several text nodes over time in response to user commands. The sample code listed in Java Scripting doesn't help much, since it seems to concern adding script like calls when a document loads.

Once you are in the run method you can use what ever DOM calls you want to modify the document. At this point most modifications are automatically tracked by Batik (the major exception is indirect references - changes to a gradient will not update all the graphics elements using that gradient for example).

If you could provide sample code or point to a small program that does something similar, it would be a big help. Infact, if you could point me to an archive of simple Batik programs with their source SVG files, I would like to spend some time reading through them.

Well there is the samples directory. There is not an archive of Batik programs that use Java to handle document modification. The samples directory contains a number of examples that use JavaScript to modify the document (samples/tests/spec/scripting). Other than needing to wrap the DOM calls in the Runnable the DOM is normal.



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



Reply via email to