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

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

java.lang.Object
  |
  +--edu.berkeley.guir.lib.satin.objects.GraphicalObjectImpl
        |
        +--edu.berkeley.guir.lib.satin.stroke.TimedStroke
All Implemented Interfaces:
Cloneable, EventListener, GraphicalObject, SatinConstants, Serializable, Shape, StrokeListener, Watchable
Direct Known Subclasses:
Circuit, LineArrow

public class TimedStroke
extends GraphicalObjectImpl
implements SatinConstants

A single Stroke that can paint itself. This is not a Component because there would be too many components. This work is based off of Chris Long's GDT Gesture class.

This software is distributed under the Berkeley Software License.

 Revisions:  - SATIN-v1.0-1.0.0, May 17 1998, 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:
Chris Long ( allanl@cs.berkeley.edu ), 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 TIMEDSTROKE_STYLE_FILE
          The name of the file containins the current stroke properties.
 
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
 
Fields inherited from interface edu.berkeley.guir.lib.satin.objects.GraphicalObject
GESTUREINTRP_CLPROPERTY, INKINTRP_CLPROPERTY, STYLE_CLPROPERTY, VIEW_CLPROPERTY
 
Constructor Summary
TimedStroke()
          Create an empty Stroke.
TimedStroke(Polygon p)
          Create a stroke based on this Polygon.
TimedStroke(Polygon2D p)
          Create a stroke based on this Polygon.
TimedStroke(TimedStroke tstk)
          Make a copy of the points of this TimedStroke.
 
Method Summary
 void addPoint(double x, double y)
          Add a point to this Stroke.
 void addPoint(double x, double y, long time)
           
 void addPoint(float x, float y)
           
 void addPoint(float x, float y, long time)
           
 void addPoint(Point2D pt)
          Add a point to this Stroke.
 void addPoint(Point2D pt, long time)
           
 void changePoint(int n, double x, double y)
          Change the nth point of the stroke to the given coordinates.
 void clearPoints()
           
 Object clone()
          Create a duplicate of this stroke.
protected  TimedStroke clone(TimedStroke stk)
          For clone chaining purposes.
protected  void defaultRender(SatinGraphics g)
          The default method for rendering.
 TimedStroke doneAddingPoints()
          Tell the stroke that we won't add any more points.
 String getButtonString()
           
 Point2D getEndPoint2D(int cdsys)
           
 Point2D getEndPoint2D(int cdsys, AffineTransform tx, Point2D pt)
           
 long getEndTime()
          Get the end time of this Timed Stroke.
 double getLength2D(int cdsys)
           
 int getNumPoints()
          Get the number of points in the stroke.
 TimedPolygon2D getPolygon2D(int cdsys)
           
 TimedPolygon2D getPolygon2D(int cdsys, AffineTransform tx, TimedPolygon2D p)
           
 Point2D getStartPoint2D(int cdsys)
           
 Point2D getStartPoint2D(int cdsys, AffineTransform tx, Point2D pt)
           
 long getStartTime()
          Get the start time of this Timed Stroke.
 TimedStroke getSubstroke(double start, double end)
          Get a portion of this stroke by percentages of length.
 boolean isLeftButton()
          Check if left button is down.
 boolean isMiddleButton()
          Check if middle button is down.
 boolean isRightButton()
          Check if right button is down.
static void main(String[] argv)
           
protected  void renderSelected(SatinGraphics g, Rectangle2D rect)
          Render some selection handles on the stroke itself.
static void setDrawFix(boolean flag)
          Straight lines aren't being rendered correctly.
 void setLeftButton(boolean flag)
          Set whether the left button is down.
 void setMiddleButton(boolean flag)
          Set whether the middle button is down.
 void setRightButton(boolean flag)
          Set whether the right button is down.
 String toDebugString()
          Some debugging info.
 
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, createNewInteractionHandler, createNewViewHandler, damage, damage, damage, damage, deepClone, 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, handleSingleStroke, handleUpdateStroke, hasClosedBoundingPoints, hasDamageEnabled, hasNotifyEnabled, intersects, intersects, isClippedToBounds, isDirty, isSelectable, isVisible, minDistance, minDistance, minLocalDistance, moveBy, moveBy, moveTo, moveTo, notifyWatchers, notifyWatchers, notifyWatchersDelete, notifyWatchersUpdate, notifyWatchersUpdate, onNewStroke, onSingleStroke, onUpdateStroke, postProcessNewStroke, postProcessSingleStroke, postProcessUpdateStroke, preProcessNewStroke, preProcessSingleStroke, preProcessUpdateStroke, redispatchNewStroke, redispatchSingleStroke, redispatchUpdateStroke, removeIndexedProperty, removeIndexedProperty, removeProperty, removeWatcher, render, renderAllCoordBounds, renderBoundingBox, renderDebug, renderDimensions, 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, shapeContainsInternal, shapeContainsInternal, shapeIntersects, shapeIntersects, shapeIntersectsInternal, toString, updateBoundingPoints
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIMEDSTROKE_STYLE_FILE

public static final String TIMEDSTROKE_STYLE_FILE
The name of the file containins the current stroke properties.
Constructor Detail

TimedStroke

public TimedStroke()
Create an empty Stroke.

