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

edu.berkeley.guir.lib.satin.objects
Class PatchImpl

java.lang.Object
  |
  +--edu.berkeley.guir.lib.satin.objects.GraphicalObjectImpl
        |
        +--edu.berkeley.guir.lib.satin.objects.GraphicalObjectGroupImpl
              |
              +--edu.berkeley.guir.lib.satin.objects.PatchImpl
All Implemented Interfaces:
Cloneable, EventListener, GraphicalObject, GraphicalObjectCollection, GraphicalObjectGroup, Patch, SatinConstants, Serializable, Shape, StrokeListener, Watchable, Watcher
Direct Known Subclasses:
BrainNote, Gate

public class PatchImpl
extends GraphicalObjectGroupImpl
implements Patch

A Graphical Object Group with boundaries, additional kinds of properties and behavior.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, Apr 01 1999, JH
               Created class
             - 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 PATCH_STYLE_FILE
          The name of the file containing the current stroke properties.
 
Fields inherited from interface edu.berkeley.guir.lib.satin.objects.GraphicalObjectGroup
DEFAULT_POS_POLICY, KEEP_ABS_POS, KEEP_REL_POS
 
Fields inherited from interface edu.berkeley.guir.lib.satin.objects.GraphicalObject
GESTUREINTRP_CLPROPERTY, INKINTRP_CLPROPERTY, STYLE_CLPROPERTY, VIEW_CLPROPERTY
 
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
PatchImpl()
           
PatchImpl(Polygon newPoly)
          Make a patch with the specified boundaries.
PatchImpl(Polygon2D newPoly)
          Make a patch with the specified boundaries.
PatchImpl(Rectangle2D r)
           
PatchImpl(Shape s)
          Make a patch with the specified boundaries.
PatchImpl(TimedStroke stk)
          Make a patch with the specified boundaries.
 
Method Summary
 Object clone()
          Clone this object shallowly, copying references to any children this GraphicalObject has.
protected  PatchImpl clone(PatchImpl p)
          For clone chaining purposes.
 Object deepClone()
          Make a deep-clone.
protected  PatchImpl deepClone(PatchImpl newPatch)
          For deep-clone chaining.
protected  void defaultRender(SatinGraphics g)
          The default method for rendering.
 void handleSingleStroke(SingleStrokeEvent evt)
           
 boolean isAddLeftButtonStrokes()
          Returns whether left-button strokes are added.
 boolean isAddMiddleButtonStrokes()
          Returns whether middle-button strokes are added.
 boolean isAddRightButtonStrokes()
          Returns whether right-button strokes are added.
static void main(String[] argv)
           
 void onNotify(Watchable w, Object arg)
          Callback method for generic notifications.
 void onUpdate(Watchable w, Object arg)
          Callback method for notifications.
 void onUpdate(Watchable w, String strProperty, Object oldVal, Object newVal)
          Callback method for notifications.
protected  void renderChildren(SatinGraphics g)
          Renders the children of the patch.
 void setAddLeftButtonStrokes(boolean flag)
          Set whether left-button strokes will be added.
 void setAddMiddleButtonStrokes(boolean flag)
          Set whether middle-button strokes will be added.
 void setAddRightButtonStrokes(boolean flag)
          Set whether right-button strokes will be added.
 void setDrawChildren(boolean flag)
          Set whether we should draw the children or not.
 void setDrawPatch(boolean flag)
          Set whether we should draw the patch border.
 void setFillPatch(boolean flag)
          Set whether we should fill in the patch.
protected  boolean shapeContainsInternal(Point2D pt)
          Internal method.
protected  boolean shapeContainsInternal(Shape s)
          Internal method.
protected  boolean shapeIntersectsInternal(Shape s)
          Internal method.
protected  void updateGroupBounds()
          This method is called by our parent class whenever a Graphical Object is added or removed.
protected  void updateGroupBounds(GraphicalObject gob)
          This method is called by our parent class whenever a Graphical Object is added or removed.
 
