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 Cameron McCormack <cl...@csse.monash.edu.au> on 2003/05/16 06:19:20 UTC

Changing SVG documents being displayed by JSVGCanvas

Hi.

I'm trying to do some simple updating of my SVG document while it's
being displayed by a JSVGCanvas.

Attached is some a short program which moves a rectangle when you click
the button.  What happens, though, is that the image only gets updated
if you move the mouse over the JSVGCanvas.  I have made my document
ALWAYS_DYNAMIC.  Is there a method I should be calling after updating
the document tree to force a redraw?

Thanks,

Cameron

-- 
Cameron McCormack
  // clm@csse.monash.edu.au
  // http://www.csse.monash.edu.au/~clm/
  // icq 26955922

Re: Changing SVG documents being displayed by JSVGCanvas

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "WB" == William Billingsley <wh...@cam.ac.uk> writes:

WB> Basically, just wrapping this around your update code should do
WB> the trick:

WB> // Returns immediately
WB> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
WB> Runnable() { public void run() { // your rectangle updates here
WB> }); }

WB> Any more experienced people, feel free to correct me.

    No this is correct.

WB> (Personally, I think Batik is still lacking a good overall How-To
WB> introduction -- there are several times when I've had to delve
WB> into the source for Squiggle just to see what the standard way of
WB> doing something with a JSVGCanvas is.  

    Agreed a good How-To would be nice. I'm sure committers would be
willing to help here, but right now I don't think any of the committers
has the time to write it whole cloth.

WB> It might also be worth revisiting why this externally-visible
WB> thread-switching is necessary, and whether it could have been
WB> hidden from the user of the JSVGCanvas by including it in the
WB> implementation of one of the Batik classes?  Just a couple of
WB> half-thought-out thoughts.)

    I'm open to suggestions, but I should also point out that this is
_exactly_ the same approach taken by swing.  The biggest difference is
that usually you don't notice it with swing since your listeners are
called in the event thread (similarly DOM call backs are made in the
update thread) with Batik however most people are getting called from
Swing and want to modify DOM).

    It was decided that using the event thread would not be good in
our case as it would 'freeze' any user application while rendering, or
script etc. were running.

WB> Will.

WB> On Friday 16 May 2003 5:19 am, Cameron McCormack wrote:
>> Hi.
>> 
>> I'm trying to do some simple updating of my SVG document while it's
>> being displayed by a JSVGCanvas.
>> 
>> Attached is some a short program which moves a rectangle when you
>> click the button.  What happens, though, is that the image only
>> gets updated if you move the mouse over the JSVGCanvas.  I have
>> made my document ALWAYS_DYNAMIC.  Is there a method I should be
>> calling after updating the document tree to force a redraw?
>> 
>> Thanks,
>> 
>> Cameron


WB> ---------------------------------------------------------------------
WB> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For
WB> 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


Re: Changing SVG documents being displayed by JSVGCanvas

Posted by Vincent Hardy <vi...@sun.com>.
Hi William,

William Billingsley wrote:

>(Personally, I think Batik is still lacking a good overall How-To introduction 
>-- there are several times when I've had to delve into the source for 
>Squiggle just to see what the standard way of doing something with a 
>JSVGCanvas is.  
>It might also be worth revisiting why this externally-visible thread-switching 
>is necessary, and whether it could have been hidden from the user of the 
>JSVGCanvas by including it in the implementation of one of the Batik classes?
>Just a couple of half-thought-out thoughts.)
>  
>

I agree that our documentation could be improved. Contributions in that 
area are welcome!
Vincent.



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


Re: Changing SVG documents being displayed by JSVGCanvas

Posted by William Billingsley <wh...@cam.ac.uk>.
Hi Cameron,

I'm also quite new to Batik and had a similar problem for a while.  If you 
look here:
http://xml.apache.org/batik/javaScripting.html#Threads
The documentation does tell you how to solve this.

Basically, just wrapping this around your update code should do the trick:

// Returns immediately
canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() 
{
     public void run() {
		// your rectangle updates here
      });
}

Any more experienced people, feel free to correct me.

(Personally, I think Batik is still lacking a good overall How-To introduction 
-- there are several times when I've had to delve into the source for 
Squiggle just to see what the standard way of doing something with a 
JSVGCanvas is.  
It might also be worth revisiting why this externally-visible thread-switching 
is necessary, and whether it could have been hidden from the user of the 
JSVGCanvas by including it in the implementation of one of the Batik classes?
Just a couple of half-thought-out thoughts.)

Will.

On Friday 16 May 2003 5:19 am, Cameron McCormack wrote:
> Hi.
>
> I'm trying to do some simple updating of my SVG document while it's
> being displayed by a JSVGCanvas.
>
> Attached is some a short program which moves a rectangle when you click
> the button.  What happens, though, is that the image only gets updated
> if you move the mouse over the JSVGCanvas.  I have made my document
> ALWAYS_DYNAMIC.  Is there a method I should be calling after updating
> the document tree to force a redraw?
>
> Thanks,
>
> Cameron


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