You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Harm Cuppens <ha...@iosint.be> on 2003/03/13 15:58:51 UTC

InvokeAndWait problem

Hello all,

I'm adding undo/redo support to my application (a little SVGEditor). I 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 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 InvokeAndWait
method (to get immediate results on the canvas) which starts the redo 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, 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 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


Re: InvokeAndWait problem

Posted by Siarhei Biarozkin <sb...@zandar.com>.
Hi,
I'd recommend not to couple your undo/redo functionality with the Batik,
after all, it's just one component of your application. Instead, use
something like this :

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

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

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

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

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

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


> Hello all,
>
> I'm adding undo/redo support to my application (a little SVGEditor). I
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
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
InvokeAndWait
> method (to get immediate results on the canvas) which starts the redo
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,
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
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
>
>
>


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