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 th...@kodak.com on 2008/02/06 02:18:45 UTC

Re: Panning around and SVG document

Hi Mark,

"Mark Claassen" <mc...@ocie.net> wrote on 01/11/2008 03:42:00 PM:

> There are three things I want to do:
> 1) allow zooming via a toolbar control
>    -- Abbreviated feature set
>      --If the vertical scroll bar is 0, 
>        zoom in and keep vertical scroll bar value 0
>      --If vertical scroll bar is not 0,
>        zoom in and keeping the center of the viewable area
>        in the center after the zoom as much as possible
> 
> 2) allow zooming via mouse double-click, centering on the MouseEvent
> 3) Have a fit-to-page and a fit-width (like Acrobat's)
> 
> If someone could give me a nudge in the right direction, I would really
> appeciate it.

   As you appear to be aware all of the above is accomplished 
by adjusting the rendering transform on the canvas.

> Here is a sample of the code I have that does not work.  I
> would have expected this to work.

    I would have expected it to work as well.  What does it do?
And when is the code called?

> Also, for the first 2 items, how can I specify the region I want to 
> scroll to?

   The JSVGScrollPane is totally driven by the Rendering transform
and the bounds of the document so changing the translate on the
Rendering Transform will update the scrollbars as well.

> What I had to do before is set this after I got a gvtRenderingStarted 
> event.  Is there a more straightforward way of doing this?

    The initial rendering transform is set by the 
'computeRenderingTransform'
method.  So you can subclass the canvas and override that to provide
an initial rendering transform if you wanted to.

===

> canvas is a JSVGCanvas
> scroller is a JSVGScrollPane
> 
>    private void matchWidth() {
>       Dimension2D docSize = canvas.getSVGDocumentSize();
>       Dimension panelSize = scroller.getSize();
>       double scaleFactor =
> panelSize.getWidth()/docSize.getWidth();
> 
> 
canvas.setRenderingTransform(AffineTransform.getScaleInstance(scaleFactor 
,
> scaleFactor ));
>    }