jj2000.disp
Class ImgMouseListener

java.lang.Object
  |
  +--java.awt.event.MouseAdapter
        |
        +--jj2000.disp.ImgMouseListener
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class ImgMouseListener
extends java.awt.event.MouseAdapter
implements java.awt.event.MouseMotionListener

This class handles the dragging of an image displayed in an ImgScrollPane. When the mouse is dragged the image scrolls accordingly.

Objects of this class must be registerd as both mouse listener and mouse motion listener.

While the dragging is taking place the cursor is changed to the MOVE_CURSOR type. The original cursor is restored when the mouse is released after the drag.


Field Summary
(package private)  ImgScrollPane isp
          The component where the image is displayed
(package private)  java.awt.Cursor prevCursor
           
(package private)  int startMouseX
          The horizontal coordinate where the drag starts
(package private)  int startMouseY
          The vertical coordinate where the drag starts
(package private)  int startScrollX
          The horizontal scroll position when the drag started
(package private)  int startScrollY
          The vertical scroll position when the drag started
 
Constructor Summary
ImgMouseListener(ImgScrollPane isp)
          Instantiate a new ImgMouseListener that will work on the specified ImgScrollPane.
 
Method Summary
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mouseMoved(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseEntered, mouseExited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isp

ImgScrollPane isp
The component where the image is displayed


startMouseX

int startMouseX
The horizontal coordinate where the drag starts


startMouseY

int startMouseY
The vertical coordinate where the drag starts


startScrollX

int startScrollX
The horizontal scroll position when the drag started


startScrollY

int startScrollY
The vertical scroll position when the drag started


prevCursor

java.awt.Cursor prevCursor
Constructor Detail

ImgMouseListener

public ImgMouseListener(ImgScrollPane isp)
Instantiate a new ImgMouseListener that will work on the specified ImgScrollPane.

Parameters:
isp - The image scroll pane on which the actions should operate.
Method Detail

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class java.awt.event.MouseAdapter

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class java.awt.event.MouseAdapter

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener