&& ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0)) {
setPosition(evt.getX(), evt.getY());
origin = evt.getPoint();
JCanvas canvas = ((JCanvas) _target.getView());
TransformContext context = canvas.getCanvasPane()
.getTransformContext();
// clone the transform that is in the context, so we can
// avoid a lot of repeated scaling of the same transform.
transformOrigin = (AffineTransform) context.getTransform()
.clone();
// Take the event and first transform it from the panner
// coordinates into the view coordinates.
Dimension viewSize = _target.getView().getSize();
Rectangle viewRect = new Rectangle(0, 0, viewSize.width,
viewSize.height);
Rectangle myRect = _getInsetBounds();
AffineTransform forward = CanvasUtilities.computeFitTransform(
viewRect, myRect);
double xScaled = (origin.getX() - myRect.getX())
/ forward.getScaleX();
double yScaled = (origin.getY() - myRect.getY())
/ forward.getScaleY();
scaled = new Point2D.Double(xScaled, yScaled);
// Now transform from the view coordinates into the
// pane coordinates.
try {
context.getInverseTransform().transform(scaled, scaled);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}