com.rolemodelsoft.drawlet.shapes.polygons
Class AnySidedPolygonTool
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.polygons.AnySidedPolygonTool
- public class AnySidedPolygonTool
- extends ShapeTool
This tool produces PolygonShapes with a variable number of sides.
|
Method Summary |
protected Figure |
basicNewFigure(int x,
int y)
Create and answer a new Figure. |
protected int |
defaultNumberOfSides()
Answer the default/initial number of sides. |
protected void |
mouseDoubleClicked(java.awt.event.MouseEvent e)
Called when the mouse is double-clicked. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Called if the mouse is dragged (moved with the mouse button down). |
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 goes up. |
protected void |
movePoint(int pointIndex,
int x,
int y)
Move the identified point of the polygon. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
AnySidedPolygonTool
public AnySidedPolygonTool(DrawingCanvas canvas)
- Constructs and initializes a new instance of a tool to create polygons
on a DrawingCanvas
- Parameters:
canvas - the canvas on which to place PolygonFigures.
basicNewFigure
protected Figure basicNewFigure(int x,
int y)
- Create and answer a new Figure.
- Overrides:
- basicNewFigure in class ConstructionTool
- Parameters:
x - the x coordinatey - the y coordinate- Returns:
- a newly created Figure
defaultNumberOfSides
protected int defaultNumberOfSides()
- Answer the default/initial number of sides.
- Returns:
- an integer representing the default/initial number of sides.
mouseDoubleClicked
protected void mouseDoubleClicked(java.awt.event.MouseEvent e)
- Called when the mouse is double-clicked.
- Overrides:
- mouseDoubleClicked in class AbstractInputEventHandler
- Parameters:
e - the MouseEvent to handle.
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Called if the mouse is dragged (moved with the mouse button down).
If we are constructing a polygon, move its last point as indicated,
and consume the event.
- 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 polygon, move its last point as indicated.
- Overrides:
- mouseMoved in class AbstractInputEventHandler
- Parameters:
e - the event
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Called if the mouse goes up.
- 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 polygon.
Assumes that pointIndex is a valid point in the current polygon being edited
- Parameters:
pointIndex - the index of the point to move.x - the x coordinate.y - the y coordinate.