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

edu.berkeley.guir.lib.satin.objects
Interface GraphicalObject

All Superinterfaces:
Cloneable, EventListener, SatinConstants, Serializable, Shape, StrokeListener, Watchable
All Known Subinterfaces:
GraphicalObjectGroup, Patch
All Known Implementing Classes:
GraphicalObjectGroupImpl, GraphicalObjectImpl, Sheet, GraphicalObjectWrapper

public interface GraphicalObject
extends SatinConstants, Cloneable, Serializable, Watchable, Shape, StrokeListener

A GraphicalObject is anything with some state, dynamically redefinable views on that state, and dynamically redefinable behaviors to manipulate that state.

The idea behind a GraphicalObject is to separate an object into the Model, View, Controller pattern (MVC). The Model is the underlying data structures, the Controllers handle the input, and the Views handle the output. A Model can have multiple Controllers and Views.

In the standard MVC, the Model is the center of the triad, with Views and Controllers attached to it. What we are investigating with SATIN is to see if we can make the View more central, dynamically changing the Model and Controllers as necessary.

The reason for this is to support not what the computer recognizes, but what the human perceives. Since the View is the portion that the human perceives, we wish to make it more central to interaction. Interpreters try to recognize what's on the screen (ie what you perceive) and try to help you manage and manipulate the information in a useful way.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, Oct 26 1998, JH
               Created class
             - SATIN-v2.1-1.0.0, Aug 11 2000, JH
               Touched for SATIN release
 

Since:
JDK 1.3RC1
Version:
SATIN-v2.1-1.0.0, Aug 11 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu )

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 GESTUREINTRP_CLPROPERTY
          Class property for View.
static String INKINTRP_CLPROPERTY
          Class property for View.
static String STYLE_CLPROPERTY
          Class property for Style.
static String VIEW_CLPROPERTY
          Class property for View.
 
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
 
