UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.satin.command
Class CommandImpl

java.lang.Object
  |
  +--edu.berkeley.guir.lib.satin.command.CommandImpl
All Implemented Interfaces:
Command, SatinConstants, Serializable, UndoableEdit
Direct Known Subclasses:
AddGestureInterpreterCommand, AddInkInterpreterCommand, ApplyTransformationCommand, CopyCommand, DeleteCommand, InsertCommand, MacroCommand, MoveCommand, OpenCommand, PasteCommand, RemoveCommand, SaveCommand, SelectCommand, SetLocationCommand, SetTransformCommand, UndoableCommand

public abstract class CommandImpl
extends Object
implements Command, Serializable

A simple implementation of Command.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, Jun 22 1999, JH
               Created class
             - SATIN-v1.0-1.1.0, Dec 09 1999, JH
               Updated CommandImpl for SATINv2.
               Modified the enable/disable to be a counting semaphore.
               Renamed doit() to run().
               Made commands that can execute() themselves.
             - SATIN-v2.1-1.0.0, Aug 11 2000, JH
               Touched for SATIN release
 

Since:
JDK 1.2
Version:
SATIN-v2.1-1.0.0, Aug 11 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu )
See Also:
Serialized Form

Inner classes inherited from class edu.berkeley.guir.lib.satin.SatinConstants
SatinConstants.ObjectPoolAffineTransform, SatinConstants.ObjectPoolPoint2D, SatinConstants.ObjectPoolPolygon2D, SatinConstants.ObjectPoolRectangle2D, SatinConstants.ObjectPoolStringBuffer, SatinConstants.UniqueAffineTransform, SatinConstants.UniquePoint2D, SatinConstants.UniquePolygon2D, SatinConstants.UniqueRectangle2D
 
Fields inherited from interface edu.berkeley.guir.lib.satin.SatinConstants
ABOVE, ALL, BAR, BELOW, clipboard, clprops, cmdqueue, cmdsubsys, CONTAINEDBY, CONTAINS, COORD_ABS, COORD_LOCAL, COORD_REL, DAMAGE_LATER, DAMAGE_NOW, DEBUG_GRAPHICS_OFFSET, DEBUG_STYLE_FILE, DEBUG_STYLE_GPROPERTY, DEEP, DEFAULT_POINT2D_POOL_SIZE, DEFAULT_POLYGON2D_POOL_SIZE, DEFAULT_RECTANGLE_POOL_SIZE, DEFAULT_REPAINT_THRESHOLD, DEFAULT_SELECT_THRESHOLD, DEFAULT_STRINGBUFFER_POOL_SIZE, DEFAULT_TRANSFORM_POOL_SIZE, DIR_CENTER, DIR_DOWN, DIR_DOWN_LEFT, DIR_DOWN_RIGHT, DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_UP_LEFT, DIR_UP_RIGHT, FILTER_THRESHOLD, FIRST, FLOATING_PT_TOLERANCE, glprops, INTERSECTS, KEY_STYLE_DASHARRAY, KEY_STYLE_DASHPHASE, KEY_STYLE_DRAWCOLOR, KEY_STYLE_DRAWFONT, KEY_STYLE_DRAWTRANSPARENCY, KEY_STYLE_ENDCAP, KEY_STYLE_FILLCOLOR, KEY_STYLE_FILLTRANSPARENCY, KEY_STYLE_LINEJOIN, KEY_STYLE_LINEWIDTH, KEY_STYLE_MITERLIMIT, NEAR, NOTIFY_BOUNDS, NOTIFY_LAYER, NOTIFY_LOCATION, NOTIFY_STYLE, NOTIFY_TRANSFORM, poolPoints, poolPolys, poolRects, poolStrbuf, poolTx, rand, SATIN_DATA_DIRECTORY_DEFAULT, SATIN_DATA_DIRECTORY_GPROPERTY, SATIN_PROPERTIES_FILENAME, SHALLOW
 
Constructor Summary
CommandImpl()
           
 
Method Summary
 boolean addEdit(UndoableEdit anEdit)
           
 boolean canRedo()
          Override this method in the subclass.
 boolean canUndo()
          Override this method in the subclass.
