xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Wagener <peter.wage...@hypoluxo.com>
Subject Re: Scrollbars & auto-resizing
Date Mon, 03 Apr 2006 19:44:12 GMT
Hi All,

I actually ended up getting the behavior I desired (see previous  
email in thread) by setting the canvas's 'recenterOnResize' property  
to 'true', but *after* I created the JSVGScrollPane to contain the  
canvas.  So...

JSVGScrollPane scrollPane = new JSVGScrollPane(canvas);
add(scrollPane, BorderLayout.CENTER);
canvas.setRecenterOnResize(true);

The JSVGScrollPane constructor sets that property to false  
explicitly, so I feel like I'm breaking a rule here... anyone know  
the reason for doing that?  Either way, I've got something workable I  
think.


Thanks,

Peter



On Mar 28, 2006, at 4:50 PM, Peter Wagener wrote:

> Hi All,
>
> I'm trying to implement a viewer that has a JSlider to control the  
> zoom
> level, and uses scrollbars to allow the user to move around the image
> when zoomed in. In the containing JPanel, I've taken my JSVGCanvas and
> wrapped it inside a JSVGScrollPane...
>
>         JSVGScrollPane scrollPane = new JSVGScrollPane(canvas);
>         add(scrollPane, BorderLayout.CENTER);
>
> ... and implemented the JSlider control by having the listener  
> create a
> new JsvgCanvas.ZoomAction(...).  In this case, my JSlider's values go
> from 100 to 300:
>
>         double desiredScale = zoomSlider.getValue();
>         double oldScale = currentScale;
>         double zoomLevel = desiredScale / oldScale;
>
>         JSVGCanvas.ZoomAction zoomAction = canvas.new
> ZoomAction(zoomLevel);
>         zoomAction.actionPerformed(null);
>
>         currentScale = desiredScale;
>
> This works great -- the user can zoom in & out with the slider, and  
> the
> scrollbars respond correctly.  The zooming is also smooth and shows  
> live
> updates.  The only minor issue I have is that zooming in, scrolling to
> the bottom, then zooming back out leaves the image uncentered; I'd  
> like
> to have it automatically track back towards the original center  
> point of
> the image, but I'm willing to leave that for future work :)
>
> My main issue is that the JSVGScrollPane seems to remove the default
> behavior of the JSVGCanvas, in which it automatically resizes  
> itself to
> fill the containing JPanel when that panel changes size.  This makes
> sense, as the scrollpane's size never changes, but is there a way to
> have the best of both worlds?  In other words, have a widget (like the
> slider) control "manual" zooming that has scrollbars, but still let  
> the
> JSVGCanvas resize itself as necessary?
>
>
> Thanks,
>
> Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users- 
> help@xmlgraphics.apache.org
>
>


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


Mime
View raw message