com.rolemodelsoft.drawlet.basics
Class BoxSelectionHandle

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
        |
        +--com.rolemodelsoft.drawlet.basics.CanvasHandle
              |
              +--com.rolemodelsoft.drawlet.basics.BoxSelectionHandle

public class BoxSelectionHandle
extends CanvasHandle

A handle one can use to select figures on a canvas within a box. This would typically be used by some sort of SelectionTool, but there is nothing in the code that assumes that to be the case.


Field Summary
protected  int anchorX
          The x coordinate at which the box is anchored.
protected  int anchorY
          The y coordinate at which the box is anchored.
protected  java.awt.Rectangle box
          The Rectangular area to search for figures.
protected  java.util.Vector surrounded
          The figures that are surrounded.
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.CanvasHandle
canvas, halfWidth, HANDLE_SIZE, previousTool
 
Constructor Summary
BoxSelectionHandle(int startX, int startY, int endX, int endY)
          Constructs and initializes a new instance with a box derived from two points.
 
Method Summary
 boolean contains(int x, int y)
          Checks whether a specified x,y location is "inside" this handle, where x and y are defined to be relative to the coordinate system of this handle.
 java.awt.Rectangle getBounds()
          Returns the current bounds of this handle.
protected  java.awt.Color getHighlightColor()
          Answer the Color to use when highlighting.
 void mouseDragged(java.awt.event.MouseEvent evt)
          Resize the selection area and make sure the ones inside are selected, and those newly outside are not.
 void paint(java.awt.Graphics g)
          Paints the handle.
 void releaseControl(DrawingCanvas canvas)
          Release control of the canvas and clean up if necessary.
 void takeControl(DrawingCanvas canvas)
          Make the handle be the event handler for the canvas.
protected  void updateBox(int x, int y)
          Change the box of the receiver based on its anchor and a new x,y.
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.CanvasHandle
defaultHandleSize, finished, getHandleHeight, getHandleSize, getHandleWidth, getX, getY, intersects, mouseReleased, setHandleSize
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
keyPressed, keyReleased, keyTyped, mouseClicked, mouseDoubleClicked, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseSingleClicked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

box

protected java.awt.Rectangle box
The Rectangular area to search for figures.

anchorX

protected int anchorX
The x coordinate at which the box is anchored.

anchorY

protected int anchorY
The y coordinate at which the box is anchored.

surrounded

protected java.util.Vector surrounded
The figures that are surrounded.
Constructor Detail

BoxSelectionHandle

public BoxSelectionHandle(int startX,
                          int startY,
                          int endX,
                          int endY)
Constructs and initializes a new instance with a box derived from two points. NOTE: They do NOT have to be top-left and bottom-right
Parameters:
startX - the x coordinate of the anchor corner
startY - the y coordinate of the anchor corner
endX - the x coordinate of the floating corner
endY - the y coordinate of the floating corner
Method Detail

contains

public boolean contains(int x,
                        int y)
Checks whether a specified x,y location is "inside" this handle, where x and y are defined to be relative to the coordinate system of this handle.
Overrides:
contains in class CanvasHandle
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
boolean value of true if the specified x,y position is "inside this handle; false otherwise.

getBounds

public java.awt.Rectangle getBounds()
Returns the current bounds of this handle.
Overrides:
getBounds in class CanvasHandle
Returns:
a Rectangle representing the current bounds of this handle

getHighlightColor

protected java.awt.Color getHighlightColor()
Answer the Color to use when highlighting.
Returns:
the Color to use when highlighting

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Resize the selection area and make sure the ones inside are selected, and those newly outside are not.
Overrides:
mouseDragged in class AbstractInputEventHandler
Parameters:
evt - the event

paint

public void paint(java.awt.Graphics g)
Paints the handle.
Overrides:
paint in class CanvasHandle
Parameters:
g - the specified Graphics window

releaseControl

public void releaseControl(DrawingCanvas canvas)
Release control of the canvas and clean up if necessary. Since this is a public method, don't assume the receiver actually has control.
Overrides:
releaseControl in class CanvasHandle
Parameters:
canvas - the canvas which the receiver is to release control

takeControl

public void takeControl(DrawingCanvas canvas)
Make the handle be the event handler for the canvas. Note, once it takes control, it is obligated to return at a future point in time.
Overrides:
takeControl in class CanvasHandle
Parameters:
x - the x coordinate
y - the y coordinate
See Also:
#locate

updateBox

protected void updateBox(int x,
                         int y)
Change the box of the receiver based on its anchor and a new x,y.
Parameters:
x - the x coordinate
y - the y coordinate