Methods inherited from class edu.berkeley.guir.lib.satin.objects.GraphicalObjectGroupImpl
add, add, add, add, addToBack, addToBack, addToFront, addToFront, bringDownALayer, bringDownNLayers, bringToBottomLayer, bringToTopLayer, bringUpALayer, bringUpNLayers, clear, clone, contains, createNewInteractionHandler, deepClone, get, getAbsoluteLayer, getCollectionBounds2D, getCollectionBounds2D, getDispatchee, getFirst, getForwardIterator, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getID, getLast, getRelativeLayer, getReverseIterator, indexOf, isEmpty, notifyWatchersDelete, numElements, onDelete, remove, removeAll, setRelativeLayer, sort, toDebugString
 
Methods inherited from class edu.berkeley.guir.lib.satin.objects.GraphicalObjectImpl
addIndexedProperty, addWatcher, applyTransform, bringDownALayer, bringDownNLayers, bringToBottomLayer, bringToTopLayer, bringUpALayer, bringUpNLayers, clearIndexedProperty, clearWatchers, clone, contains, contains, contains, contains, countWatchers, createNewViewHandler, damage, damage, damage, damage, deepClone, delete, disableDamage, disableNotify, enableDamage, enableNotify, equals, getAbsoluteLayer, getBoundingPoints2D, getBoundingPoints2D, getBoundingPoints2DRef, getBounds, getBounds2D, getBounds2D, getBounds2D, getClassDebugProperty, getClassProperty, getClassPropertyGestureInterpreter, getClassPropertyInkInterpreter, getClassPropertyStyle, getClassPropertyView, getGestureInterpreter, getHeight2D, getIndexedProperty, getIndexedProperty, getInkInterpreter, getInteractionHandler, getInverseTransform, getInverseTransform, getLocalBoundingPoints2DRef, getLocation2D, getLocation2D, getParentGroup, getPathIterator, getPathIterator, getPresentationName, getProperty, getPropertyNames, getRelativeLayer, getSheet, getStyle, getStyleRef, getTransform, getTransform, getTransformRef, getUniqueID, getView, getViewHandler, getWidth2D, handleNewStroke, handleUpdateStroke, hasClosedBoundingPoints, hasDamageEnabled, hasNotifyEnabled, intersects, intersects, isClippedToBounds, isDirty, isSelectable, isVisible, minDistance, minDistance, minLocalDistance, moveBy, moveBy, moveTo, moveTo, notifyWatchers, notifyWatchers, notifyWatchersUpdate, notifyWatchersUpdate, onNewStroke, onSingleStroke, onUpdateStroke, postProcessNewStroke, postProcessSingleStroke, postProcessUpdateStroke, preProcessNewStroke, preProcessSingleStroke, preProcessUpdateStroke, redispatchNewStroke, redispatchSingleStroke, redispatchUpdateStroke, removeIndexedProperty, removeIndexedProperty, removeProperty, removeWatcher, render, renderAllCoordBounds, renderBoundingBox, renderDebug, renderDimensions, renderSelected, renderSelectionHandle, setBoundingPoints2D, setClassDebugProperty, setClassProperty, setClassPropertyGestureInterpreter, setClassPropertyInkInterpreter, setClassPropertyStyle, setClassPropertyView, setClipToBounds, setDirty, setGestureInterpreter, setHasClosedBoundingPoints, setIndexedProperty, setInkInterpreter, setInteractionHandler, setLocalBoundingPoints2DRef, setParentGroup, setProperty, setRelativeLayer, setSelectable, setStyle, setTransform, setTransformInternal, setUniqueID, setView, setViewHandler, setVisible, shapeContains, shapeContains, shapeContains, shapeContains, shapeIntersects, shapeIntersects, toString, updateBoundingPoints
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.berkeley.guir.lib.satin.objects.GraphicalObjectGroup
add, add, addToBack, addToFront, bringDownALayer, bringDownNLayers, bringToBottomLayer, bringToTopLayer, bringUpALayer, bringUpNLayers, getAbsoluteLayer, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getGraphicalObjects, getRelativeLayer, removeAll, setRelativeLayer
 
