did.gui
Class DIDCreationHandler

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

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

File:         DIDCreationHandler.java
Version:      1.0
Description:  This class is responsible for the creation of both rectangle and polygon 
ROIs.  Both types are created using mouse events.  Rectangles are created by pressing the
mouse at the point where you want the rectangle to begin then dragging the mouse to the 
proper size.  Releasing the mouse completes the creation process.  Polygons are created 
by clicking the mouse wherever you want a vertex to be placed.  To complete the Polygon 
click on the orginal vertex.  
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
DIDCreationHandler(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 detect mouse clicks.
 void mouseDragged(java.awt.event.MouseEvent e)
          Method used to respond to the user dragging the mouse.
 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)
          Method used to respond to the mouse being moved.
 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 user releasing the mouse.
 void setImageMax(int x, int y)
          Method used to set the maximum x and y coordinates thus establishing a virtual bounding rectangle (defined by the origin and max coordinates) which all ROIs must reside in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DIDCreationHandler

public DIDCreationHandler(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

setImageMax

public void setImageMax(int x,
                        int y)
Method used to set the maximum x and y coordinates thus establishing a virtual bounding rectangle (defined by the origin and max coordinates) which all ROIs must reside in. NOTE: In future versions it may be more efficient to construct a Java Rectangle object and used it's contains() method to determine if an ROI is inside the bounds of the Image.
Parameters:
x - The largest x coordinate.
y - The largest y coordinate.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Method used to detect mouse clicks. In this implementation the clicking of a mouse signifies the fixation of a vertex of a polygon. If the fixation point is the origin the polygon is complete. All actions necessary to properly complete the addition of an ROI are contained in the addROI method.
Parameters:
e - MouseEvent refelecting the current mouse properties.
See Also:
Polygon.addPoint(int, int)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Method used to respond to the mouse being moved. In this implementation moving the mouse is relevant to polygon creation. Once the first vertex of polygon ROI has been established (mouseClicked) this method take care of drawing a line between the last vertex to be fixed and the currend mouse position. This method also ensures the polygon ROI stays within the bounds of the image being edited.
Parameters:
e - MouseEvent refelecting the current mouse properties.
See Also:
mouseClicked(java.awt.event.MouseEvent), DIDPolyRoi.setLastVertex(int, int)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Method used to respond to the mouse being pressed. In this implementation a mouse pressed siginifies the begining of a rectangle sizing operation. This method checks to make sure the rectangle's origins are within the bounds of the image being edited.
Parameters:
e - MouseEvent refelecting the current mouse properties.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Method used to respond to the user dragging the mouse. In this implementation, dragging the mouse siginifies the sizing of a newly created rectangle ROI. This method checks to make sure the rectangle is within the bounds of the image being edited an sets it's size and location accordingly.
Parameters:
e - MouseEvent refelecting the current mouse properties.
See Also:
DIDRectRoi.setLocation(int, int)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Method used to respond to the user releasing the mouse. In this implementation a mouse release signifies the completion of a Rectangle ROI. All actions necessary to properly complete the addition of an ROI are contained in the addROI method.
Parameters:
e - MouseEvent refelecting the current mouse properties.
See Also:
#addRoi

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.

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.