|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfig.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 This method is empty for class Command. |
java.lang.String |
getDescription()
one-line description of this command return a one-line desription of this command, e.g. to label the undo/redo buttons, if any |
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 Try to undo this command as far as possible. |
| 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 Commandpublic void execute()
CommandThis method is empty for class Command.
execute in class Commandpublic void undo()
CommandTry 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 Commandpublic 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 Commandpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenerpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic java.lang.String getDescription()
Commandreturn a one-line desription of this command, e.g. to label the undo/redo buttons, if any
getDescription in class Commandpublic 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 | |||||||||