edu.mit.sketch.toolkit
Class StrokeData

java.lang.Object
  |
  +--edu.mit.sketch.toolkit.StrokeData
All Implemented Interfaces:
Serializable

public class StrokeData
extends Object
implements Serializable

This class stores all the data from a single stroke. Time array has the same length as points.

See Also:
Serialized Form

Field Summary
 boolean a_is_valid
           
 double[] acceleration
          Time derivative of speed
 double[] accumulated_length
          The accumulated length of the curve upto ith vertex.
 boolean accumulated_length_is_valid
           
 Rectangle bounding_box
           
 Point center
           
 double[] d
          Direction array.
 boolean d_is_valid
           
 double[] dd_dt
          Derivative of the direction array (d).
 Gaussian[] dd_dt_gaussians
           
 boolean dd_dt_is_valid
           
 double[][] dd_dt_scale_space
          Direction change scale space information.
 boolean dd_dt_scale_space_is_valid
           
 int direction_window_width
          Parameters and constants.
 int fit_method
           
 PolarPoint[] polar_points
          The vertices mapped to polar coordinates.
 boolean polar_points_is_valid
           
 Dimension radius
           
 double[] speed
          Time derivative of position
 Gaussian[] speed_gaussians
          The gaussian filters.
 double[][] speed_scale_space
          Speed scale space information.
 boolean speed_scale_space_is_valid
           
 double test_line_scale
           
 long[] time
          The absolute time stamps for the vertices.
 boolean v_is_valid
           
 Vertex[] vertices
          The vertices in this data set.
 
Constructor Summary
StrokeData(Point[] points)
          The constructor.
StrokeData(Vertex[] vertices)
          The constructor.
 
Method Summary
 double averageAbsoluteFinG(double[] f, double[] g)
          Average
 double averageAbsoluteFinG(double[] f, long[] g)
          Average
 double averageFinG(double[] f, double[] g)
          Average
 double averageFinG(double[] f, long[] g)
          Average
 double averageSpeed()
          Average speed
 void convolveChangeInDirection(double[] filter)
          Do convolution.
 void convolveDirection(double[] filter)
          Do convolution.
 void derive_accumulated_length()
          Compute the derive accumulated length.
 void derive_d(int method)
          Derive direction, and fill in the d array.
 void derive_dd_dt_scale_space()
          Compute the scale space data.
 void derive_dd_dt()
          Find time derivative of direction, and fill in the dd_dt array.
 void derive_speed_scale_space()
          Compute the scale space data.
 void deriveAcceleration()
          Derive acceleration, and fill in the acceleration array.
 void deriveBoundingBox()
          Derive the bounding box for the vertices.
 double[] deriveDirectionUsingRotationalSWODR(Point[] input, int window_span)
          Derive direction, and return it.
 double[] deriveDirectionViaSWODR(Point[] input, int twice_window_size)
          Derive direction, and fill in the d array.
 void derivePolarCoordinates()
          Derive the polar coordinates of the vertices with respect to the center.
 void deriveProperties()
          Derive speed, and fill in the speed array.
 void deriveScaleSpaces()
          Derive speed, and fill in the speed array.
 void deriveSpeed()
          Derive speed, and fill in the speed array.
 double[] differantiateDirection(double[] direction)
          Differantiate the direction array using the current timing data.
 int[] filterCollinearVertices(int[] indices)
          filterCollinearVertices.
 int[] filterVerticesByLSQE(int[] indices, double tolerance)
          filterCollinearVertices.
 Polygon getDataPoints()
          Put the valid points in the points array in a Polygon and return it.
 Vertex[] getDirectionFit(double dd_dt_scale)
          Find the corners of the polygon using the change in the direction.
 Ellipse getEllipse()
          Return the ellipse fully containing the data points.
 long getEndTime()
           
 Vertex[] getSpeedFit(double average_scale)
          See if the input is a polygon.
 long getStartTime()
           
 Vertex[] getVertices()
          Return the vertices array.
 void invalidateCaches()
          Invalidates caches
 double leastSquaresForCircle()
          calculate the lsq error.
 double leastSquaresForCircle2()
          calculate the lsq error.
 void paint(Graphics g)
          Paint
 Vertex[] removeRedundantEndPoints(Vertex[] input_points)
          Remove the redundant at the beginning and the end.
 void setFitMethod(int method)
          Set fit method
 boolean testLine(double test_line_scale)
          See if the input is a line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertices

public Vertex[] vertices
The vertices in this data set.

time

public long[] time
The absolute time stamps for the vertices.

speed

public transient double[] speed
Time derivative of position

acceleration

public transient double[] acceleration
Time derivative of speed

d

public transient double[] d
Direction array. Length of this array is the same as the length of the vertices array. Basically the direction (ie. the angle of the tangent) at the last point in vertices is just the same as that of the previous point.

dd_dt

public transient double[] dd_dt
Derivative of the direction array (d). The length of this array is one less than that of d.

accumulated_length

public transient double[] accumulated_length
The accumulated length of the curve upto ith vertex.

speed_scale_space

public transient double[][] speed_scale_space
Speed scale space information. The rightmost dimension indexes the speed values at different scales, and the leftmost dimension indexes the scale parameter. Higher values correspond to coarser scales.

dd_dt_scale_space

