com.rolemodelsoft.drawlet.shapes.lines
Class LinePointHandle

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
        |
        +--com.rolemodelsoft.drawlet.basics.CanvasHandle
              |
              +--com.rolemodelsoft.drawlet.basics.SquareCanvasHandle
                    |
                    +--com.rolemodelsoft.drawlet.shapes.lines.LinePointHandle
Direct Known Subclasses:
ConnectingLinePointHandle

public class LinePointHandle
extends SquareCanvasHandle
implements FigureHolder

This class provides a handle that shows up at a particular Locator on a line and reshapes the figure accordingly as it is dragged.


Field Summary
protected  LineFigure figure
          The figure to which we are attached.
protected  int index
          The index of the point (vertex) on the line we manipulate.
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.CanvasHandle
canvas, halfWidth, HANDLE_SIZE, previousTool
 
Constructor Summary
LinePointHandle(LineFigure figure, int index)
          Constructs and initializes a new instance of a handle which can affect the the position of a particular point defining a line.
 
Method Summary
protected  int centerX()
          Answer the x coordinate at the center of the handle.
protected  int centerY()
          Answer the y coordinate at the center of the handle.
 Figure getFigure()
          Answers the figure associated with this handle.
 void mouseDragged(java.awt.event.MouseEvent evt)
          Called if the mouse is dragged (the mouse button is down).
 void mouseReleased(java.awt.event.MouseEvent evt)
          Called if the mouse is released (the mouse button goes up).
 void move(int x, int y)
          Reshape the figure by moving the corresponding point and cleanly repaint the canvas.
 void setFigure(Figure newFigure)
          Set the figure the receiver is holding.
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.SquareCanvasHandle
getBounds, paint
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.CanvasHandle
contains, defaultHandleSize, finished, getHandleHeight, getHandleSize, getHandleWidth, getX, getY, intersects, releaseControl, setHandleSize, takeControl
 
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

figure

protected LineFigure figure
The figure to which we are attached.

index

protected int index
The index of the point (vertex) on the line we manipulate.
Constructor Detail

LinePointHandle

public LinePointHandle(LineFigure figure,
                       int index)
Constructs and initializes a new instance of a handle which can affect the the position of a particular point defining a line.
Parameters:
figure - the figure whose point (vertex) we may wish to move.
index - the identifying index of the point of interest.
Method Detail

centerX

protected int centerX()
Answer the x coordinate at the center of the handle.
Overrides:
centerX in class SquareCanvasHandle
Returns:
an integer representing the x coordinate at the center of the handle

centerY

protected int centerY()
Answer the y coordinate at the center of the handle.
Overrides:
centerY in class SquareCanvasHandle
Returns:
an integer representing the x coordinate at the center of the handle

getFigure

public Figure getFigure()
Answers the figure associated with this handle.
Specified by:
getFigure in interface FigureHolder
Returns:
the Figure associated with this handle

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Called if the mouse is dragged (the mouse button is down).
Overrides:
mouseDragged in class AbstractInputEventHandler
Parameters:
evt - the event
See Also:
move(int, int)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Called if the mouse is released (the mouse button goes up).
Overrides:
mouseReleased in class CanvasHandle
Parameters:
evt - the event

move

public void move(int x,
                 int y)
Reshape the figure by moving the corresponding point and cleanly repaint the canvas.
Parameters:
x - the x coordinate for the new location of the point
y - the y coordinate for the new location of the point

setFigure

public void setFigure(Figure newFigure)
Set the figure the receiver is holding. Note: in this case, it must be a LineFigure
Specified by:
setFigure in interface FigureHolder
Parameters:
newFigure - the new LineFigure to affect.
Throws:
java.lang.IllegalArgumentException - If the figure is not a LineFigure.