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

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

java.lang.Object
  |
  +--edu.berkeley.guir.lib.satin.watch.WatchableImpl
        |
        +--edu.berkeley.guir.lib.satin.command.CommandSubsystem
All Implemented Interfaces:
Cloneable, EventListener, MouseListener, MouseMotionListener, SatinConstants, Serializable, Watchable

public class CommandSubsystem
extends WatchableImpl
implements SatinConstants, MouseListener, MouseMotionListener

Command central for commands. All necessary values and references to objects should be obtainable through here. Everything in the command package should be able to access everything in this class. This class simply decouples the command package from everything else.

Some of the useful things the CommandSubsystem does include:

The reason this is a Watchable object is that the system needs to know what objects are selected in order to render correctly. If these objects change, the system also needs to know that. Hence, this class is Watchable.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, Apr 03 1999, JH
               Created class
             - SATIN-v1.0-1.0.1, Jun 28 2000, JH
               Added JavaBeans notification messages (PropertyChange).
             - 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
 
Field Summary
static String SELECTED_ADDED
          Message sent when an item is selected.
static String SELECTED_REMOVED
          Message sent when an item is de-selected.
 
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
CommandSubsystem()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addPropertyChangeListener(String strPropertyName, PropertyChangeListener l)
           
 void addSelected(GraphicalObject gob)
          Add the specified GraphicalObject to the selected list if it is not already (can only be in the list at most once).
 void addSelected(Iterator it)
          Add the GraphicalObjects in the iterator to the selected list.
 void clearSelected()
          Clear out the list of selected objects.
 Point getAbsoluteLastLocation()
          Get the last mouse location clicked.
 Point getAbsoluteLastLocation(Point pt)
          Get the last mouse location clicked.
 int getAbsoluteLastXLocation()
          Get the last mouse x-location clicked.
 int getAbsoluteLastYLocation()
          Get the last mouse y-location clicked.
 GraphicalObject getLastGraphicalObject()
          Get the last Graphical Object added by InsertCommand.
 Point getLocalLastLocation(GraphicalObject gob)
          Get the last mouse location clicked, in the specified GraphicalObject's coordinate system.
 Point getLocalLastLocation(GraphicalObject gob, Point pt)
          Get the last mouse location clicked, in the specified GraphicalObject's coordinate system.
 int getLocalLastXLocation(GraphicalObject gob)
          Get the last mouse x-location clicked, in the specified GraphicalObject's coordinate system.
 int getLocalLastYLocation(GraphicalObject gob)
          Get the last mouse y-location clicked, in the specified GraphicalObject's coordinate system.
 Iterator getSelected()
          Get a copy of the list of selected Graphical Objects.
 GraphicalObjectCollection getSelectedCollection()
          Returns a reference to the actual collection of selected objects.
 void initializeCommandSubsystem(Sheet newSheet)
           
 boolean isSelected(GraphicalObject gob)
           
 void mouseClicked(MouseEvent evt)
          Keep track of where the mouse is in the Sheet.
 void mouseDragged(MouseEvent evt)
           
 void mouseEntered(MouseEvent evt)
           
 void mouseExited(MouseEvent evt)
           
 void mouseMoved(MouseEvent evt)
           
 void mousePressed(MouseEvent evt)
          Keep track of where the mouse is in the Sheet.
 void mouseReleased(MouseEvent evt)
          Keep track of where the mouse is in the Sheet.
 void postEvent(AWTEvent evt)
          Throw an event into the System event queue.
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void removePropertyChangeListener(String strPropertyName, PropertyChangeListener l)
           
 void removeSelected(GraphicalObject gob)
          Remove the specified Graphical Object from the selected list.
 void setLastGraphicalObject(GraphicalObject gob)
          Set the last Graphical Object added.
 void setSelected(GraphicalObjectCollection g)
          Set the list of selected objects.
 String toString()
           
 
Methods inherited from class edu.berkeley.guir.lib.satin.watch.WatchableImpl
addWatcher, clearWatchers, clone, countWatchers, disableNotify, enableNotify, hasNotifyEnabled, notifyWatchers, notifyWatchers, notifyWatchers, notifyWatchers, notifyWatchersDelete, notifyWatchersDelete, notifyWatchersUpdate, notifyWatchersUpdate, notifyWatchersUpdate, notifyWatchersUpdate, notifyWatchersUpdate, removeWatcher
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECTED_ADDED

public static final String SELECTED_ADDED
Message sent when an item is selected. Old: Null. New: GraphicalObject selected.

SELECTED_REMOVED

public static final String SELECTED_REMOVED
Message sent when an item is de-selected. Old: GraphicalObject deselected. New: Null
Constructor Detail

CommandSubsystem

public CommandSubsystem()
Method Detail

initializeCommandSubsystem

public void initializeCommandSubsystem(Sheet newSheet)

mouseClicked

public void mouseClicked(MouseEvent evt)
Keep track of where the mouse is in the Sheet.
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent evt)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent evt)
Specified by:
mouseExited in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent evt)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent evt)
Specified by:
mouseMoved in interface MouseMotionListener

mousePressed

public void mousePressed(MouseEvent evt)
Keep track of where the mouse is in the Sheet.
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent evt)
Keep track of where the mouse is in the Sheet.
Specified by:
mouseReleased in interface MouseListener

postEvent

public void postEvent(AWTEvent evt)
Throw an event into the System event queue. This allows Satin to activate widgets.

isSelected

public boolean isSelected(GraphicalObject gob)

setSelected

public void setSelected(GraphicalObjectCollection g)
Set the list of selected objects.
Parameters:
g - is the collection of Graphical Objects to set to.

clearSelected

public void clearSelected()
Clear out the list of selected objects.

removeSelected

public void removeSelected(GraphicalObject gob)
Remove the specified Graphical Object from the selected list.
Parameters:
gob - is the Graphical Object to remove from the selected list.

addSelected

public void addSelected(GraphicalObject gob)
Add the specified GraphicalObject to the selected list if it is not already (can only be in the list at most once).
Parameters:
gob - is the Graphical Object to add to the selected list.

addSelected

public void addSelected(Iterator it)
Add the GraphicalObjects in the iterator to the selected list.

getSelected

public Iterator getSelected()
Get a copy of the list of selected Graphical Objects. Modify the copy to your heart's content.
Returns:
a Graphical Object Collection.

getSelectedCollection

public GraphicalObjectCollection getSelectedCollection()
Returns a reference to the actual collection of selected objects. Be careful, as any modifications to this collection will modify the list of selected objects. Furthermore, be aware that cloning this list will increase the number of watchers for each of the contained objects.

getAbsoluteLastLocation

public Point getAbsoluteLastLocation()
Get the last mouse location clicked.
Returns:
a Point containing the last x- and y- mouse coordinates clicked.

getAbsoluteLastLocation

public Point getAbsoluteLastLocation(Point pt)
Get the last mouse location clicked.
Parameters:
pt - is the storage space to put the answer in.
Returns:
a Point containing the last x- and y- mouse coordinates clicked.

getAbsoluteLastXLocation

public int getAbsoluteLastXLocation()
Get the last mouse x-location clicked.
Returns:
an int containing the last x- mouse coordinate clicked.

getAbsoluteLastYLocation

public int getAbsoluteLastYLocation()
Get the last mouse y-location clicked.
Returns:
an int containing the last y- mouse coordinate clicked.

getLocalLastLocation

public Point getLocalLastLocation(GraphicalObject gob)
Get the last mouse location clicked, in the specified GraphicalObject's coordinate system.
Parameters:
gob - is the GraphicalObject whose coordinate system we will use.
Returns:
a Point containing the last x- and y- mouse coordinates clicked.

getLocalLastLocation

public Point getLocalLastLocation(GraphicalObject gob,
                                  Point pt)
Get the last mouse location clicked, in the specified GraphicalObject's coordinate system.
Parameters:
gob - is the GraphicalObject whose coordinate system we will use.
pt - is the storage space to put the answer in.
Returns:
a Point containing the last x- and y- mouse coordinates clicked.

getLocalLastXLocation

public int getLocalLastXLocation(GraphicalObject gob)
Get the last mouse x-location clicked, in the specified GraphicalObject's coordinate system.
Parameters:
gob - is the GraphicalObject whose coordinate system we will use.
Returns:
an int containing the last y- mouse coordinate clicked.

getLocalLastYLocation

public int getLocalLastYLocation(GraphicalObject gob)
Get the last mouse y-location clicked, in the specified GraphicalObject's coordinate system.
Parameters:
gob - is the GraphicalObject whose coordinate system we will use.
Returns:
an int containing the last y- mouse coordinate clicked.

setLastGraphicalObject

public void setLastGraphicalObject(GraphicalObject gob)
Set the last Graphical Object added. Used by InsertCommand.
Parameters:
gob - is the last Graphical Object added.

getLastGraphicalObject

public GraphicalObject getLastGraphicalObject()
Get the last Graphical Object added by InsertCommand.
Returns:
the last Graphical Object added.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

addPropertyChangeListener

public void addPropertyChangeListener(String strPropertyName,
                                      PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(String strPropertyName,
                                         PropertyChangeListener l)

toString

public String toString()
Overrides:
toString in class WatchableImpl

Copyright Information