edu.mit.sketch.clocksketch.model
Class Stroke

java.lang.Object
  extended by edu.mit.sketch.clocksketch.model.Stroke
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
PenStroke

public abstract class Stroke
extends java.lang.Object
implements java.lang.Comparable

A stroke is a collection of Points that collectively form a "Stroke" or one single continuous motion made by the pen user.

Author:
David Pitman Apr 30, 2005

Constructor Summary
Stroke()
           
 
Method Summary
abstract  boolean addPoint(Point point)
          Adds a Point to the Stroke.
abstract  void clearPoints()
          Removes all Points from the Stroke.
abstract  double[] endPointsCorrelation()
          Returns the x, y, and shortest-distance correlation (between 0 and 1) of how close the endpoints are given the length of the stroke.
abstract  boolean equals(java.lang.Object o)
          Returns true only if the Stroke equals another Stroke
abstract  void extrapolateMissingValues()
          Logitech's IO pen will drop any points that are on a straight line to save memory.
abstract  double getAverageRadius(int k, boolean includeHooklets)
          Returns the radius of the symbol, with smoothing factor k.
abstract  java.awt.geom.Point2D getCenterOfMass(boolean includeHooklets)
          Returns the center of mass, (the average point) of all the Points in the Stroke
abstract  double[] getDirectionData(int k)
          Creates an array with the direction from point to the next, averaging with k nearest neighbors.
abstract  double[] getDirectionDerivative(int k)
          Calculates the derivative w/ respect to time (dt) of the directionality.
abstract  double[] getDirectionDerivativeRegression()
          Stores the results of analyzing the linear regression of the directionality/dt.
abstract  double[] getDirectionRegression()
          Stores the results of analyzing the linear regression of the directionality.
abstract  double getDistance()
          Returns the distance between the first point and the last point.
abstract  long getEndOfStroke()
          Returns the time (UNIX timestamp) that the stroke ended.
abstract  Point getFirstPoint()
          Returns the first Point of the Stroke
abstract  int getIndexNumber()
          All of the strokes downloaded from a pen are assigned a number in the order they were drawn, starting from 0.
abstract  java.lang.String getLabel()
          Returns the label of the stroke
abstract  Point getLastPoint()
          Returns the last Point of the Stroke
abstract  double getLength()
          Returns the length of the stroke.
abstract  double getMaxXCoordinate()
          Returns the largest X coordinate of the Stroke
abstract  double getMaxYCoordinate()
          Returns the largest Y coordinate of the Stroke
abstract  double getMinXCoordinate()
          Returns the smallest X coordinate of the Stroke.
abstract  double getMinYCoordinate()
          Returns the smallest Y coordinate of the Stroke.
abstract  int getNumberOfNonHookletPoints()
          Returns the number of points that are not hooklets within the stroke.
abstract  int getNumberOfPoints()
          Returns the number of points within the stroke
abstract  Symbol getParentSymbol()
          Returns the current parent Symbol (if any) of the Stroke
abstract  java.util.LinkedList<Point> getPointsByTimeStamp()
          Returns a LinkedList of Points by time stamp in ascending order.
abstract  long getStartOfStroke()
          Returns the time (UNIX timestamp) that the stroke started at.
abstract  boolean isHighlighted()
           
abstract  boolean removePoint(Point point)
          Removes a Point from the Stroke.
abstract  void setDirectionDerivativeRegression(double[] directionDerivative)
          Stores the results of analyzing the linear regression of the directionality/dt.
abstract  void setDirectionRegression(double[] direction)
          Stores the results of analyzing the linear regression of the directionality.
abstract  void setHighlighted(boolean highlight)
           
abstract  void setIndexNumber(int strokeNumber)
          Assigns the stroke a number based on how many strokes where drawn before it: If there were n Strokes drawn before, then the number is (n + 1) - 1.
abstract  void setLabel(java.lang.String label)
          Sets a label for the stroke
abstract  void setParentSymbol(Symbol parent)
          Sets the current parent Symbol of the Stroke, replacing the old parent Symbol
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

Stroke

public Stroke()
Method Detail

addPoint

public abstract boolean addPoint(Point point)
Adds a Point to the Stroke. Returns true iff the add was successful.

Parameters:
point -

removePoint

public abstract boolean removePoint(Point point)
Removes a Point from the Stroke. Returns true iff the remove was successful.

Parameters:
point -

clearPoints

public abstract void clearPoints()
Removes all Points from the Stroke.


setLabel

public abstract void setLabel(java.lang.String label)
Sets a label for the stroke

Parameters:
label -

getLabel

public abstract java.lang.String getLabel()
Returns the label of the stroke


