xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: When to register EventListeners?
Date Sat, 11 Oct 2003 11:14:06 GMT
>> Reinhard Brandst├Ądter wrote:
>>> I think calling setSVGDocument() after I've created the document 
>>> "offline" isn't the right way but how can I use the updateManager to 
>>> replace the whole document in the Canvas with the new one?

> Thomas DeWeese wrote:
>>    The whole idea of the updateManager is that it tracks the changes
>> to the document as you make them.  One consequence of this
>> is that it can be faster to make all your changes up front rather
>> than have them tracked 'live'.

Reinhard Brandst├Ądter wrote:
> So this means if I use the invokeLater() from the UpdateManager it's 
> slower than directly modifying the document. 

    No, it just means that you may have two threads modifying the same
document at the same time.  Once the document is associated with the Canvas
(and hence an UpdateManager) all modifications are tracked - it doesn't matter
what thread the changes are made in it tracks them.  However if the modifications
aren't made in the UpdateManager thread you will have multi-threading issues.

 > As I mentioned before there
 > is no need to immediately see the changes in the canvas as they are made.
 > But somehow this interferes with Java Scripting and Event handling.

   The update of the display is only ever done _after_ a Runnable completes
so if you moved the "reconstruction" of the document into a runnable no repaints
would happen until the runnable completed.  This would also make your
document "play nicely" with JavaScript and Event handling.  As it is
your JavaScript and Events may be running on the same Document as you
are constructing it!

   I would take one of three routes here:

1) Don't load the document with setURI (do you even need to load something
    from a URI?[*]), but load the document yourself, modify it and then set it
    with setSVGDocument.
2) Move all your code into a Runnable and run it in the UpdateManager Thread.
3) Load the document with setURI, then deep clone the Document, then modify
    the clone (which doesn't have to be in the UpdateManager Thread and the
    changes won't be tracked by the Canvas).  Then you can set the clone document
    on the canvas.

[*] What is the document you are loading from the URI?  Is there any reason
     that the document from the URI needs to be related to the document you
     create on the fly?

To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org

View raw message