diva.sketch.toolbox
Class LineRecognizer

java.lang.Object
  extended by diva.sketch.toolbox.LineRecognizer
All Implemented Interfaces:
StrokeRecognizer

public class LineRecognizer
extends Object
implements StrokeRecognizer

This recognizer recognizes lines from strokes. It forms a line with the first and last points in a stroke, and for each point on the stroke, it calculates the distance of the point from the line and computes the confidence value based on the maximum distance.

Version:
$Revision: 1.4 $
Author:
Heloise Hse (hwawen@eecs.berkeley.edu)

Field Summary
static double DEFAULT_DIST_THRESH
           
static String LINE_TYPE_ID
          The type ID for lines.
 
Constructor Summary
LineRecognizer()
           
 
Method Summary
 RecognitionSet strokeCompleted(TimedStroke s)
          Invoked when a stroke is completed.
 RecognitionSet strokeModified(TimedStroke s)
          Invoked when a stroke has been modified, for example, points have been added to the stroke.
 RecognitionSet strokeStarted(TimedStroke s)
          Invoked when a stroke starts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_TYPE_ID

public static final String LINE_TYPE_ID
The type ID for lines.

See Also:
Constant Field Values

DEFAULT_DIST_THRESH

public static final double DEFAULT_DIST_THRESH
See Also:
Constant Field Values
Constructor Detail

LineRecognizer

public LineRecognizer()
Method Detail

strokeCompleted

public RecognitionSet strokeCompleted(TimedStroke s)
Invoked when a stroke is completed. This occurs when the mouse up event has been detected. First, filter the input stroke. If there's only 1 data point (lineCheck result is -1), this is definitely not a line, confidence = 0. If there are 2 data points, create a SimpleData with LINE_TYPE_ID and confidence value of 1. If there are more than 2 points in the filtered stroke, form a line with the first and the last points, then for every point in between, calculate the distance between the point and the line, record the maximum distance (maxDist)from the line, then create a SimpleData with LINE_TYPE_ID and confidence value of * (1-maxDist/100).

Specified by:
strokeCompleted in interface StrokeRecognizer

strokeModified

public RecognitionSet strokeModified(TimedStroke s)
Invoked when a stroke has been modified, for example, points have been added to the stroke. It is probably safe to assume that this will be called every time a point is added to a stroke.

Specified by:
strokeModified in interface StrokeRecognizer

strokeStarted

public RecognitionSet strokeStarted(TimedStroke s)
Invoked when a stroke starts. This occurs when the mouse down event has been detected.

Specified by:
strokeStarted in interface StrokeRecognizer


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.