com.rolemodelsoft.drawlet.basics
Class SelectionTool

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
        |
        +--com.rolemodelsoft.drawlet.basics.CanvasTool
              |
              +--com.rolemodelsoft.drawlet.basics.SelectionTool
Direct Known Subclasses:
GraphNodeTool

public class SelectionTool
extends CanvasTool

This provides basic functionality necessary to select a Figure(s) on a DrawingCanvas and/or pass control onto Handles. There could be other ways to provide this functionality, but this seems like a safe generic way to do it.


Field Summary
protected  Figure referenceFigure
          The figure where the mouse went down.
protected  int referenceX
          The x coordinate where the mouse went down.
protected  int referenceY
          The y coordinate where the mouse went down.
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.CanvasTool
canvas
 
Constructor Summary
SelectionTool(DrawingCanvas canvas)
          Constructs and initializes a new instance of a tool to select figures on a DrawingCanvas
 
Method Summary
 void boxSelect(java.awt.event.MouseEvent e, int x, int y)
          Select based on a box.
protected  void mouseDoubleClicked(java.awt.event.MouseEvent e)
          Called if the mouse is double-clicked.
 void mouseDragged(java.awt.event.MouseEvent e)
          Called if the mouse is dragged (the mouse button is down).
 void mousePressed(java.awt.event.MouseEvent e)
          Called if the mouse is down.
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.CanvasTool
getX, getY, mouseReleased
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseSingleClicked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

referenceX

protected int referenceX
The x coordinate where the mouse went down. This is used to determine what to do when other events occur.

referenceY

protected int referenceY
The y coordinate where the mouse went down. This is used to determine what to do when other events occur.

referenceFigure

protected Figure referenceFigure
The figure where the mouse went down. This is used to determine what to do when other events occur.
Constructor Detail

SelectionTool

public SelectionTool(DrawingCanvas canvas)
Constructs and initializes a new instance of a tool to select figures on a DrawingCanvas
Parameters:
canvas - the canvas from which to select figures.
Method Detail

boxSelect

public void boxSelect(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Select based on a box.
Parameters:
e - the event caused this to happen
x - the x coordinate of the mouse
y - the y coordinate of the mouse
See Also:
mouseDragged(java.awt.event.MouseEvent)

mouseDoubleClicked

protected void mouseDoubleClicked(java.awt.event.MouseEvent e)
Called if the mouse is double-clicked. Try passing it on to a handle if there is one present at the point. Otherwise, see if there is a figure who might want to give control to an editTool.
Overrides:
mouseDoubleClicked in class AbstractInputEventHandler
Parameters:
e - the event
See Also:
AbstractInputEventHandler.mouseClicked(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Called if the mouse is dragged (the mouse button is down). If we didn't put it down on top of a figure, do a box select, otherwise, move the selected figures (and handles);
Overrides:
mouseDragged in class AbstractInputEventHandler
Parameters:
e - the event

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Called if the mouse is down. Keep track of where the mouse went down and then look for handles to take control, or figures to select/deselect
Overrides:
mousePressed in class AbstractInputEventHandler
Parameters:
e - the event