com.rolemodelsoft.drawlet.shapes.polygons
Class PolygonPointHandle
java.lang.Object
|
+--com.rolemodelsoft.drawlet.basics.AbstractInputEventHandler
|
+--com.rolemodelsoft.drawlet.basics.CanvasHandle
|
+--com.rolemodelsoft.drawlet.basics.SquareCanvasHandle
|
+--com.rolemodelsoft.drawlet.shapes.polygons.PolygonPointHandle
- public class PolygonPointHandle
- extends SquareCanvasHandle
- implements FigureHolder
This class provides a handle that shows up at a particular Locator on a
PolygonFigure and reshapes the figure accordingly as it is dragged.
If the first and last point of the polygon are the same, it moves them both.
|
Field Summary |
protected PolygonFigure |
figure
The figure to which the handle is attached. |
protected int |
index
The index of the point (vertex) we manipulate. |
|
Constructor Summary |
PolygonPointHandle(PolygonFigure figure,
int index)
Constructs and initializes a new instance of a handle which can
affect the the position of a particular point defining a polygon. |
|
Method Summary |
int |
centerX()
Answer the x coordinate at the center of the handle. |
int |
centerY()
Answer the y coordinate at the center of the handle. |
Figure |
getFigure()
Returns the Figure associated with this handle. |
void |
mouseDragged(java.awt.event.MouseEvent evt)
Called if the mouse is dragged (moved with the mouse button down). |
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.CanvasHandle |
contains,
defaultHandleSize,
finished,
getHandleHeight,
getHandleSize,
getHandleWidth,
getX,
getY,
intersects,
mouseReleased,
releaseControl,
setHandleSize,
takeControl |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
figure
protected PolygonFigure figure
- The figure to which the handle is attached.
index
protected int index
- The index of the point (vertex) we manipulate.
PolygonPointHandle
public PolygonPointHandle(PolygonFigure figure,
int index)
- Constructs and initializes a new instance of a handle which can
affect the the position of a particular point defining a polygon.
- Parameters:
figure - the figure whose point (vertex) we may wish to move.index - the identifying index of the point of interest
centerX
public 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
public int centerY()
- Answer the y coordinate at the center of the handle.
- Overrides:
- centerY in class SquareCanvasHandle
- Returns:
- an integer representing the y coordinate at the center of the handle.
getFigure
public Figure getFigure()
- Returns 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 (moved with the mouse button down).
Move the particular point of the polygon accordingly.
- Overrides:
- mouseDragged in class AbstractInputEventHandler
- Parameters:
evt - the event- See Also:
move(int, int)
move
public void move(int x,
int y)
- Reshape the figure by moving the corresponding point
and cleanly repaint the canvas.
- Parameters:
x - an integer representing the x coordinate to move to.y - an integer representing the y coordinate to move to.
setFigure
public void setFigure(Figure newFigure)
- Set the figure the receiver is holding.
Note: in this case, it must be a PolygonFigure.
- Specified by:
- setFigure in interface FigureHolder
- Parameters:
newFigure - the new PolygonFigure to affect.- Throws:
- java.lang.IllegalArgumentException - If the figure is not a PolygonFigure.