/*========================================================================= Program: FusionViewer Module: $RCSfile: PanMouseTool.java,v $ Language: Java Date: $Date: 2007/02/02 19:25:27 $ Version: $Revision: 1.3 $ Copyright (c) Insightful Corporation. All rights reserved. See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ package org.fusionviewer.display; import java.awt.Point; import java.awt.event.MouseEvent; /**\class PanMouseTool *\brief Pan a zoomed in image in response to the user dragging the mouse. */ public class PanMouseTool implements MouseTool { private ImageSliceView m_parent; private Point m_anchor; public PanMouseTool(ImageSliceView parent) { m_parent = parent; } public boolean canHandle(MouseEvent e) { return true; } public void mousePressed(MouseEvent e) { m_anchor = e.getPoint(); } public void mouseReleased(MouseEvent e) { m_parent.releaseMouseTool(); } public void mouseDragged(MouseEvent e) { int dx = -(e.getX() - m_anchor.x); int dy = -(e.getY() - m_anchor.y); m_parent.setOrigin(m_parent.getXOrigin() + dx, m_parent.getYOrigin() - dy); m_anchor = e.getPoint(); } public void mouseMoved(MouseEvent e) { } }