Methods inherited from interface edu.berkeley.guir.lib.satin.objects.GraphicalObject
addIndexedProperty, applyTransform, bringDownALayer, bringDownNLayers, bringToBottomLayer, bringToTopLayer, bringUpALayer, bringUpNLayers, clearIndexedProperty, damage, damage, damage, damage, delete, disableDamage, enableDamage, getAbsoluteLayer, getBoundingPoints2D, getBoundingPoints2D, getBounds2D, getBounds2D, getGestureInterpreter, getHeight2D, getIndexedProperty, getIndexedProperty, getInkInterpreter, getInverseTransform, getInverseTransform, getLocation2D, getLocation2D, getParentGroup, getProperty, getPropertyNames, getRelativeLayer, getSheet, getStyle, getStyleRef, getTransform, getTransform, getTransformRef, getUniqueID, getView, getWidth2D, handleNewStroke, handleUpdateStroke, hasClosedBoundingPoints, hasDamageEnabled, isClippedToBounds, isSelectable, isVisible, minDistance, minDistance, moveBy, moveBy, moveTo, moveTo, onNewStroke, onSingleStroke, onUpdateStroke, postProcessNewStroke, postProcessSingleStroke, postProcessUpdateStroke, preProcessNewStroke, preProcessSingleStroke, preProcessUpdateStroke, redispatchNewStroke, redispatchSingleStroke, redispatchUpdateStroke, removeIndexedProperty, removeIndexedProperty, removeProperty, render, setBoundingPoints2D, setClipToBounds, setGestureInterpreter, setHasClosedBoundingPoints, setIndexedProperty, setInkInterpreter, setParentGroup, setProperty, setRelativeLayer, setSelectable, setStyle, setTransform, setUniqueID, setView, setVisible, shapeContains, shapeContains, shapeContains, shapeContains, shapeIntersects, shapeIntersects
 
Methods inherited from interface edu.berkeley.guir.lib.satin.watch.Watchable
addWatcher, clearWatchers, countWatchers, disableNotify, enableNotify, hasNotifyEnabled, notifyWatchers, notifyWatchers, notifyWatchersDelete, notifyWatchersUpdate, notifyWatchersUpdate, removeWatcher
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, intersects, intersects
 
Methods inherited from interface edu.berkeley.guir.lib.satin.objects.GraphicalObjectCollection
add, add, addToBack, addToFront, clear, contains, get, getCollectionBounds2D, getCollectionBounds2D, getFirst, getForwardIterator, getID, getLast, getReverseIterator, indexOf, isEmpty, numElements, remove, sort
 
Methods inherited from interface edu.berkeley.guir.lib.satin.watch.Watcher
onDelete
 

Field Detail

PATCH_STYLE_FILE

public static final String PATCH_STYLE_FILE
The name of the file containing the current stroke properties.
Constructor Detail

PatchImpl

public PatchImpl()

PatchImpl

public PatchImpl(TimedStroke stk)
Make a patch with the specified boundaries.
Parameters:
stk - represents the boundary of the Patch.

PatchImpl

public PatchImpl(Shape s)
Make a patch with the specified boundaries.
Parameters:
s - is the shape boundary.

PatchImpl

public PatchImpl(Rectangle2D r)

PatchImpl

public PatchImpl(Polygon2D newPoly)
Make a patch with the specified boundaries.
Parameters:
newpoly - is the boundary.

PatchImpl

public PatchImpl(Polygon newPoly)
Make a patch with the specified boundaries.
Parameters:
newpoly - is the boundary.
Method Detail

setAddLeftButtonStrokes

public void setAddLeftButtonStrokes(boolean flag)
Set whether left-button strokes will be added.
Specified by:
setAddLeftButtonStrokes in interface Patch

setAddMiddleButtonStrokes

public void setAddMiddleButtonStrokes(boolean flag)
Set whether middle-button strokes will be added.
Specified by:
setAddMiddleButtonStrokes in interface Patch

setAddRightButtonStrokes

public void setAddRightButtonStrokes(boolean flag)
Set whether right-button strokes will be added.
Specified by:
setAddRightButtonStrokes in interface Patch

isAddLeftButtonStrokes

public boolean isAddLeftButtonStrokes()
Returns whether left-button strokes are added.
Specified by:
isAddLeftButtonStrokes in interface Patch

isAddMiddleButtonStrokes

public boolean isAddMiddleButtonStrokes()
Returns whether middle-button strokes are added.
Specified by:
isAddMiddleButtonStrokes in interface Patch

isAddRightButtonStrokes

