edu.mit.sketch.toolkit
Class SimpleClassifier

java.lang.Object
  |
  +--edu.mit.sketch.toolkit.Classifier
        |
        +--edu.mit.sketch.toolkit.SimpleClassifier

public class SimpleClassifier
extends Classifier

This class implements Classifier. The SimpleClassifier will deal with single stroke input only. There is a SimpleClassifier object associated with each stroke. In conjunction with this class is the StrokeData class. The users must creare a StrokeData object and pass it to this class.


Field Summary
 double dd_dt_average_scale
          This is how much we scale the average curvature to get the threshold for curvature fit.
 Vertex[] direction_fit
          Fit based on curvature
 int direction_window_width
          This is the number of points to be included for deriving direction.
 Vertex[] final_fit
          Best hybrid fit
 int fit_method
          This is the fit method to be used when deriving the direction.
 Vertex[] points
          Speed original points in the stroke.
 double polyline_vs_general_path_bias
          Final fit LSQE is scaled by this, and compared against the general path LSQE.
 double speed_average_scale
          This is how much we scale the average speed to get the threshold for the speed fit.
 Vertex[] speed_fit
          Speed fit
 double test_line_scale
          This controls the strictness of line classification.
 
Fields inherited from class edu.mit.sketch.toolkit.Classifier
COMPLEX, ELLIPSE, error_calculator, LINE, POLYGON, stroke_data
 
Constructor Summary
SimpleClassifier(StrokeData stroke_data)
          Constructs a Classifier object.
 
Method Summary
 int classify()
          Returns the best fit type for the strokeData
 int[] classify(double error_bound)
          Returns the set of types that fit the stroke with error value less than the bound specified, (not necessarily sorted by goodness).
 Approximation[] classifyAndRank()
          Returns an array of approximations to the input stroke sorted by their goodness.
 GeneralPath getComplexApproximation()
          Returns the best fit GeneralPath for the StrokeData.
 double getComplexError()
          Returns the error between the best fit GeneralPath and the strokeData.
 Ellipse getEllipseApproximation()
          Returns the best fit Ellipse for the StrokeData.
 double getEllipseError()
          Returns the error between the best fit ellipse and the strokeData.
 Line getLineApproximation()
          Returns the best fit Line for the StrokeData.
 double getLineError()
          Returns the error between the best fit line and the strokeData.
 Polygon getPolygonApproximation()
          Returns the best fit Polygon for the StrokeData.
 double getPolygonError()
          Returns the error between the best fit polygon and the strokeData.
 boolean isComplex()
          Returns true if the best fit for the strokeData is a complex shape.
 boolean isComplex(double error_bound)
          Returns true if the best fit complex shape has error measure less than error_bound.
 boolean isEllipse()
          Returns true if the best fit for the strokeData is an Ellipse.
 boolean isEllipse(double error_bound)
          Returns true if the best fit ellipse for the strokeData is less than error_bound.
 boolean isLine()
          Returns true if the best fit shape for the strokeData is a Line.
 boolean isLine(double error_bound)
          Returns true if the best fit line has an error of less than error_bound.
 boolean isPolygon()
          Returns true if the best fit for strokeData is a polygon.
 boolean isPolygon(double error_bound)
          Returns true if the best fit polygon has an error of less than bound.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

direction_window_width

public int direction_window_width
This is the number of points to be included for deriving direction.

fit_method

public int fit_method
This is the fit method to be used when deriving the direction.

dd_dt_average_scale

public double dd_dt_average_scale
This is how much we scale the average curvature to get the threshold for curvature fit. Making this too high of too low results in fewer points in the output fit.

speed_average_scale

public double speed_average_scale
This is how much we scale the average speed to get the threshold for the speed fit. Making this too high of too low results in fewer points in the output fit.

test_line_scale

public double test_line_scale
This controls the strictness of line classification. Higher threshold means less strict.

polyline_vs_general_path_bias

public double polyline_vs_general_path_bias
Final fit LSQE is scaled by this, and compared against the general path LSQE. Making this larger creates a bias towards complex fits.

