xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harm Cuppens" <harm.cupp...@iosint.be>
Subject RE: InvokeAndWait problem
Date Fri, 14 Mar 2003 08:22:24 GMT
Ok,

I've found out I tried using the invokeLater, but i placed it on my redo
button, while I was in the process of testing the undo button.
Go figure...

InvokeLater does the trick, and it works fine now.

Thanks everyone for reconfirming that I need to call it a day :-P

Harm

-----Original Message-----
From: Thomas E Deweese [mailto:thomas.deweese@kodak.com]
Sent: donderdag 13 maart 2003 16:36
To: Batik Users; harm.cuppens@iosint.be
Subject: RE: InvokeAndWait problem


>>>>> "HC" == Harm Cuppens <harm.cuppens@iosint.be> writes:

HC> Thanks for the reply, I see your point, but the problem will still
HC> be there.  In the void redo
HC> svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeAndWait(new
HC> Runnable() { // my code which acts on the DOM }); }

    So clearly someone has to switch to invokeLater() or move out of
the event thread.  So a couple of things,

    1) I think the suspicion that your undo will happen 'sooner' if
you use invokeAndWait instead of invokeLater is misguided.  It isn't
clear to me how you could still get a deadlock if you switched to
invokeLater (I'm guessing the problem moved).

    2) If your concern is that you want to ensure the addition has
completed before going on to other things then I suggest you take all
of your code out of the event loop and into a separate thread.

HC> Batik would still be able to call invokeAndWait in one of it's
HC> methods.  Because my undo/redo code works with the DOM, lots of
HC> events are triggered as a result. These events can be for example
HC> in my case: DOMNodeInserted, which the Bridge takes care of. In my
HC> case an Image element being inserted with an XLink, then the
HC> URIResolver calls the checkLoadExternalResource(...,...) which
HC> calls invokeAndWait again!

HC> Harm

HC> -----Original Message----- From: Siarhei Biarozkin
HC> [mailto:sberyozkin@zandar.com] Sent: donderdag 13 maart 2003 16:12
HC> To: Batik Users; harm.cuppens@iosint.be Subject: Re: InvokeAndWait
HC> problem


HC> Hi, I'd recommend not to couple your undo/redo functionality with
HC> the Batik, after all, it's just one component of your
HC> application. Instead, use something like this :

HC> Undoable undoable = new Undoable() { void do() {
HC> svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeAndWait(new
HC> Runnable() { // do it/redo it }); } void redo() {

HC> svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeAndWait(new
HC> Runnable() { // undo it }); } }

HC> YourUndoManager.redo() { undoable.redo(); }

HC> YourUndoManager.do() { undoable.do(); }

HC> There may be many more, perhaps, better approaches, but the key is
HC> to separate concerns Cheers Sergey Beryozkin

HC> ----- Original Message ----- From: "Harm Cuppens"
HC> <harm.cuppens@iosint.be> To: "Batik Users (E-mail)"
HC> <batik-users@xml.apache.org> Sent: Thursday, March 13, 2003 2:58
HC> PM Subject: InvokeAndWait problem


>> Hello all,
>>
>> I'm adding undo/redo support to my application (a little
>> SVGEditor). I
HC> have
>> a JSVGCanvas where I can draw my lines, rectangles etc. I can also
>> import images (or reference them) into the SVG document.
>>
>> For every action I perform I added undo/redo support.  For the
>> undo/redo action to happen immediately on the canvas, i call the
>> InvokeAndWait method:
>>
>> svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeAndWait(new
>> Runnable() { undoManager.redo() });
>>
>> But I have the following problem, I insert an <image> with a xlink
>> to a
HC> file
>> on my disk into the document. I then undo this operation (so the
>> image is removed again). Now when I try to redo this action, I call
>> the
HC> InvokeAndWait
>> method (to get immediate results on the canvas) which starts the
>> redo
HC> code.
>> But it seems that the class org.apache.batik.bridge.URIResolver
>> calls the method userAgent.checkLoadExternalResource(purl,
>> pDocURL). This brings me to the code inside the
>> BridgeUserAgentWrapper inner class of JSVGComponent where the
>> method calls another InvokeAndWait resulting a total halt of the
>> program. So I'm in a situation where i'm calling invokeAndWait to
>> run code that could call invokeAndWait again :-( I have tried the
>> invokeLater method, but that gave the same results,
HC> program
>> just hangs.
>>
>> Is there any way to get arround this (besides not using
>> invokeAndWait)? I really like to have my undo/redo actions to occur
>> immediately without
HC> having
>> to worry about that code calling another invokeAndWait.
>>
>> Thanks,
>>
>> Harm
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For
>> additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
>>


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


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



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


Mime
View raw message