getIndexNumber

public abstract int getIndexNumber()
All of the strokes downloaded from a pen are assigned a number in the order they were drawn, starting from 0.


setIndexNumber

public abstract void setIndexNumber(int strokeNumber)
Assigns the stroke a number based on how many strokes where drawn before it: If there were n Strokes drawn before, then the number is (n + 1) - 1. (For zero indexing)

Parameters:
strokeNumber -

isHighlighted

public abstract boolean isHighlighted()

setHighlighted

public abstract void setHighlighted(boolean highlight)
Parameters:
highlight -

getStartOfStroke

public abstract long getStartOfStroke()
Returns the time (UNIX timestamp) that the stroke started at.


getEndOfStroke

public abstract long getEndOfStroke()
Returns the time (UNIX timestamp) that the stroke ended.


getPointsByTimeStamp

public abstract java.util.LinkedList<Point> getPointsByTimeStamp()
Returns a LinkedList of Points by time stamp in ascending order.


equals

public abstract boolean equals(java.lang.Object o)
Returns true only if the Stroke equals another Stroke

Overrides:
equals in class java.lang.Object

getMinXCoordinate

public abstract double getMinXCoordinate()
Returns the smallest X coordinate of the Stroke.


getMinYCoordinate

public abstract double getMinYCoordinate()
Returns the smallest Y coordinate of the Stroke.


getMaxXCoordinate

public abstract double getMaxXCoordinate()
Returns the largest X coordinate of the Stroke


getMaxYCoordinate

public abstract double getMaxYCoordinate()
Returns the largest Y coordinate of the Stroke


getNumberOfPoints

public abstract int getNumberOfPoints()
Returns the number of points within the stroke


getNumberOfNonHookletPoints

public abstract int getNumberOfNonHookletPoints()
Returns the number of points that are not hooklets within the stroke.


getFirstPoint

public abstract Point getFirstPoint()
Returns the first Point of the Stroke


getLastPoint

public abstract Point getLastPoint()
Returns the last Point of the Stroke


getLength

public abstract double getLength()
Returns the length of the stroke.


getDistance

public abstract double getDistance()
Returns the distance between the first point and the last point.


endPointsCorrelation

public abstract double[] endPointsCorrelation()
Returns the x, y, and shortest-distance correlation (between 0 and 1) of how close the endpoints are given the length of the stroke.


setDirectionRegression

public abstract void setDirectionRegression(double[] direction)
Stores the results of analyzing the linear regression of the directionality. [ Alpha, Beta, R ]

Parameters:
direction -

getDirectionRegression

public abstract double[] getDirectionRegression()
Stores the results of analyzing the linear regression of the directionality. [ Alpha, Beta, R ]

Returns:
direction

setDirectionDerivativeRegression

public abstract void setDirectionDerivativeRegression(double[] directionDerivative)
Stores the results of analyzing the linear regression of the directionality/dt. [ Alpha, Beta, R ]

Parameters:
directionDerivative -

getDirectionDerivativeRegression

public abstract double[] getDirectionDerivativeRegression()
Stores the results of analyzing the linear regression of the directionality/dt. [ Alpha, Beta, R ]

Returns:
direction

getDirectionData

public abstract double[] getDirectionData(int k)
Creates an array with the direction from point to the next, averaging with k nearest neighbors. Each value is in radian, shifted by +Pi/2

Parameters:
k -

getDirectionDerivative

public abstract double[] getDirectionDerivative(int k)
Calculates the derivative w/ respect to time (dt) of the directionality. The returned array will be length direction.length-1 because the derivative of the last point cannot be calculated.

Parameters:
k - used to offset the data gathering
Returns:
array of derivatives.

getCenterOfMass

public abstract java.awt.geom.Point2D getCenterOfMass(boolean includeHooklets)
Returns the center of mass, (the average point) of all the Points in the Stroke


getAverageRadius

public abstract double getAverageRadius(int k,
                                        boolean includeHooklets)
Returns the radius of the symbol, with smoothing factor k. Where k = # of neighbors to average each point's value with.


extrapolateMissingValues

public abstract void extrapolateMissingValues()
Logitech's IO pen will drop any points that are on a straight line to save memory. We need those points to do image recognition. This method fills in any straight lines that seem to be missing points. We can guess when points are missing by the fact that the pen samples at 75/s.


getParentSymbol

public abstract Symbol getParentSymbol()
Returns the current parent Symbol (if any) of the Stroke


setParentSymbol

public abstract void setParentSymbol(Symbol parent)
Sets the current parent Symbol of the Stroke, replacing the old parent Symbol