static String debug()
           
 void die()
          Override this method in the subclass.
 void disable()
          This method is implemented for all subclasses in the superclass.
 void enable()
          This method is implemented for all subclasses in the superclass.
 void execute()
          Checks if the command is enabled or not, and executes the command if it is enabled, setting the execution time in the process.
 long getExecutionTime()
          Get the system time this command was first executed.
 String getPresentationName()
          Override this method in the subclass.
 String getRedoPresentationName()
          You don't have to override this method in the subclass.
 String getUndoPresentationName()
          You don't have to override this method in the subclass.
 boolean isDisabled()
          This method is implemented for all subclasses in the superclass.
 boolean isEnabled()
          This method is implemented for all subclasses in the superclass.
 boolean isSignificant()
          Override this method in the subclass.
 void redo()
          Override this method in the subclass.
 boolean replaceEdit(UndoableEdit anEdit)
           
protected abstract  void run()
          This method is called by execute() if the command is enabled.
 void setExecutionTime()
          Set the time this command was executed to the current time.
 void setExecutionTime(long l)
          Set the time this command was executed to the specified time.
 String toString()
           
 void undo()
          Override this method in the subclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandImpl

public CommandImpl()
Method Detail

isEnabled

public final boolean isEnabled()
This method is implemented for all subclasses in the superclass.
Specified by:
isEnabled in interface Command
Following copied from interface: edu.berkeley.guir.lib.satin.command.Command
Returns:
true if the command can be executed, false otherwise.

isDisabled

public final boolean isDisabled()
This method is implemented for all subclasses in the superclass.
Specified by:
isDisabled in interface Command
Following copied from interface: edu.berkeley.guir.lib.satin.command.Command
Returns:
true if the command can not be executed, false otherwise.

enable

public void enable()
This method is implemented for all subclasses in the superclass.
Specified by:
enable in interface Command

disable

public void disable()
This method is implemented for all subclasses in the superclass.
Specified by:
disable in interface Command

addEdit

public boolean addEdit(UndoableEdit anEdit)
Specified by:
addEdit in interface UndoableEdit

replaceEdit

public boolean replaceEdit(UndoableEdit anEdit)
Specified by:
replaceEdit in interface UndoableEdit

setExecutionTime

public void setExecutionTime()
Description copied from interface: Command
Set the time this command was executed to the current time.
Specified by:
setExecutionTime in interface Command

setExecutionTime

public void setExecutionTime(long l)
Description copied from interface: Command
Set the time this command was executed to the specified time.
Specified by:
setExecutionTime in interface Command
Following copied from interface: edu.berkeley.guir.lib.satin.command.Command
Parameters:
l - is the time to set the execution time to.

getExecutionTime

public long getExecutionTime()
Description copied from interface: Command
Get the system time this command was first executed.
Specified by:
getExecutionTime in interface Command
Following copied from interface: edu.berkeley.guir.lib.satin.command.Command
Returns:
a long representing time in ms. Just normal Java time.

getPresentationName

public String getPresentationName()
Override this method in the subclass.
Specified by:
getPresentationName in interface UndoableEdit

getRedoPresentationName

public String getRedoPresentationName()
You don't have to override this method in the subclass.
Specified by:
getRedoPresentationName in interface UndoableEdit

getUndoPresentationName

public String getUndoPresentationName()
You don't have to override this method in the subclass.
Specified by:
getUndoPresentationName in interface UndoableEdit

canRedo

public boolean canRedo()
Override this method in the subclass. By default, returns false.
Specified by:
canRedo in interface UndoableEdit

canUndo

public boolean canUndo()
Override this method in the subclass. By default, returns false.
Specified by:
canUndo in interface UndoableEdit

isSignificant

public boolean isSignificant()
Override this method in the subclass. By default, returns false.
Specified by:
isSignificant in interface UndoableEdit

redo

public void redo()
Override this method in the subclass.
Specified by:
redo in interface UndoableEdit

undo

public void undo()
Override this method in the subclass.
Specified by:
undo in interface UndoableEdit

die

public void die()
Override this method in the subclass.
Specified by:
die in interface UndoableEdit

execute

public final void execute()
Checks if the command is enabled or not, and executes the command if it is enabled, setting the execution time in the process. Executes command by calling run(). Override run(), not this method, in your subclass.
Specified by:
execute in interface Command
See Also:
Command.execute()

run

protected abstract void run()
This method is called by execute() if the command is enabled. You should override this method in your subclass to do the dirty work.

toString

public String toString()
Overrides:
toString in class Object

debug

public static String debug()

Copyright Information