Hi Ted Just in case it may be of some interrest... You may take a look here:
http://seagis.sourceforge.net/javadoc/net/seas/awt/ZoomPane.html (sorry, the JavaDoc is in French for now. I have translated some part in English, but not this one yet... However, all widgets are localized (French and English for now)) You can zoom, translate and rotate with keyboard, mouse wheel (zoom only) or contextual menu (right mouse click). When using keyboard, the zoom is centered around the center of the display area. When using mouse (mouse wheel or contextual menu), the zoom is centered around the mouse cursor location. You can also zoom by draging a rectangular area with the mouse. This class take care of managing JScrollBars. Futhermore, each zoom change fire a ZoomChangeEvent. You can use it to synchronized many zooms (i.e. any zoom done in a ZoomPane is also applied in whatever other ZoomPane you want). Since it is LGPL code (not GPL), you can use it without having to GPLified yours code. I guess you can also look at the source code and pick whatever you want... Good luck, Martin. ----- Message d'origine ----- De : "Ted Hill" <[EMAIL PROTECTED]> Envoy� : lundi 8 octobre 2001 14:48 Objet : Re: Pan Zoom Rotate > Mike, > > Thanks, > > This does fix the 'jumping' problem, but now the rotation is no longer > around the center of the display area. > > My goal is to have both the zoom and rotate be done on the center of the > display area, and to have the pan track the mouse without jumping. > > Thanks again, > > Ted Hill > > > ----- Original Message ----- > From: "Mike Robinson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, October 05, 2001 6:21 PM > Subject: Re: [JAVA2D] Pan Zoom Rotate > > > > Ted, > > > > The following change fixes the 'jumping' problem. However, it effects > where your rotation center is. But that > > may be a simplier problem. > > > > // right mouse does pan and rotate > > if(SwingUtilities.isRightMouseButton(e)) > > { > > bZooming = false; > > > > if(e.isControlDown()) // rotating > > { > > rotationDegrees += deltaX; > > } > > else // panning > > { > > // need to adjust the delta values depending on the > current > > // zoom factor. If don't do this panning goes 'too > fast' when > > // zoomed up and 'too slow' when zoomed down. > > panX += deltaX * (1/zoomFactor); > > panY += deltaY * (1/zoomFactor); > > > > } > > // adjust the pan translation so that even when > > // axes are rotated, will still pan in direction of > > // mouse movement > > file://*********Moved this code from the else above > > double radians = degreesToRadians(rotationDegrees); > > double sinRadians = Math.sin(radians); > > double cosRadians = Math.cos(radians); > > > > xPrime = (panX * cosRadians) + (panY * sinRadians); > > yPrime = (panY * cosRadians) - (panX * sinRadians); > > } > > > > -Mike Robinson > > > > Ted Hill wrote: > > > > > Attached is a short one-file example that creates a buffered image and > > > displays it in a JPanel. > > > > > > Using the mouse you can pan, zoom and rotate the image as follows: > > > > > > * To zoom, drag left mouse button up (bigger) or down (smaller). > > > * To pan, drag right mouse button in any direction. > > > * To rotate, drag right mouse button left or right with CTRL down. > > > > > > The rotate and zoom are done about the center of the panel, i.e. you can > > > zoom in on the center of the image without it drifting off to the side. > You > > > can also rotate the image about its current center. > > > > > > I'm having a problem with my pan though. > > > > > > Pan works fine if there is no rotation. > > > > > > However, following a rotation, the image will 'jump' initially. After > the > > > initial jump, it will track the mouse as desired. > > > > > > Can anyone help me eliminate the initial jump when starting a pan > following > > > a rotate? > > > > > > Thank you, > > > > > > Ted Hill > > > > > > ------------------------------------------------------------------------ > > > Name: PanZoomTest4.java > > > PanZoomTest4.java Type: VisualCafe File > (application/x-unknown-content-type-VisualCafeFile.Document) > > > Encoding: quoted-printable > > > > -- > > ****************************************** > > Mike Robinson, Computer Science Department > > Maharishi University of Management > > Fairfield, IA 52557 USA > > Voice: 1-641-472-7000 ext. 4300 > > Email: [EMAIL PROTECTED] > > > > > =========================================================================== > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the > body > > of the message "signoff JAVA2D-INTEREST". For general help, send email to > > [EMAIL PROTECTED] and include in the body of the message "help". > > > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