public transient double[][] dd_dt_scale_space
Direction change scale space information. The rightmost dimension indexes the data values at different scales, and the leftmost dimension indexes the scale parameter. Higher values correspond to coarser scales.

speed_gaussians

public transient Gaussian[] speed_gaussians
The gaussian filters.

dd_dt_gaussians

public transient Gaussian[] dd_dt_gaussians

polar_points

public PolarPoint[] polar_points
The vertices mapped to polar coordinates.

direction_window_width

public int direction_window_width
Parameters and constants.

fit_method

public int fit_method

test_line_scale

public double test_line_scale

center

public Point center

bounding_box

public Rectangle bounding_box

radius

public Dimension radius

v_is_valid

public boolean v_is_valid

a_is_valid

public boolean a_is_valid

d_is_valid

public boolean d_is_valid

dd_dt_is_valid

public boolean dd_dt_is_valid

polar_points_is_valid

public boolean polar_points_is_valid

accumulated_length_is_valid

public boolean accumulated_length_is_valid

dd_dt_scale_space_is_valid

public boolean dd_dt_scale_space_is_valid

speed_scale_space_is_valid

public boolean speed_scale_space_is_valid
Constructor Detail

StrokeData

public StrokeData(Vertex[] vertices)
The constructor.

StrokeData

public StrokeData(Point[] points)
The constructor.
Method Detail

deriveProperties

public void deriveProperties()
Derive speed, and fill in the speed array. This method should cache data in order to save computation.

deriveScaleSpaces

public void deriveScaleSpaces()
Derive speed, and fill in the speed array. This method should cache data in order to save computation.

invalidateCaches

public void invalidateCaches()
Invalidates caches

getVertices

public Vertex[] getVertices()
Return the vertices array.

derivePolarCoordinates

public void derivePolarCoordinates()
Derive the polar coordinates of the vertices with respect to the center. Also determine the upper_right and lower right points (for surrounding rectangle).

deriveBoundingBox

public void deriveBoundingBox()
Derive the bounding box for the vertices.

getStartTime

public long getStartTime()

getEndTime

public long getEndTime()

deriveSpeed

public void deriveSpeed()
Derive speed, and fill in the speed array. This method should cache data in order to save computation.

deriveAcceleration

public void deriveAcceleration()
Derive acceleration, and fill in the acceleration array.

derive_d

public void derive_d(int method)
Derive direction, and fill in the d array.

derive_dd_dt

public void derive_dd_dt()
Find time derivative of direction, and fill in the dd_dt array.

derive_accumulated_length

public void derive_accumulated_length()
Compute the derive accumulated length.

derive_dd_dt_scale_space

public void derive_dd_dt_scale_space()
Compute the scale space data.

derive_speed_scale_space

public void derive_speed_scale_space()
Compute the scale space data.

filterVerticesByLSQE

public int[] filterVerticesByLSQE(int[] indices,
                                  double tolerance)
filterCollinearVertices.

filterCollinearVertices

public int[] filterCollinearVertices(int[] indices)
filterCollinearVertices.

deriveDirectionUsingRotationalSWODR

public double[] deriveDirectionUsingRotationalSWODR(Point[] input,
                                                    int window_span)
Derive direction, and return it. This method is different than the previous one in that here we look at a collection of vertices rather than two vertices to come up with the direction. Also use the rotation method.

deriveDirectionViaSWODR

public double[] deriveDirectionViaSWODR(Point[] input,
                                        int twice_window_size)
Derive direction, and fill in the d array. This method is different than the previous one in that here we look at a collection of vertices rather than two vertices to find the direction. Also this is supposed to work faster. Returns the direction array.

differantiateDirection

public double[] differantiateDirection(double[] direction)
Differantiate the direction array using the current timing data.

averageSpeed

public double averageSpeed()
Average speed

averageFinG

public double averageFinG(double[] f,
                          double[] g)
Average

averageAbsoluteFinG

public double averageAbsoluteFinG(double[] f,
                                  double[] g)
Average

averageFinG

public double averageFinG(double[] f,
                          long[] g)
Average

averageAbsoluteFinG

public double averageAbsoluteFinG(double[] f,
                                  long[] g)
Average

getDataPoints

public Polygon getDataPoints()
Put the valid points in the points array in a Polygon and return it.

getSpeedFit

public Vertex[] getSpeedFit(double average_scale)
See if the input is a polygon.

getDirectionFit

public Vertex[] getDirectionFit(double dd_dt_scale)
Find the corners of the polygon using the change in the direction. This is basically done by finding the peaks of the dd_dt array.

testLine

public boolean testLine(double test_line_scale)
See if the input is a line.

getEllipse

public Ellipse getEllipse()
Return the ellipse fully containing the data points.

leastSquaresForCircle

public double leastSquaresForCircle()
calculate the lsq error.

leastSquaresForCircle2

public double leastSquaresForCircle2()
calculate the lsq error.

removeRedundantEndPoints

public Vertex[] removeRedundantEndPoints(Vertex[] input_points)
Remove the redundant at the beginning and the end.

setFitMethod

public void setFitMethod(int method)
Set fit method

convolveDirection

public void convolveDirection(double[] filter)
Do convolution.

convolveChangeInDirection

public void convolveChangeInDirection(double[] filter)
Do convolution.

paint

public void paint(Graphics g)
Paint