|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.commands.Command jfig.commands.CreateFreehandCommand
create an open freehand line via mouse dragging.
CreateFreehandCommand allows the user to create a freehand line. Click the "left" mouse button at the line start point, then hold the mouse button and drag the mouse to draw the line. Releasing the left button finished the line. The final line is stored as a standard FIG polyline, and can later be modified via all FIG line editing commands.
Note that this semantics means that you cannot use the "right" button to immediately cancel a CreateFreehandCommand (use the "undo" command instead).
Note that the freehand line stores and uses all intermediate mouse positions - no optimizations are applied to reduce the number of points. Therefore, using very large freehand lines may incur performance problems.
This command class uses its own internal MouseMotionListener to handle redrawing via mouse dragging.
Field Summary | |
protected int |
n_points
|
protected FigPolyline |
polyline
|
Fields inherited from class jfig.commands.Command |
editor, objectCanvas, ready |
Constructor Summary | |
CreateFreehandCommand(FigBasicEditor editor,
FigCanvas objectCanvas)
|
Method Summary | |
void |
execute()
execute the current editor command |
java.lang.String |
getDescription()
one-line description of this command |
FigObject[] |
getModifiedObjects()
return an array-wrapped reference to the freehand line object created by this command. |
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
mousePressed(FigCanvasEvent evt)
mousePressed: create a new freehand line object and add points to it. |
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
java.lang.String |
toString()
return a (possibly verbose) description of this Command object |
void |
undo()
undo this command |
Methods inherited from class jfig.commands.Command |
cancel, isReady, message, notifyEditor, statusMessage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int n_points
protected FigPolyline polyline
Constructor Detail |
public CreateFreehandCommand(FigBasicEditor editor, FigCanvas objectCanvas)
Method Detail |
public FigObject[] getModifiedObjects()
getModifiedObjects
in class Command
public void execute()
Command
This method is empty for class Command.
execute
in class Command
public void undo()
Command
Try to undo this command as far as possible. Don't try to undo() a command that has never been execute()d before. This method is empty for class Command.
undo
in class Command
public void mousePressed(FigCanvasEvent evt)
Note: Unlike all other xfig/jfig commands, CreateFreehandCommand needs to react to mouse-movements, not to clicks only. Therefore, on the first mouse-click, we register this command object as a MouseMotionListener with the objectCanvas. Once we detect a mouseReleased event, we finish this command and create the final polyline object.
mousePressed
in class Command
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public java.lang.String getDescription()
Command
return a one-line desription of this command, e.g. to label the undo/redo buttons, if any
getDescription
in class Command
public java.lang.String toString()
Command
toString
in class Command
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |