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

edu.berkeley.guir.lib.satin.stroke
Class StrokeAssembler

java.lang.Object
  |
  +--edu.berkeley.guir.lib.satin.stroke.StrokeAssembler
All Implemented Interfaces:
Cloneable, EventListener, MouseListener, MouseMotionListener, SatinConstants, Serializable, Watcher

public class StrokeAssembler
extends Object
implements SatinConstants, Serializable, Cloneable, MouseListener, MouseMotionListener, Watcher

Accumulates mouse events and creates Stroke objects. Through an ingenious hack [tm], this StrokeAssembler is always the last MouseListener to receive an event. Furthermore, it ignores consumed events (ie AWTEvent.consume()). So, if you get mouse events and don't want others to use the event, then just consume it.

There should only be one instance of this class per Sheet.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, Oct 09 1998, JH
               Created class
             - SATIN-v2.1-1.0.0, Aug 11 2000, JH
               Touched for SATIN release
             - SATIN-v2.1-1.0.1, Oct 30 2000, JH
               Fixed some problems with auto-pan
               Fixed a bug with bounds (auto-pan at wrong places)
               Modified auto-pan to work only if pen moved outside sheet bds
 

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
StrokeAssembler(Sheet parent)
          Constructor.
 
Method Summary
 Object clone()
          A happy clone we are.
 boolean isEnabled()
          Check whether we are creating strokes or not.
 boolean isLeftButtonAccepted()
           
 boolean isMiddleButtonAccepted()
           
 boolean isRightButtonAccepted()
           
 void mouseClicked(MouseEvent evt)
           
 void mouseDragged(MouseEvent evt)
          Handle mouse dragged with button down.
 void mouseEntered(MouseEvent evt)
           
 void mouseExited(MouseEvent evt)
           
 void mouseMoved(MouseEvent evt)
           
 void mousePressed(MouseEvent evt)
          Handle mouse button first pressed.
 void mouseReleased(MouseEvent evt)
          Handle release of mouse button.
 void onDelete(Watchable w)
          Callback method for notifications of deletions, that is this Graphical Object has been deleted and you should remove it.
 void onNotify(Watchable w, Object arg)
          Callback method for generic notifications.
 void onRepaint(GraphicalObject gob)
           
 void onRepaint(Rectangle rect)
           
 void onUpdate(Watchable w, Object arg)
          Callback method for notifications.
 void onUpdate(Watchable w, String strProperty, Object oldVal, Object newVal)
          Update on transforms by the Sheet, so we can apply strokes correctly.
 void setAcceptLeftButton(boolean flag)
           
 void setAcceptMiddleButton(boolean flag)
           
 void setAcceptRightButton(boolean flag)
           
 void setAutoScroll(boolean flag)
          Set whether auto scroll when drawing is enabled or not.
 void setEnabled(boolean flag)
          Set whether we should be creating strokes or not.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrokeAssembler

public StrokeAssembler(Sheet parent)
Constructor. Automatically makes ourself a mouse Interpreter and mouse motion Interpreter for the parent.
Parameters:
parent - is the Sheet component that holds this object.
Method Detail

setEnabled

public void setEnabled(boolean flag)
Set whether we should be creating strokes or not.

isEnabled

public boolean isEnabled()
Check whether we are creating strokes or not.

isLeftButtonAccepted

public boolean isLeftButtonAccepted()

isMiddleButtonAccepted

public boolean isMiddleButtonAccepted()

isRightButtonAccepted

public boolean isRightButtonAccepted()

setAcceptLeftButton

public void setAcceptLeftButton(boolean flag)

setAcceptMiddleButton

public void setAcceptMiddleButton(boolean flag)

setAcceptRightButton

public void setAcceptRightButton(boolean flag)

setAutoScroll

public void setAutoScroll(boolean flag)
Set whether auto scroll when drawing is enabled or not.

mouseClicked

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

mouseEntered

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

mouseExited

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

mouseMoved

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

mousePressed

public final void mousePressed(MouseEvent evt)
Handle mouse button first pressed. Creates a new Stroke object with initial position at start position.
Specified by:
mousePressed in interface MouseListener

mouseDragged

public final void mouseDragged(MouseEvent evt)
Handle mouse dragged with button down. Adds current position to existing Stroke object before sending updates to any Progressive Interpreters.
Specified by:
mouseDragged in interface MouseMotionListener

mouseReleased

public void mouseReleased(MouseEvent evt)
Handle release of mouse button. Adds final position to existing Stroke object before sending updates to any Full-Stroke Interpreters.
Specified by:
mouseReleased in interface MouseListener

onNotify

public void onNotify(Watchable w,
                     Object arg)
Description copied from interface: Watcher
Callback method for generic notifications. This typically won't be used.
Specified by:
onNotify in interface Watcher
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watcher
Parameters:
w - is the Watchable object notifying you.
arg - is some agreed upon argument.
See Also:
Watchable.notifyWatchers(), Watchable.notifyWatchers(java.lang.Object)

onUpdate

public void onUpdate(Watchable w,
                     Object arg)
Description copied from interface: Watcher
Callback method for notifications.
Specified by:
onUpdate in interface Watcher
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watcher
Parameters:
w - is the Watchable object that has been updated.
arg - is some agreed upon argument.
See Also:
Watchable.notifyWatchersUpdate(Object)

onUpdate

public void onUpdate(Watchable w,
                     String strProperty,
                     Object oldVal,
                     Object newVal)
Update on transforms by the Sheet, so we can apply strokes correctly.
Specified by:
onUpdate in interface Watcher
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watcher
Parameters:
w - is the Watchable object that has been updated.
strProperty - is the name of the property to update.
oldVal - is the old value of the property. This should usually be a clone of the old value, so that modifying this value should have no effect. Whether this is a copy or a reference should be defined in the SatinConstants file.
newVal - is the new value of the property. This should usually be a clone of the old value, so that modifying this value should have no effect. However, don't clone if it is prohibitively expensive to do so. Whether this is a copy or a reference should be defined in the SatinConstants file.
See Also:
SatinConstants, Watchable.notifyWatchersUpdate(String, Object, Object)

onRepaint

public void onRepaint(GraphicalObject gob)

onRepaint

public void onRepaint(Rectangle rect)

onDelete

public void onDelete(Watchable w)
Description copied from interface: Watcher
Callback method for notifications of deletions, that is this Graphical Object has been deleted and you should remove it.
Specified by:
onDelete in interface Watcher
Following copied from interface: edu.berkeley.guir.lib.satin.watch.Watcher
Parameters:
w - is the Watchable object to be deleted.
See Also:
Watchable.notifyWatchersDelete()

clone

public Object clone()
Description copied from interface: Watcher
A happy clone we are.
Specified by:
clone in interface Watcher
Overrides:
clone in class Object

Copyright Information