Hi there !
I made a simple drawing applet in Java, using Graphics 2D API. You can
draw shapes, select them,
drag them, etc.
I tried to add zooming abilities by overriding the paintComponent
method of the JPanel:
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.scale(zoomValue, zoomValue);
....// draw shapes
}
zoomValue is a double that changes when clicking on ZoomOut or ZoomIn
buttons in the applet.
The scale works okay for shapes displayed on the JPanel. But the mouse
coordinates are not
affected by the scale. So I can't select the shapes properly with the
mouse.
Do you know a simple way to scale the mouse coordinates ?
Thank you very much !
Julien
ak - 04 Jan 2004 21:00 GMT
> I made a simple drawing applet in Java, using Graphics 2D API. You can
> draw shapes, select them,
[quoted text clipped - 20 lines]
> affected by the scale. So I can't select the shapes properly with the
> mouse.
why not to scale the shape itself?
--
____________
http://reader.imagero.com the best java image reader.