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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]