did.gui
Class DIDEditHandler

java.lang.Object
  |
  +--did.gui.DIDEditHandler

public class DIDEditHandler
extends java.lang.Object
implements javax.swing.event.MouseInputListener, java.awt.event.KeyListener

File:         DIDEditHandler.java
Version:      1.1
Description:  This class handles all movement and scaling of ROIs (rotation was inteded to 
be handled by this class but for now is handled by the ImageCanvas).  To do so it must be
registered on the DIDImageCanvas for the type of events that it is to listen for.  This 
class is setup to handle Mouse and Key events.  Example:
  DIDEditHandler newEditHandler = new DIDEditHandler(DIDImageCanvas);
  addMouseMotionListener(newEditHandler)
Three basic functionalities are exposed by this class: the ablility to translate an ROI to
the active vertex, set the active vertex, and skew the active vertex (Rotation is also 
performed arount the active vertex but at the moment not by this class).  The active 
vertex is therefore an important concept in the manipulation of ROIs and is set by holding
down the control key and clicking on the on the vertex handle(the square around the 
vertex).  Once set the active vertex appears in green.  
Note:  This class also extends the KeyListener interface but does not implement any special
code.  Due to an unresolved issue which does not allow KeyEvent detection on any other 
object than the main Frame all key detection is being handled in the main Frame.   This 
is only a stopgap measure.  Once the soure of the error has been identified all KeyEvent
detection should be moved to the appropriate classes.

Modification Log:
Date          Name    Comment
xx-xx-xxxx    XXX	   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Constructor Summary
DIDEditHandler(DIDImageCanvas canvas)
          Method used to instantiate the class.
 
Method Summary
 void keyPressed(java.awt.event.KeyEvent e)
          This method is triggered when the user presses a key.
 void keyReleased(java.awt.event.KeyEvent e)
          This method is triggered when the user releases a key.
 void keyTyped(java.awt.event.KeyEvent e)
          This method is triggered when the user presses then releases a key.
 void mouseClicked(java.awt.event.MouseEvent e)
          Method used to respond to the mouse being clicked.
 void mouseDragged(java.awt.event.MouseEvent e)
          Method used to respond to the mouse being dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
          Method used to respond to the mouse entering the Canvas.
 void mouseExited(java.awt.event.MouseEvent e)
          Method used to respond to the mouse leaving the Canvas.
 void mouseMoved(java.awt.event.MouseEvent e)
          Method used to respond to the mouse moving in the Canvas.
 void mousePressed(java.awt.event.MouseEvent e)
          Method used to respond to the mouse being pressed.
 void mouseReleased(java.awt.event.MouseEvent e)
          Method used to respond to the mouse being released.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DIDEditHandler

public DIDEditHandler(DIDImageCanvas canvas)
Method used to instantiate the class. Sets a refernce to the ImageCanvas to which this listener is registered.
Parameters:
canvas - The ImageCanvas to which this listener is registered.
Method Detail

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Method used to respond to the mouse being pressed. In this implementation if the Alt key is down the active vertex in the Polygon is set to the current mouse position. If the Shift key is down then the entire Polygon is translated to the location of the MouseEvent (Translation is constrained to the active vertex).
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Method used to respond to the mouse being dragged. In this implementation if the Alt key is down the active vertex in the Polygon is set to the current mouse position. If the Shift key is down then the entire Polygon is translated to the location of the MouseEvent (Translation is constrained to the active vertex).
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Method used to respond to the mouse being clicked. In this implementation when the user clicks on the ImageCanvas without holding down any other keys
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Method used to respond to the mouse being released. There is currently no need to implement this method in this class.
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Method used to respond to the mouse entering the Canvas. There is currently no need to implement this method in this class.
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Method used to respond to the mouse leaving the Canvas. There is currently no need to implement this method in this class.
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Method used to respond to the mouse moving in the Canvas. There is currently no need to implement this method in this class.
Parameters:
e - A MouseEvent class describing the current state of the physical mouse device.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
This method is triggered when the user presses a key. There is no special implmentation for this application. (See note at top of class)
Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
e - KeyEvent refelecting the current keyboard properties.

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
This method is triggered when the user releases a key. There is no special implmentation for this application. (See note at top of class)
Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
e - KeyEvent refelecting the current keyboard properties.

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
This method is triggered when the user presses then releases a key. There is no special implmentation for this application. (See note at top of class)
Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
e - KeyEvent refelecting the current keyboard properties.