Method Summary
 void addIndexedProperty(String strPropertyName, Object newVal)
           
 void applyTransform(AffineTransform newTx)
          Apply an affine Transform to this Graphical Object.
 void bringDownALayer()
          Bring this Graphical Object down one layer in its current group.
 void bringDownNLayers(int n)
          Bring this Graphical Object down N layers in its current group.
 void bringToBottomLayer()
          Bring this Graphical Object to the bottom of its current group.
 void bringToTopLayer()
          Bring this Graphical Object to the top of its current group.
 void bringUpALayer()
          Bring this Graphical Object up one layer in its current group.
 void bringUpNLayers(int n)
          Bring this Graphical Object up N layers in its current group.
 void clearIndexedProperty(String strPropertyName)
           
 Object clone()
          Clone this object shallowly, copying references to any children this GraphicalObject has.
 void damage(int sync)
          If this GraphicalObject Watchable.hasNotifyEnabled(), mark this GraphicalObject as damaged and repaint.
 void damage(int sync, GraphicalObject gob)
          If this GraphicalObject Watchable.hasNotifyEnabled(), mark the specified GraphicalObject as damaged and repaint.
 void damage(int sync, Rectangle2D rect)
          If this GraphicalObject Watchable.hasNotifyEnabled(), mark the specified region as damaged and repaint.
 void damage(int sync, Rectangle2D oldRect, Rectangle2D newRect)
          If this GraphicalObject Watchable.hasNotifyEnabled(), mark the specified regions as damaged and repaint.
 Object deepClone()
          Clone this object deeply, recursively deep-cloning any children this GraphicalObject has.
 void delete()
          Delete this object.
 void disableDamage()
          Turn off damage mechanism temporarily.
 void enableDamage()
          Re-enable damage mechanism.
 String getAbsoluteLayer()
          Get the absolute layer this group is in.
 Polygon2D getBoundingPoints2D(int cdsys)
          Get a Polygon describing the outer boundary of all of the visible views of this GraphicalObject.
 Polygon2D getBoundingPoints2D(int cdsys, AffineTransform tx, Polygon2D poly)
          Get a Polygon describing the outer boundary of all of the visible views of this GraphicalObject.
 Rectangle2D getBounds2D(int cdsys)
          Get the bounds of all of the visible views of this GraphicalObject.
 Rectangle2D getBounds2D(int cdsys, AffineTransform tx, Rectangle2D rect)
          Get the bounds of all of the visible views of this GraphicalObject.
 Interpreter getGestureInterpreter()
          Get the current Gesture Interpreter, which tries to handle strokes as gestures.
 float getHeight2D(int cdsys)
          Get the height of all of the visible views of this GraphicalObject.
 List getIndexedProperty(String strPropertyName)
           
 Object getIndexedProperty(String strPropertyName, int index)
           
 Interpreter getInkInterpreter()
          Get the current Ink Interpreter, which tries to handle strokes as Ink.
 AffineTransform getInverseTransform(int cdsys)
          Get the inverse of the transform.
 AffineTransform getInverseTransform(int cdsys, AffineTransform outTx)
          Get the inverse transform.
 Point2D getLocation2D(int cdsys)
          Get the location of the top-left corner of the bounding box for all of the visible views of this GraphicalObject.
 Point2D getLocation2D(int cdsys, AffineTransform tx, Point2D pt)
          Get the location of the top-left corner of the bounding box for all of the visible views of this GraphicalObject.
 GraphicalObjectGroup getParentGroup()
          Get the parent of this Graphical object.
 Object getProperty(String strPropertyName)
           
 Iterator getPropertyNames()
           
 String getRelativeLayer()
          Get the current layer this Graphical Object is in.
 Sheet getSheet()
          Get the sheet that this Graphical object is in.
 Style getStyle()
          Get a copy of the current Style for this Graphical Object.
 Style getStyleRef()
          Get a reference of the current Style for this Graphical Object.
 AffineTransform getTransform(int cdsys)
          Get a copy of the current transform for this GraphicalObject.
 AffineTransform getTransform(int cdsys, AffineTransform outTx)
          Get a copy of the current transform, putting the results in outTx.
 AffineTransform getTransformRef()
          Get a reference to the current transform.
 int getUniqueID()
          Get the ID of this GraphicalObject.
 View getView()
          Get the current View for this GraphicalObject, the object that handles how the the GraphicalObject is displayed.
 float getWidth2D(int cdsys)
          Get the width of all of the visible views of this GraphicalObject.
 void handleNewStroke(NewStrokeEvent evt)
          This callback is called when the stroke should be handled by this object.
 void handleSingleStroke(SingleStrokeEvent evt)
           
 void handleUpdateStroke(UpdateStrokeEvent evt)
           
 boolean hasClosedBoundingPoints()
          Check if the bounding points describing this GraphicalObject is a closed Polygon (e.g.
 boolean hasDamageEnabled()
          See if damage is enabled or not.
 boolean isClippedToBounds()
          Check whether the GraphicalObject should be clipped to bounds or not.
 boolean isSelectable()
          Check whether or not this Graphical Object can be selected.
 boolean isVisible()
          Check whether this GraphicalObject is visible or not.
 float minDistance(int cdsys, double x, double y)
          Calculate the closest distance from the specified point to self.
 float minDistance(int cdsys, Point2D pt)
          Calls the other minDistance(int, double, double) method.
 void moveBy(int cdsys, double dx, double dy)
          Move relative to where we currently are.
 void moveBy(int cdsys, Point2D pt)
          Calls the other moveBy(int, double, double) method.
 void moveTo(int cdsys, double x, double y)
          Move directly to the specified position.
 void moveTo(int cdsys, Point2D pt)
          Calls the other moveTo(int, double, double) method.
 void onNewStroke(NewStrokeEvent evt)
          Here is an overview of how dispatching works in Satin.
 void onSingleStroke(SingleStrokeEvent evt)
           
 void onUpdateStroke(UpdateStrokeEvent evt)
           
 void postProcessNewStroke(NewStrokeEvent evt)
           
 void postProcessSingleStroke(SingleStrokeEvent evt)
           
 void postProcessUpdateStroke(UpdateStrokeEvent evt)
           
 void preProcessNewStroke(NewStrokeEvent evt)
           
 void preProcessSingleStroke(SingleStrokeEvent evt)
           
 void preProcessUpdateStroke(UpdateStrokeEvent evt)
           
 void redispatchNewStroke(NewStrokeEvent evt)
           
 void redispatchSingleStroke(SingleStrokeEvent evt)
           
 void redispatchUpdateStroke(UpdateStrokeEvent evt)
           
 List removeIndexedProperty(String strPropertyName)
           
 Object removeIndexedProperty(String strPropertyName, int index)
           
 Object removeProperty(String strPropertyName)
           
 void render(SatinGraphics g)
          Render this graphical object in the specified Graphics context.
 void setBoundingPoints2D(int cdsys, Shape s)
          Set the bounding points for our default view.
 void setClipToBounds(boolean flag)
          Set whether the GraphicalObject should be clipped to bounds or not.
 Interpreter setGestureInterpreter(Interpreter intrp)
          Set the current Gesture Interpreter, which tries to handle strokes as gestures.
 void setHasClosedBoundingPoints(boolean flag)
          Set whether or not this GraphicalObject is a closed shape or not.
 void setIndexedProperty(String strPropertyName, int index, Object newVal)
           
 Interpreter setInkInterpreter(Interpreter intrp)
          Set the current Ink Interpreter, which tries to handle strokes as Ink.
 void setParentGroup(GraphicalObjectGroup newParent)
          Set who the parent of this Graphical Object is.
 void setProperty(String strPropertyName, Object newVal)
           
 void setRelativeLayer(int layer)
          A convenience method to set what layer this object is in.
 void setSelectable(boolean flag)
          Set whether or not this Graphical Object can be selected.
 Style setStyle(Style newStyle)
          Set the current Style for this Graphical Object.
 void setTransform(AffineTransform newTx)
          Set and apply a copy of the specified AffineTransform to this GraphicalObject.
 void setUniqueID(int newID)
          Set the ID of this GraphicalObject.
 void setView(View v)
          Set the View for this GraphicalObject.
 void setVisible(boolean flag)
          Set whether this GraphicalObject should be displayed or not.
 boolean shapeContains(GraphicalObject gob)
          See if the specified GraphicalObject fits entirely within our bounds.
 boolean shapeContains(int cdsys, double x, double y)
          See if we contain the specified point.
 boolean shapeContains(int cdsys, Point2D pt)
          See if we contain the specified point.
 boolean shapeContains(int cdsys, Shape s)
          See if we contain the specified rectangle.
 boolean shapeIntersects(GraphicalObject gob)
          See if the specified GraphicalObject intersects the this GraphicalObject.
 boolean shapeIntersects(int cdsys, Shape s)
          See if we intersect the specified shape.
 
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
 

Field Detail

STYLE_CLPROPERTY

public static final String STYLE_CLPROPERTY
Class property for Style. New instances of a given subclass will use this style as their default style.
See Also:
SatinConstants.clprops

VIEW_CLPROPERTY

public static final String VIEW_CLPROPERTY
Class property for View. New instances of a given subclass will use this View as their default view.
See Also:
SatinConstants.clprops

GESTUREINTRP_CLPROPERTY

public static final String GESTUREINTRP_CLPROPERTY
Class property for View. New instances of a given subclass will use this interpreter as their default gesture interpreter.
See Also:
SatinConstants.clprops

INKINTRP_CLPROPERTY

public static final String INKINTRP_CLPROPERTY
Class property for View. New instances of a given subclass will use this interpreter as their default ink interpreter.
See Also:
SatinConstants.clprops
Method Detail

setUniqueID

public void setUniqueID(int newID)
Set the ID of this GraphicalObject. It is designed for network access, and should not normally be called.
Returns:
the ID value set.

getUniqueID

public int getUniqueID()
Get the ID of this GraphicalObject. This value should be set by the constructor.
Returns:
an integer containing the ID value.

getPropertyNames

public Iterator getPropertyNames()
See Also:
FlexProperties.getPropertyNames()

getProperty

public Object getProperty(String strPropertyName)
See Also:
FlexProperties.getProperty(String)

setProperty

public void setProperty(String strPropertyName,
                        Object newVal)
See Also:
FlexProperties.setProperty(String, Object)

removeProperty

public Object removeProperty(String strPropertyName)
See Also:
FlexProperties.removeProperty(String)

getIndexedProperty

public List getIndexedProperty(String strPropertyName)
See Also:
FlexProperties.getIndexedProperty(String)

getIndexedProperty

public Object getIndexedProperty(String strPropertyName,
                                 int index)
See Also:
FlexProperties.getIndexedProperty(String, int)

setIndexedProperty

public void setIndexedProperty(String strPropertyName,
                               int index,
                               Object newVal)
See Also:
FlexProperties.setIndexedProperty(String, int, Object)

addIndexedProperty

public void addIndexedProperty(String strPropertyName,
                               Object newVal)
See Also:
FlexProperties.addIndexedProperty(String, Object)

removeIndexedProperty

public Object removeIndexedProperty(String strPropertyName,
                                    int index)
See Also:
FlexProperties.removeIndexedProperty(String, int)

removeIndexedProperty

public List removeIndexedProperty(String strPropertyName)
See Also:
FlexProperties.removeIndexedProperty(String)

clearIndexedProperty

public void clearIndexedProperty(String strPropertyName)
See Also:
FlexProperties.clearIndexedProperty(String)

setView

public void setView(View v)
Set the View for this GraphicalObject. This sets the bounding points for the View to be the same as this GraphicalObject by default.
See Also:
getView(), View.setBoundingPoints2DRef(Polygon2D)

getView

public View getView()
Get the current View for this GraphicalObject, the object that handles how the the GraphicalObject is displayed.
See Also:
setView(View)

setGestureInterpreter

public Interpreter setGestureInterpreter(Interpreter intrp)
Set the current Gesture Interpreter, which tries to handle strokes as gestures.
Parameters:
intrp - is the new Interpreter to use.
Returns:
the current Interpreter.

getGestureInterpreter

public Interpreter getGestureInterpreter()
Get the current Gesture Interpreter, which tries to handle strokes as gestures.
Returns:
the current Interpreter.

setInkInterpreter

public Interpreter setInkInterpreter(Interpreter intrp)
Set the current Ink Interpreter, which tries to handle strokes as Ink.
Parameters:
intrp - is the new Interpreter to use.
Returns:
the current Interpreter.

getInkInterpreter

public Interpreter getInkInterpreter()
Get the current Ink Interpreter, which tries to handle strokes as Ink.
Returns:
the current Interpreter.

setStyle

public Style setStyle(Style newStyle)
Set the current Style for this Graphical Object.

Notifies Watchers of an update when called.

Parameters:
the - Style to set to. A null value means use default values.

getStyle

public Style getStyle()
Get a copy of the current Style for this Graphical Object.
Returns:
the current Style.

getStyleRef

public Style getStyleRef()
Get a reference of the current Style for this Graphical Object.
Returns:
the current Style.

getRelativeLayer

public String getRelativeLayer()
Get the current layer this Graphical Object is in. Layers are a property of all Graphical Objects, and only specify a relative Z-ordering (not an absolute one). That is, we only know if a Graphical Object is above or below another, but not by how much (b/c didn't think it would be that useful, and would increase complexity). Layers may also be nested (through Graphical Object Groups).

 Main Tree
 |--  
 |    A Collection
 |    |--
 |    |   Relative: 1
 |    |   Absolute: 1
 |    |
 |    |    |--
 |    |    |   Relative: 1
 |    |    |   Absolute: 1.1
 |    |    |--
 |    |
 |    |    |--
 |    |    |   Relative: 2
 |    |    |   Absolute: 1.2
 |    |    |--
 |    |--
 |
 |    Another Collection
 |    |--
 |    |   Relative: 2
 |    |   Absolute: 2
 |    |
 |    |    |--
 |    |    |   Relative: 1
 |    |    |   Absolute: 2.1
 |    |    |--
 |    |--
 |--
 
Returns:
a non-negative value representing the current layer we are in.

setRelativeLayer

public void setRelativeLayer(int layer)
A convenience method to set what layer this object is in. Usually, this should not be used.

Notifies Watchers of an update when called.

Parameters:
layer - is the non-negative layer value to set to. If it is set too high, it is just sent to the bottom-most layer.

getAbsoluteLayer

public String getAbsoluteLayer()
Get the absolute layer this group is in.
Returns:
a String like "1.3.2" or "2.1.1"

bringUpALayer

public void bringUpALayer()
Bring this Graphical Object up one layer in its current group. Does nothing if the operation is not possible.

Notifies Watchers of an update when called.


bringUpNLayers

public void bringUpNLayers(int n)
Bring this Graphical Object up N layers in its current group. Brings up as many layers as possible.

Notifies Watchers of an update when called.

Parameters:
n - is the number of layers to move this GraphicalObject up.

bringDownALayer

public void bringDownALayer()
Bring this Graphical Object down one layer in its current group. Does nothing if the operation is not possible.

Notifies Watchers of an update when called.


bringDownNLayers

public void bringDownNLayers(int n)
Bring this Graphical Object down N layers in its current group. Brings up as many layers as possible.

Notifies Watchers of an update when called.

Parameters:
n - is the number of layers to move this GraphicalObject down.

bringToTopLayer

public void bringToTopLayer()
Bring this Graphical Object to the top of its current group. Does nothing if the operation is not possible.

Notifies Watchers of an update when called.


bringToBottomLayer

public void bringToBottomLayer()
Bring this Graphical Object to the bottom of its current group. Does nothing if the operation is not possible.

Notifies Watchers of an update when called.


applyTransform

public void applyTransform(AffineTransform newTx)
Apply an affine Transform to this Graphical Object.

Notifies Watchers of an update when called.

Parameters:
newTx - is a Transform to apply. No modifications are made to newTx.

setTransform

public void setTransform(AffineTransform newTx)
Set and apply a copy of the specified AffineTransform to this GraphicalObject.

Notifies Watchers of an update when called.

Parameters:
newTx - is a Transform to apply. Removes the old one completely. No modifications are made to newTx.

getTransformRef

public AffineTransform getTransformRef()
Get a reference to the current transform. For optimization purposes.

getTransform

public AffineTransform getTransform(int cdsys)
Get a copy of the current transform for this GraphicalObject.
Parameters:
cdsys - is the coordinate system.
Returns:
a copy of the current Transform.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getTransform

public AffineTransform getTransform(int cdsys,
                                    AffineTransform outTx)
Get a copy of the current transform, putting the results in outTx.
Parameters:
cdsys - is the coordinate system.
outTx - is the storage space.
Returns:
a reference to outTx.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getInverseTransform

public AffineTransform getInverseTransform(int cdsys)
Get the inverse of the transform.
Parameters:
cdsys - is the coordinate system to use.
Returns:
the inverse transform in the specified coordinate system.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getInverseTransform

public AffineTransform getInverseTransform(int cdsys,
                                           AffineTransform outTx)
Get the inverse transform.
Parameters:
cdsys - is the coordinate system to use.
outTx - is the output storage. Use null to create a new object.
Returns:
a reference to outTx
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

minDistance

public float minDistance(int cdsys,
                         double x,
                         double y)
Calculate the closest distance from the specified point to self. This method assumes that the GraphicalObject can be described as a Polygon. The distance is defined as 0 if the point is within this GraphicalObject and the GraphicalObject is closed. Otherwise, it is the minimum distance from the specified point to the nearest point in the GraphicalObject.
Parameters:
cdsys - is the coordinate system.
x - is the x-coordinate.
y - is the y-coordinate.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

minDistance

public float minDistance(int cdsys,
                         Point2D pt)
Calls the other minDistance(int, double, double) method.

getLocation2D

public Point2D getLocation2D(int cdsys)
Get the location of the top-left corner of the bounding box for all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
Returns:
a Point2D containing the Location of the top-left corner of this object's bounding box.
See Also:
getLocation2D(int, AffineTransform, Point2D), SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getLocation2D

public Point2D getLocation2D(int cdsys,
                             AffineTransform tx,
                             Point2D pt)
Get the location of the top-left corner of the bounding box for all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
tx - is the transform to apply after the location is retrieved. Use null for none.
pt - is where to store the output. Use null to create a new point. Use for optimization purposes.
Returns:
a reference to pt.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getBounds2D

public Rectangle2D getBounds2D(int cdsys)
Get the bounds of all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
Returns:
a reference to rect.
See Also:
getBounds2D(int), SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getBounds2D

public Rectangle2D getBounds2D(int cdsys,
                               AffineTransform tx,
                               Rectangle2D rect)
Get the bounds of all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
tx - is the transform to apply after the location is retrieved. Use null for none.
rect - is the Rectangle to put the results in. Use null to create a new Rectangle. Use for optimization purposes.
Returns:
a reference to rect.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getBoundingPoints2D

public Polygon2D getBoundingPoints2D(int cdsys)
Get a Polygon describing the outer boundary of all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
Returns:
a Polygon representing this GraphicalObject's bounding points.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getBoundingPoints2D

public Polygon2D getBoundingPoints2D(int cdsys,
                                     AffineTransform tx,
                                     Polygon2D poly)
Get a Polygon describing the outer boundary of all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
tx - is the transform to apply after the location is retrieved. Use null for none.
poly - is the Polygon to put the results in. Use null to create a new Polygon. Use for optimization purposes.
Returns:
a reference to poly.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getWidth2D

public float getWidth2D(int cdsys)
Get the width of all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

getHeight2D

public float getHeight2D(int cdsys)
Get the height of all of the visible views of this GraphicalObject.
Parameters:
cdsys - is the coordinate system to use.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

setHasClosedBoundingPoints

public void setHasClosedBoundingPoints(boolean flag)
Set whether or not this GraphicalObject is a closed shape or not. By default is true.

hasClosedBoundingPoints

public boolean hasClosedBoundingPoints()
Check if the bounding points describing this GraphicalObject is a closed Polygon (e.g. a box) or an open Polygon (e.g. most ink strokes).
Returns:
true if the GraphicalObject is closed, false otherwise.

shapeContains

public boolean shapeContains(GraphicalObject gob)
See if the specified GraphicalObject fits entirely within our bounds.

Don't confuse this method with GraphicalObjectCollection.contains(GraphicalObject).

Parameters:
gob - is the GraphicalObject to check. It doesn't matter what coordinate space gob is in, it will be moved to the correct space.
Returns:
true if gob is contained, false otherwise.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

shapeContains

public boolean shapeContains(int cdsys,
                             Point2D pt)
See if we contain the specified point.
Parameters:
cdsys - is the coordinate system of the point.
pt - is the point.
Returns:
true if we contain the point, false otherwise.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

shapeContains

public boolean shapeContains(int cdsys,
                             double x,
                             double y)
See if we contain the specified point.
Parameters:
cdsys - is the coordinate system of the point.
x - is the x-coordinate.
y - is the y-coordinate.
Returns:
true if we contain the point, false otherwise.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

shapeContains

public boolean shapeContains(int cdsys,
                             Shape s)
See if we contain the specified rectangle.
Parameters:
cdsys - is the coordinate system of the point.
s - is the shape to check.
Returns:
true if we contain the point, false otherwise.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

shapeIntersects

public boolean shapeIntersects(GraphicalObject gob)
See if the specified GraphicalObject intersects the this GraphicalObject. Two GraphicalObjects intersect if they share any two points in common.
Parameters:
gob - is checked to see if it intersects this GraphicalObject. It doesn't matter what coordinate space gob is in, it will be moved to the correct space.
Returns:
true if gob intersects this GraphicalObject, false otherwise.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

shapeIntersects

public boolean shapeIntersects(int cdsys,
                               Shape s)
See if we intersect the specified shape.
Parameters:
cdsys - is the coordinate system of the point.
s - is the shape to check.
Returns:
true if we contain the point, false otherwise.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

isSelectable

public boolean isSelectable()
Check whether or not this Graphical Object can be selected.
Returns:
true if it can be selected, false otherwise.

setSelectable

public void setSelectable(boolean flag)
Set whether or not this Graphical Object can be selected.
Parameters:
flag - is true to set this Graphical Object as selectable, false otherwise.

moveTo

public void moveTo(int cdsys,
                   double x,
                   double y)
Move directly to the specified position.

Notifies Watchers of an update when called.

Parameters:
cdsys - is the coordinate system to use.
x - is the x-coordinate to move to.
y - is the y-coordinate to move to.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

moveTo

public void moveTo(int cdsys,
                   Point2D pt)
Calls the other moveTo(int, double, double) method.

moveBy

public void moveBy(int cdsys,
                   double dx,
                   double dy)
Move relative to where we currently are.

Notifies Watchers of an update when called.

Parameters:
cdsys - is the coordinate system to use.
dx - is the change in x-coordinate to move.
dy - is the change in y-coordinate to move.
See Also:
SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

moveBy

public void moveBy(int cdsys,
                   Point2D pt)
Calls the other moveBy(int, double, double) method.

setBoundingPoints2D

public void setBoundingPoints2D(int cdsys,
                                Shape s)
Set the bounding points for our default view.

Notifies Watchers of an update when called.

Parameters:
cdsys - is the coordinate system to use.
s - is the shape that describes our bounds.
See Also:
getView(), SatinConstants.COORD_LOCAL, SatinConstants.COORD_REL, SatinConstants.COORD_ABS

onNewStroke

public void onNewStroke(NewStrokeEvent evt)
Here is an overview of how dispatching works in Satin. The ASCII diagram below shows the lifecycle of a TimedStroke as it is dispatched. When a TimedStroke is created, a message is dispatched to the Sheet signifying that a Stroke is being created, via onNewStroke(). As the TimedStroke is updated, onUpdateStroke() is called on the Sheet. After it is completed, onSingleStroke() is called on the Sheet.
     ---------------    ------------------    ------------------
 --->|onNewStroke()|--->|onUpdateStroke()|--->|onSingleStroke()|
     ---------------    ------------------    ------------------
                                   |    ^
                                   |    |
                                   |____|

 

Here's what happens in Sheet when onNewStroke() is called, in order.

The same happens when onUpdateStroke() and onSingleStroke() are called.

Here's a full example of what happens. Suppose you are drawing a stroke on top of a GraphicalObject (which in turn is contained by the Sheet). In the notation below, the sheet is designated with s and the GraphicalObject is designated with g. The indentation represents different levels of the call stack. Here are the methods that are called:

 s.onNewStroke()                      // this occurs once per TimedStroke
    s.preProcessNewStroke()
    s.redispatchNewStroke()
       g.onNewStroke()
          g.preProcessNewStroke()
             g.getGestureInterpreter().handleNewStroke()
          g.redispatchNewStroke()
          g.postProcessNewStroke()
             g.getInkInterpreter().handleNewStroke()
          g.handleNewStroke()
    s.postProcessNewStroke()
    s.handleNewStroke()

 s.onUpdateStroke()                   // this occurs multiple times
    s.preProcessUpdateStroke()
    s.redispatchUpdateStroke()
       g.onUpdateStroke()
          g.preProcessUpdateStroke()
             g.getGestureInterpreter().handleUpdateStroke()
          g.redispatchUpdateStroke()
          g.postProcessUpdateStroke()
             g.getInkInterpreter().handleUpdateStroke()
          g.handleUpdateStroke()
    s.postProcessUpdateStroke()
    s.handleUpdateStroke()

 s.onSingleStroke()                   // this occurs once per TimedStroke
    s.preProcessSingleStroke()
    s.redispatchSingleStroke()
       g.onSingleStroke()
          g.preProcessSingleStroke()
             g.getGestureInterpreter().handleSingleStroke()
          g.redispatchSingleStroke()
          g.postProcessSingleStroke()
             g.getInkInterpreter().handleSingleStroke()
          g.handleSingleStroke()
    s.postProcessSingleStroke()
    s.handleSingleStroke()
 
Parameters:
evt - is the event to dispatch. evt should be in this GraphicalObject's local coordinate space when this method is called.
See Also:
for information on how to manipulate the event.

preProcessNewStroke

public void preProcessNewStroke(NewStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

redispatchNewStroke

public void redispatchNewStroke(NewStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

postProcessNewStroke

public void postProcessNewStroke(NewStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

handleNewStroke

public void handleNewStroke(NewStrokeEvent evt)
Description copied from interface: StrokeListener
This callback is called when the stroke should be handled by this object. If you, the listener, have consumed the Stroke, then call SatinEvent.setConsumed() with true to signify that it is consumed and no one else should handle it. Furthermore, if you don't want the stroke to be rendered, then call SatinEvent.setShouldRender(boolean) with false. By default, the stroke will be rendered.
Specified by:
handleNewStroke in interface StrokeListener
See Also:
onNewStroke(NewStrokeEvent)

onUpdateStroke

public void onUpdateStroke(UpdateStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

preProcessUpdateStroke

public void preProcessUpdateStroke(UpdateStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

redispatchUpdateStroke

public void redispatchUpdateStroke(UpdateStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

postProcessUpdateStroke

public void postProcessUpdateStroke(UpdateStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

handleUpdateStroke

public void handleUpdateStroke(UpdateStrokeEvent evt)
Specified by:
handleUpdateStroke in interface StrokeListener
See Also:
onNewStroke(NewStrokeEvent)

onSingleStroke

public void onSingleStroke(SingleStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

preProcessSingleStroke

public void preProcessSingleStroke(SingleStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

redispatchSingleStroke

public void redispatchSingleStroke(SingleStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

postProcessSingleStroke

public void postProcessSingleStroke(SingleStrokeEvent evt)
See Also:
onNewStroke(NewStrokeEvent)

handleSingleStroke

public void handleSingleStroke(SingleStrokeEvent evt)
Specified by:
handleSingleStroke in interface StrokeListener
See Also:
onNewStroke(NewStrokeEvent)

setVisible

public void setVisible(boolean flag)
Set whether this GraphicalObject should be displayed or not.

isVisible

public boolean isVisible()
Check whether this GraphicalObject is visible or not.

disableDamage

public void disableDamage()
Turn off damage mechanism temporarily. This works like a counting semaphore. Every time this method is called, the disable value is incremented. The damage mechanism is enabled if and only if the disable value is 0.

This method is useful if you are doing multiple operations to the same GraphicalObject all at once, but don't want to damage the GraphicalObject until all the operations are done.

See Also:
enableDamage(), hasDamageEnabled()

enableDamage

public void enableDamage()
Re-enable damage mechanism.
See Also:
disableDamage(), hasDamageEnabled()

hasDamageEnabled

public boolean hasDamageEnabled()
See if damage is enabled or not.
See Also:
disableDamage(), enableDamage()

setClipToBounds

public void setClipToBounds(boolean flag)
Set whether the GraphicalObject should be clipped to bounds or not. Slows down performance if true. Default is false.
Parameters:
flag - specifies whether the GraphicalObject should be clipped to bounds or not.

isClippedToBounds

public boolean isClippedToBounds()
Check whether the GraphicalObject should be clipped to bounds or not.
Returns:
true if the GraphicalObject should be clipped to bounds, false otherwise.

damage

public void damage(int sync)
If this GraphicalObject Watchable.hasNotifyEnabled(), mark this GraphicalObject as damaged and repaint.
Parameters:
sync - is either SatinConstants.DAMAGE_NOW or SatinConstants.DAMAGE_LATER
See Also:
SatinConstants.DAMAGE_NOW, SatinConstants.DAMAGE_LATER

damage

public void damage(int sync,
                   GraphicalObject gob)
If this GraphicalObject Watchable.hasNotifyEnabled(), mark the specified GraphicalObject as damaged and repaint.
Parameters:
sync - is either SatinConstants.DAMAGE_NOW or SatinConstants.DAMAGE_LATER
gob - is the GraphicalObject to repaint.
See Also:
SatinConstants.DAMAGE_NOW, SatinConstants.DAMAGE_LATER

damage

public void damage(int sync,
                   Rectangle2D rect)
If this GraphicalObject Watchable.hasNotifyEnabled(), mark the specified region as damaged and repaint.
Parameters:
sync - is either SatinConstants.DAMAGE_NOW or SatinConstants.DAMAGE_LATER
rect - is the rectangle to damage (absolute coordinates).
See Also:
SatinConstants.DAMAGE_NOW, SatinConstants.DAMAGE_LATER

damage

public void damage(int sync,
                   Rectangle2D oldRect,
                   Rectangle2D newRect)
If this GraphicalObject Watchable.hasNotifyEnabled(), mark the specified regions as damaged and repaint. This method is typically used when transforms are applied, when the GraphicalObject was in one place and is now in another.
Parameters:
sync - is either SatinConstants.DAMAGE_NOW or SatinConstants.DAMAGE_LATER
oldRect - is the rectangle to damage (absolute coordinates).
newRect - is the rectangle to damage (absolute coordinates).
See Also:
SatinConstants.DAMAGE_NOW, SatinConstants.DAMAGE_LATER

render

public void render(SatinGraphics g)
Render this graphical object in the specified Graphics context.

When this method is called for you, your Style and Transform has already been set. This has several implications.

First, you can just use the normal drawing methods, like drawLine(), and they will automatically use the thickness and other properties as set in Style. You can still set colors and fonts and such if you want, though.

Secondly, your coordinate system is set such that (0,0) is your top-left corner.

Third, since your transform is already set, you don't have to do anything special to get rotation. Just draw normally.

Fourth, while in render(), do not call any methods that use SatinConstants.COORD_REL or SatinConstants.COORD_ABS, since the transform has already been applied. Instead, use SatinConstants.COORD_LOCAL.

So in other words, all you have to do is just draw the GraphicalObject normally, and everything else will be handled for you. However, do NOT call anything that uses the transformed bounds, since that will apply the transform twice (the transform has already been applied once).

Parameters:
g - is the Graphics context to draw in.

getParentGroup

public GraphicalObjectGroup getParentGroup()
Get the parent of this Graphical object.
Returns:
the Parent of this Graphical Object, or null if it does not have a parent.

setParentGroup

public void setParentGroup(GraphicalObjectGroup newParent)
Set who the parent of this Graphical Object is. This method should not be normally called, but it is necessary to have since we need a way of setting parents when adding Graphical Objects to Groups.

Please note that this does not necessarily add this GraphicalObject to the specified parent. Typically, this method will be called for you when a GraphicalObject is added to a Group or Patch.

Parameters:
newParent - is the parent to set to. Use null if this object does not have a parent.

getSheet

public Sheet getSheet()
Get the sheet that this Graphical object is in.
Returns:
the Sheet that this Graphical Object is in, or null if it is not in a Sheet.

delete

public void delete()
Delete this object. Useful only if this object has a parent. Essentially, this means that you cannot delete the root of the interactor tree.

Also notifies Watchers of a delete when called.


clone

public Object clone()
Clone this object shallowly, copying references to any children this GraphicalObject has.
Specified by:
clone in interface Watchable
Overrides:
clone in class Object

deepClone

public Object deepClone()
Clone this object deeply, recursively deep-cloning any children this GraphicalObject has.

Copyright Information