Zoom in/out Image

Hi guys,In my Applet , I'm drawing some shapes (ovals and lines) .I need to add zooming functionality , so that when i click zoom in button the Image is scaled correspondly.can someone suggest a way to do that ?thanks.
[254 byte] By [Servant@AKa] at [2007-10-2 0:44:18]
# 1
Yeah. I'd be interested in that too.The only suggestion I have is to change the size of what you are drawing by some factor. And also the location.If you are using drawImage(), it will do the scaling for you.
A_Sailora at 2007-7-15 16:59:08 > top of Java-index,Java Essentials,Java Programming...
# 2

This can easily be done using a zoom factor

ex:-

double zoomFactor = 1;

/*

when zoomFactor is 1 no zooming is used

when zoomFactor > 1 is zoom In

when zoomFactor < 1 is zoomOut

*/

//paintComponent method

g.drewLine(x1*zoomFactor, y1*zoomFactor, x2*zoomFactor, y2*zoomFactor);

if you want to enable scrolling you will need to impliment the getMaximumSize(), getMinimumSize(), getPreferedSize() methods to return the size by applying the zoomFactor

Every time the zoomFactor changes you have to repaint

LRMKa at 2007-7-15 16:59:08 > top of Java-index,Java Essentials,Java Programming...
# 3

> Yeah. I'd be interested in that too.

> The only suggestion I have is to change the size of

> what you are drawing by some factor. And also the

> e location.

>

> If you are using drawImage(), it will do the scaling

> for you.

thanks for you all guys for helping.

yes I'm using drawImage() and wants to know how to do scaling with that ?

If not i'll try to use the zoomFactor method.

can we use the any scaling method for the Graphics object ?

thanks

Servant@AKa at 2007-7-15 16:59:08 > top of Java-index,Java Essentials,Java Programming...
# 4
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image, int, int, int, int, int, int, int, int, java.awt.image.ImageObserver)
CeciNEstPasUnProgrammeura at 2007-7-15 16:59:08 > top of Java-index,Java Essentials,Java Programming...