|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.commands.Command
the empty, do-nothing, jfig editing command.
Command: To avoid a single, monolithic editor architecture, all editing functionality of the jfig graphics editor is provided by small, standalone editor 'command' objects, organized into a class hierarchy of command classes in package jfig.commands. This class, Command, is the base class of all these command classes and models an empty, do-nothing, all-time-ready, command.
Field Summary | |
protected FigBasicEditor |
editor
|
protected FigCanvas |
objectCanvas
|
protected boolean |
ready
|
Constructor Summary | |
Command(FigBasicEditor editor,
FigCanvas objectCanvas)
create an empty (idle, do-nothing) Command object |
Method Summary | |
void |
cancel()
cancel the current editor command |
void |
execute()
execute the current editor command |
java.lang.String |
getDescription()
one-line description of this command |
FigObject[] |
getModifiedObjects()
return an array of all objects modified by this Command. |
boolean |
isReady()
check whether this command is completed/ready, or not |
void |
message(java.lang.String msg)
print a (possibly long) message |
void |
mousePressed(FigCanvasEvent evt)
react to a mouse click on the editor canvas |
void |
notifyEditor()
provide a callback from commands to their editor. |
void |
statusMessage(java.lang.String msg)
print a status message, typically a short one-line message |
java.lang.String |
toString()
return a (possibly verbose) description of this Command object |
void |
undo()
undo this command |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected FigCanvas objectCanvas
protected FigBasicEditor editor
protected boolean ready
Constructor Detail |
public Command(FigBasicEditor editor, FigCanvas objectCanvas)
A new idle Command for 'editor', display on 'objectCanvas'. Note that the idle Command is always ready.
Method Detail |
public void cancel()
cancel and cleanup the current command. Note that this method is empty for class Command, but might be implemented by subclasses.
public void execute()
This method is empty for class Command.
public void undo()
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.
public void mousePressed(FigCanvasEvent evt)
This method provides the central callback from the editor to its current command object. Passing a FigCanvasEvent parameter, the editor provides information both about the screen coordinates and the world coordinates of the mouse event.
Naturally, mouse presses are ignored for class Command.
public boolean isReady()
public void notifyEditor()
This method serves as a callback from command objects to their editor. Because each command object is used for one single and atomic editing operation only, the editor has to create a new command once the previous command has execute()d. This is achieved by calling notifyEditor() from within a command, once the command has executed and is ready. The typical use is to implement the xfig-style editor modes, e.g. to create a new CopyCommand directly after the previous CopyCommand has finished.
public FigObject[] getModifiedObjects()
public void statusMessage(java.lang.String msg)
public void message(java.lang.String msg)
public java.lang.String getDescription()
return a one-line desription of this command, e.g. to label the undo/redo buttons, if any
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |