jfig.commands
Class Command

java.lang.Object
  extended byjfig.commands.Command
Direct Known Subclasses:
AlignObjectsCommand, BreakCompoundCommand, ConvertObjectCommand, CopyObjectCommand, CopyToClipboardCommand, CreateArcCommand, CreateBezierCommand, CreateBulletCommand, CreateCircleCommand, CreateClosedBezierCommand, CreateClosedSplineCommand, CreateCompoundCommand, CreateDimensioningCommand, CreateEllipseCommand, CreateFreehandCommand, CreateImageCommand, CreatePolygonCommand, CreatePolylineCommand, CreateRectangleCommand, CreateRoundedRectangleCommand, CreateSplineCommand, CreateTextCommand, CreateTriggerCommand, CutPointCommand, CutToClipboardCommand, DeleteObjectCommand, EditCommentCommand, EditObjectCommand, InsertPointCommand, JCreateImageCommand, JEditObjectCommand, JoinSplitLinesCommand, JOpenCompoundCommand, MirrorXCommand, MirrorYCommand, MoveObjectCommand, MovePointCommand, OpenCompoundCommand, PasteFromClipboardCommand, ResizeTextCommand, RotateObjectCommand, ScaleObjectCommand, SelectLibraryObjectCommand, SnapToGridCommand, UpdateCommand, ZoomRegionCommand

public class Command
extends java.lang.Object

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

objectCanvas

protected FigCanvas objectCanvas

editor

protected FigBasicEditor editor

ready

protected boolean ready
Constructor Detail

Command

public Command(FigBasicEditor editor,
               FigCanvas objectCanvas)
create an empty (idle, do-nothing) Command object

A new idle Command for 'editor', display on 'objectCanvas'. Note that the idle Command is always ready.

Method Detail

cancel

public void cancel()
cancel the current editor command

cancel and cleanup the current command. Note that this method is empty for class Command, but might be implemented by subclasses.


execute

public void execute()
execute the current editor command

This method is empty for class Command.


undo

public void undo()
undo this 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.


mousePressed

public void mousePressed(FigCanvasEvent evt)
react to a mouse click on the editor canvas

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.


isReady

public boolean isReady()
check whether this command is completed/ready, or not


notifyEditor

public void notifyEditor()
provide a callback from commands to their editor.

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.


getModifiedObjects

public FigObject[] getModifiedObjects()
return an array of all objects modified by this Command. This may return null or an array of length null.


statusMessage

public void statusMessage(java.lang.String msg)
print a status message, typically a short one-line message


message

public void message(java.lang.String msg)
print a (possibly long) message


getDescription

public 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


toString

public java.lang.String toString()
return a (possibly verbose) description of this Command object