final_fit

public Vertex[] final_fit
Best hybrid fit

speed_fit

public Vertex[] speed_fit
Speed fit

direction_fit

public Vertex[] direction_fit
Fit based on curvature

points

public Vertex[] points
Speed original points in the stroke.
Constructor Detail

SimpleClassifier

public SimpleClassifier(StrokeData stroke_data)
Constructs a Classifier object. You must pass it a StrokeData object. Contains a default error calculator, which is just the squared error.
Method Detail

classify

public int classify()
Returns the best fit type for the strokeData
Overrides:
classify in class Classifier

classify

public int[] classify(double error_bound)
Returns the set of types that fit the stroke with error value less than the bound specified, (not necessarily sorted by goodness).
Overrides:
classify in class Classifier

classifyAndRank

public Approximation[] classifyAndRank()
Returns an array of approximations to the input stroke sorted by their goodness.

isPolygon

public boolean isPolygon()
Returns true if the best fit for strokeData is a polygon.
Overrides:
isPolygon in class Classifier

isPolygon

public boolean isPolygon(double error_bound)
Returns true if the best fit polygon has an error of less than bound. The error is squared error
Overrides:
isPolygon in class Classifier

isEllipse

public boolean isEllipse()
Returns true if the best fit for the strokeData is an Ellipse.
Overrides:
isEllipse in class Classifier

isEllipse

public boolean isEllipse(double error_bound)
Returns true if the best fit ellipse for the strokeData is less than error_bound.
Overrides:
isEllipse in class Classifier

isComplex

public boolean isComplex()
Returns true if the best fit for the strokeData is a complex shape.
Overrides:
isComplex in class Classifier

isComplex

public boolean isComplex(double error_bound)
Returns true if the best fit complex shape has error measure less than error_bound.
Overrides:
isComplex in class Classifier

isLine

public boolean isLine()
Returns true if the best fit shape for the strokeData is a Line.
Overrides:
isLine in class Classifier

isLine

public boolean isLine(double error_bound)
Returns true if the best fit line has an error of less than error_bound.
Overrides:
isLine in class Classifier

getPolygonError

public double getPolygonError()
Returns the error between the best fit polygon and the strokeData. The error is calculated according to the ErrorCalculator, which uses squared error if not set by the user.
Overrides:
getPolygonError in class Classifier

getEllipseError

public double getEllipseError()
Returns the error between the best fit ellipse and the strokeData. The error is calculated according to the ErrorCalculator, which uses squared error if not set by the user.
Overrides:
getEllipseError in class Classifier

getComplexError

public double getComplexError()
Returns the error between the best fit GeneralPath and the strokeData. The error is calculated according to the ErrorCalculator, which uses squared error if not set by the user.
Overrides:
getComplexError in class Classifier

getLineError

public double getLineError()
Returns the error between the best fit line and the strokeData. The error is calculated according to the ErrorCalculator, which uses squared error if not set by the user.
Overrides:
getLineError in class Classifier

getPolygonApproximation

public Polygon getPolygonApproximation()
Returns the best fit Polygon for the StrokeData. I have used the class Polygon here because we are using a standard library of shapes which may or may not be the same as the Java defined shapes.
Overrides:
getPolygonApproximation in class Classifier

getEllipseApproximation

public Ellipse getEllipseApproximation()
Returns the best fit Ellipse for the StrokeData. I have used the class Ellipse here because we are using a standard library of shapes which may or may not be the same as the Java defined shapes.
Overrides:
getEllipseApproximation in class Classifier

getComplexApproximation

public GeneralPath getComplexApproximation()
Returns the best fit GeneralPath for the StrokeData. I have used the class GeneralPath here because we are using a standard library of shapes which may or may not be the same as the Java defined shapes.
Overrides:
getComplexApproximation in class Classifier

getLineApproximation

public Line getLineApproximation()
Returns the best fit Line for the StrokeData. I have used the class Line here because we are using a standard library of shapes which may or may not be the same as the Java defined shapes.
Overrides:
getLineApproximation in class Classifier