TimedStroke

public TimedStroke(Polygon p)
Create a stroke based on this Polygon.
Parameters:
p - is the Polygon to copy as the basis for this stroke. Should be non-null. Polygon should be in relative coordinates.

TimedStroke

public TimedStroke(Polygon2D p)
Create a stroke based on this Polygon.
Parameters:
p - is the TimedPolygon to copy as the basis for this stroke. Should be non-null. TimedPolygon should be in relative coordinates.

TimedStroke

public TimedStroke(TimedStroke tstk)
Make a copy of the points of this TimedStroke.
Parameters:
tstk - is the TimedStroke to copy.
Method Detail

setDrawFix

public static void setDrawFix(boolean flag)
Straight lines aren't being rendered correctly. Calling this method with true just adds an extra point to make straight lines not-so-straight.

isLeftButton

public boolean isLeftButton()
Check if left button is down.

isMiddleButton

public boolean isMiddleButton()
Check if middle button is down.

isRightButton

public boolean isRightButton()
Check if right button is down.

setLeftButton

public void setLeftButton(boolean flag)
Set whether the left button is down.

setMiddleButton

public void setMiddleButton(boolean flag)
Set whether the middle button is down.

setRightButton

public void setRightButton(boolean flag)
Set whether the right button is down.

addPoint

public final void addPoint(float x,
                           float y)

addPoint

public final void addPoint(double x,
                           double y)
Add a point to this Stroke. Keep in mind that the order in which points are added matters. Furthermore, be sure you add points in the same coordinate system.
Parameters:
x - is the x-Location to add.
y - is the y-Location to add.

addPoint

public final void addPoint(Point2D pt)
Add a point to this Stroke. Keep in mind that the order in which points are added matters.
Parameters:
pt - is the Point to add.

addPoint

public final void addPoint(double x,
                           double y,
                           long time)

addPoint

public final void addPoint(float x,
                           float y,
                           long time)

addPoint

public final void addPoint(Point2D pt,
                           long time)

doneAddingPoints

public final TimedStroke doneAddingPoints()
Tell the stroke that we won't add any more points. For efficiency reasons, the local bounding points for TimedStrokes are not normalized to (0, 0). Calling this method will make that happen.

clearPoints

public final void clearPoints()

changePoint

public final void changePoint(int n,
                              double x,
                              double y)
Change the nth point of the stroke to the given coordinates. This method does not normalize the local bounding points.

getSubstroke

public TimedStroke getSubstroke(double start,
                                double end)
Get a portion of this stroke by percentages of length. For example, calling getSubstroke(0.0, 0.5) would get the first 50% of the stroke, cutting the stroke if necessary.
Parameters:
start - is the start percentage of length, between 0 and 1 inclusive.
end - is the ending percentage of length, between 0 and 1 inclusive, and greater than start.
Returns:
a TimedStroke that consists of the points in the specified start and end percentages (above).

getNumPoints

public int getNumPoints()
Get the number of points in the stroke.

getPolygon2D

public TimedPolygon2D getPolygon2D(int cdsys)

getPolygon2D

public TimedPolygon2D getPolygon2D(int cdsys,
                                   AffineTransform tx,
                                   TimedPolygon2D p)

getStartPoint2D

public Point2D getStartPoint2D(int cdsys)

getStartPoint2D

public Point2D getStartPoint2D(int cdsys,
                               AffineTransform tx,
                               Point2D pt)

getEndPoint2D

public Point2D getEndPoint2D(int cdsys)

getEndPoint2D

public Point2D getEndPoint2D(int cdsys,
                             AffineTransform tx,
                             Point2D pt)

getLength2D

public double getLength2D(int cdsys)

getStartTime

public long getStartTime()
Get the start time of this Timed Stroke.
Returns:
Standard unix time, ie number of milliseconds since Jan. 1, 1970.

getEndTime

public long getEndTime()
Get the end time of this Timed Stroke.
Returns:
Standard unix time, ie number of milliseconds since Jan. 1, 1970.

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 GraphicalObjectImpl

renderSelected

protected void renderSelected(SatinGraphics g,
                              Rectangle2D rect)
Render some selection handles on the stroke itself.
Overrides:
renderSelected in class GraphicalObjectImpl
Following copied from class: edu.berkeley.guir.lib.satin.objects.GraphicalObjectImpl
Parameters:
g - is the SatinGraphics context.
rect - is the bounding box (absolute coordinates).

getButtonString

public String getButtonString()

toDebugString

public String toDebugString()
Description copied from class: GraphicalObjectImpl
Some debugging info. The general rule used for all toStrings() in SATIN is to use "\n" for newlines, and not to have a terminating newline. Override this method in subclasses.

Do not call method toString() in any implementation of toDebugString(). Method toString() calls toDebugString().

Overrides:
toDebugString in class GraphicalObjectImpl

clone

public Object clone()
Create a duplicate of this stroke.
Overrides:
clone in class GraphicalObjectImpl
Returns:
a duplicated Stroke.

clone

protected TimedStroke clone(TimedStroke stk)
For clone chaining purposes.
See Also:
GraphicalObjectImpl.clone(GraphicalObjectImpl)

main

public static void main(String[] argv)

Copyright Information