com.rolemodelsoft.drawlet.shapes.lines
Class LineTool

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
        |
        +--com.rolemodelsoft.drawlet.basics.CanvasTool
              |
              +--com.rolemodelsoft.drawlet.basics.ConstructionTool
                    |
                    +--com.rolemodelsoft.drawlet.shapes.ShapeTool
                          |
                          +--com.rolemodelsoft.drawlet.shapes.lines.LineTool
Direct Known Subclasses:
ConnectingLineTool

public class LineTool
extends ShapeTool

This tool produces Lines. Currently, one must hold the shift key down in order to add more than a single segment.


Fields inherited from class com.rolemodelsoft.drawlet.shapes.ShapeTool
anchorX, anchorY
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.ConstructionTool
figure
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.CanvasTool
canvas
 
Constructor Summary
LineTool(DrawingCanvas canvas)
          Constructs and initializes a new instance of a tool to create lines on a DrawingCanvas
 
Method Summary
protected  Figure basicNewFigure(int x, int y)
          Create and answer a new Figure.
 void mouseDragged(java.awt.event.MouseEvent e)
          Called if the mouse is dragged (the mouse button is down and mouse is moving).
 void mouseMoved(java.awt.event.MouseEvent e)
          Called if the mouse moves (when the mouse button is up).
 void mouseReleased(java.awt.event.MouseEvent e)
          Called if the mouse is released.
protected  void movePoint(int pointIndex, int x, int y)
          Move the identified point of the line.
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.ShapeTool
mousePressed
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.ConstructionTool
newFigure, setProperties
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.CanvasTool
getX, getY
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
keyPressed, keyReleased, keyTyped, mouseClicked, mouseDoubleClicked, mouseEntered, mouseExited, mouseSingleClicked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineTool

public LineTool(DrawingCanvas canvas)
Constructs and initializes a new instance of a tool to create lines on a DrawingCanvas
Parameters:
canvas - the canvas on which to place lines.
Method Detail

basicNewFigure

protected Figure basicNewFigure(int x,
                                int y)
Create and answer a new Figure.
Overrides:
basicNewFigure in class ConstructionTool
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
a newly created Figure

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Called if the mouse is dragged (the mouse button is down and mouse is moving). If we are constructing a line, move its last locator as indicated.
Overrides:
mouseDragged in class ConstructionTool
Parameters:
e - the event

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Called if the mouse moves (when the mouse button is up). If we are constructing a line, move its last locator as indicated. When done, consume the event.
Overrides:
mouseMoved in class AbstractInputEventHandler
Parameters:
e - the event

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Called if the mouse is released. If we are constructing a line, and the shift key is down, add another point. Otherwise, we're done constructing this one... get ready for the next one.
Overrides:
mouseReleased in class ShapeTool
Parameters:
e - the event

movePoint

protected void movePoint(int pointIndex,
                         int x,
                         int y)
Move the identified point of the line. Assumes that pointIndex is a valid point in the current line being edited.
Parameters:
pointIndex - the index of the point to move.
x - the x coordinate.
y - the y coordinate.