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
//*********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".