public boolean isAddRightButtonStrokes()
Returns whether right-button strokes are added.
Specified by:
isAddRightButtonStrokes in interface Patch

handleSingleStroke

public void handleSingleStroke(SingleStrokeEvent evt)
Specified by:
handleSingleStroke in interface GraphicalObject
Overrides:
handleSingleStroke in class GraphicalObjectImpl
Following copied from interface: edu.berkeley.guir.lib.satin.objects.GraphicalObject
See Also:
GraphicalObject.onNewStroke(NewStrokeEvent)

shapeContainsInternal

protected boolean shapeContainsInternal(Point2D pt)
Description copied from class: GraphicalObjectImpl
Internal method. Assumes pt is already in local coordinates. Override for specific Graphical Object behavior.
Overrides:
shapeContainsInternal in class GraphicalObjectGroupImpl

shapeContainsInternal

protected boolean shapeContainsInternal(Shape s)
Description copied from class: GraphicalObjectImpl
Internal method. Assumes s is already in local coordinates. Override for specific Graphical Object behavior.
Overrides:
shapeContainsInternal in class GraphicalObjectGroupImpl

shapeIntersectsInternal

protected boolean shapeIntersectsInternal(Shape s)
Description copied from class: GraphicalObjectImpl
Internal method. Assumes s is already in local coordinates. Override for specific Graphical Object behavior.
Overrides:
shapeIntersectsInternal in class GraphicalObjectGroupImpl

updateGroupBounds

protected void updateGroupBounds(GraphicalObject gob)
This method is called by our parent class whenever a Graphical Object is added or removed. We don't want to update our bounding points, since they are already determined, so just do nothing.
Overrides:
updateGroupBounds in class GraphicalObjectGroupImpl

updateGroupBounds

protected void updateGroupBounds()
This method is called by our parent class whenever a Graphical Object is added or removed. We don't want to update our bounding points, since they are already determined, so just do nothing.
Overrides:
updateGroupBounds in class GraphicalObjectGroupImpl

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
Overrides:
onNotify in class GraphicalObjectGroupImpl
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
Overrides:
onUpdate in class GraphicalObjectGroupImpl
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)
Description copied from interface: Watcher
Callback method for notifications.
Specified by:
onUpdate in interface Watcher
Overrides:
onUpdate in class GraphicalObjectGroupImpl
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)

setDrawPatch

public void setDrawPatch(boolean flag)
Set whether we should draw the patch border.

setFillPatch

public void setFillPatch(boolean flag)
Set whether we should fill in the patch.

setDrawChildren

public void setDrawChildren(boolean flag)
Set whether we should draw the children or not.

renderChildren

protected void renderChildren(SatinGraphics g)
Renders the children of the patch.

defaultRender

protected void defaultRender(SatinGraphics g)
Description copied from class: GraphicalObjectImpl
The default method for rendering. This method is used by the DefaultView to render. Override this method in subclasses.
Overrides:
defaultRender in class GraphicalObjectGroupImpl

clone

public Object clone()
Description copied from interface: GraphicalObject
Clone this object shallowly, copying references to any children this GraphicalObject has.
Specified by:
clone in interface GraphicalObject
Overrides:
clone in class GraphicalObjectGroupImpl
Following copied from class: edu.berkeley.guir.lib.satin.objects.GraphicalObjectGroupImpl
Returns:
a shallow clone of this object.
See Also:
GraphicalObjectGroupImpl.deepClone()

clone

protected PatchImpl clone(PatchImpl p)
For clone chaining purposes.
See Also:
GraphicalObjectImpl.clone(GraphicalObjectImpl)

deepClone

public Object deepClone()
Make a deep-clone.
Specified by:
deepClone in interface GraphicalObject
Overrides:
deepClone in class GraphicalObjectGroupImpl
Following copied from class: edu.berkeley.guir.lib.satin.objects.GraphicalObjectGroupImpl
See Also:
GraphicalObjectGroupImpl.clone()

deepClone

protected PatchImpl deepClone(PatchImpl newPatch)
For deep-clone chaining. If you override this method in a subclass, be sure to call this method, just as you would have to for normal clone chaining.
See Also:
clone(), deepClone()

main

public static void main(String[] argv)

Copyright Information