Hi Ray,

Ray <[EMAIL PROTECTED]> wrote on 07/31/2006 12:09:03 PM:

> The JSVGCanvas.ZOOM_IN_ACTION and ZOOM_OUT_ACTION are too abrupt for my
> liking. [...] The goal here was to zoom by the smaller
> increments specified above, looping through them ten times and sleeping
> between zooms to create an "animated" effect similar to what you would 
see
> when zooming with Google maps.  Here's the code I am using:
> 
> for (int j=0; j<10; j++) {
> 
view.getActionMap().get(JSVGCanvas.ZOOM_IN_ACTION).actionPerformed(null);
>   Thread.sleep(100);
> }

> Pretty simple.  The only problem is that while looping, the changes made 
to
> the view object (an SVGViewBoard object) are not showing on the screen. 

   If this is running in the Swing thread (like in the handler for an
event from the JSlider) then you are 'blocking' the swing thread and
it can't update anything.

> If I retrieve the scaling inside of the loop, I can see that it is being
> properly updated on each iteration.  The changes do not show up until 
the
> loop completes, at which point the SVG has been properly rescaled to its
> final desired size.  What's the trick to this? 

   You need to move your loop out of the Swing thread.  Of course when
you do this you will need to take care to update the swing controls
in the Swing thread.

> I tried upping the sleep time, and I've also tried running them through 
> the UpdateManager, but I get the same result.

   You may also find that the rerender speed is not fast enough in
which case you may want to investigate manipulating the 
'paintingTransform'
rather than the rendering transform during the animated effect (take a 
look
at the AbstractImageZoomInteractor). 

   Of course the ideal thing would be to trigger a re-render of the tree 
at the final resolution immediately and use the paint-transform (scaling
the old image) until that render completes. Which if before the animated
effect completes you would then use to scale for the end of the animated
effect, otherwise just switch the view and the end of the render.

   Doing this would be rather involved however since you would have to
really get into the rendering/update handling of the Swing component so
I probably don't suggest trying it unless you really want to learn a lot
about how Batik does rendering & updates (a very complex task).


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

Reply via email to