did.gui
Class DIDSelectionHandler

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

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

File:         DIDSelectionHandler.java
Version:      
Description:  This class provides the mult-selection capability for the ImageCanvas.  It
is registered with the ImageCanvas and intercepts mouse events.  When two or more ROIs 
overlap this class populates the activeRoi attribute in the ImageCanvas object it is 
registered to with the ROI that should be active.  It accomplishes this by building a
stack of ROIs that contain the point where the user clicks and then rotating through that
stack.  
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
DIDSelectionHandler(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)
          This method is called when the mouse is pressed then released.
 void mouseDragged(java.awt.event.MouseEvent e)
          This method is called when the mouse is being dragged (Mouse pressed then moved while button is held down within the component.
 void mouseEntered(java.awt.event.MouseEvent e)
          This method is called when the mouse enters the component.
 void mouseExited(java.awt.event.MouseEvent e)
          This method is called when the mouse leaves the component.
 void mouseMoved(java.awt.event.MouseEvent e)
          This method is called when the mouse is moving within the component.
 void mousePressed(java.awt.event.MouseEvent e)
           Captures mouse button press.
 void mouseReleased(java.awt.event.MouseEvent e)
          This method is called when the user releases the mouse button.
 void resetSelection()
          Method used to re-initialize the selection model.
 DIDRoiIFC selectRoi(java.awt.event.MouseEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DIDSelectionHandler

public DIDSelectionHandler(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)
Captures mouse button press.  This method is the begining of ROI manipulation.  All ROI
selection behavior is manipulated through a stack and a vector.  The stack determines 
which ROI(s) fall within the current mouse x,y coordinate and the vector contains all 
the ROIs of the image.  First, the method checks the existing selection stack to see if
it has any members.  If it does then check to see if the current mouse xy is in all the
members.  If it is then it is safe to make the next ROI in the stack the current ROI and
continue with the mouseDragged event.  If the stack fails any of these tests then a new 
one must be built.  Next, if the selection stack is empty OR all of the ROIs in the 
selection stack don't contain the latest mouse x,y then it is necessary to (re)build the
selection stack.  This is accomplished by looping through the vector containing all the 
images ROI's and asking each if the mouse x,y is inside their boundries.  Those that do 
are added to the selection stack.  The stack is then interrigated to see if it contains
any ROIs.  If it does then current ROI becomes the top ROI in the stack.  If the stack 
is empty that means the user has clicked on an empty portion of the image and a new ROI 
is created and initalized.
 
Parameters:
e - MouseEvent refelecting the current mouse properties.
See Also:
mouseReleased(java.awt.event.MouseEvent)

selectRoi

public DIDRoiIFC selectRoi(java.awt.event.MouseEvent e)
Parameters:
-  
Returns:
 

resetSelection

public void resetSelection()
Method used to re-initialize the selection model. This resetting is accomplished by clearing the roiStack, reseting the focus of all ROIs and setting the activeRoi to null.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
This method is called when the user releases the mouse button. In this implementation it is necessary to remove the ROI in the top of the Stack. By doing this the user is able to cycle through all the RIOs in any given point.
Parameters:
e - MouseEvent refelecting the current mouse properties.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
This method is called when the mouse is pressed then released. There is no special implmentation for this application.
Parameters:
e - MouseEvent refelecting the current mouse properties.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
This method is called when the mouse is being dragged (Mouse pressed then moved while button is held down within the component. There is no special implmentation for this application.
Parameters:
e - MouseEvent refelecting the current mouse properties.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
This method is called when the mouse enters the component. There is no special implmentation for this application.
Parameters:
e - MouseEvent refelecting the current mouse properties.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
This method is called when the mouse leaves the component. There is no special implmentation for this application.
Parameters:
e - MouseEvent refelecting the current mouse properties.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
This method is called when the mouse is moving within the component. There is no special implmentation for this application.
Parameters:
e - MouseEvent refelecting the current mouse properties.

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.