public class ApproximateStrokeFilter extends StrokeFilter
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_THRESH_DISTANCE
If the farthest point from a line segment is less than the
DEFAULT_THRESH_DISTANCE, we can throw away all the in-between
points, because they are almost colinear.
|
PROPERTY_KEY
Constructor and Description |
---|
ApproximateStrokeFilter()
Construct a ApproximateStrokeFilter with default threshold
distance of 2 units.
|
Modifier and Type | Method and Description |
---|---|
TimedStroke |
apply(TimedStroke s)
Reduce the number of points in the given pen stroke using the
"approximation by line segments" algorithm.
|
static TimedStroke |
approximate(TimedStroke s)
Reduce the number of points in the given pen stroke using the
"approximation by line segments" algorithm.
|
static TimedStroke |
approximate(TimedStroke s,
double threshDist)
Reduce the number of points in the given pen stroke using the
"approximation by line segments" algorithm.
|
void |
setThreshDistance(int val)
Set the threshold distance of a point from a line segment.
|
public static final double DEFAULT_THRESH_DISTANCE
public ApproximateStrokeFilter()
public TimedStroke apply(TimedStroke s)
Algorithm: Form a line with the first and last points of the stroke. Find a farthest point (P) from the line segment such that distance between the line and P exceeds a threshold value. Then, break the line segment into 2 and recursively apply filtering on the 2 parts, (first, P) and (P, last). The threshold value is defaulted to DEFAULT_THRESH_DISTANCE.
apply
in class StrokeFilter
s
- the stroke to be filtered.public static TimedStroke approximate(TimedStroke s)
Algorithm: Form a line with the first and last points of the stroke. Find a farthest point (P) from the line segment such that distance between the line and P exceeds a threshold value. Then, break the line segment into 2 and recursively apply filtering on the 2 parts, (first, P) and (P, last). The threshold value is defaulted to DEFAULT_THRESH_DISTANCE.
s
- the stroke to be filtered.public static TimedStroke approximate(TimedStroke s, double threshDist)
Algorithm: Form a line with the first and last points of the stroke. Find a farthest point (P) from the line segment such that distance between the line and P exceeds a threshold value (threshDist). Then, break the line segment into 2 and recursively apply filtering on the 2 parts, (first, P) and (P, last).
public void setThreshDistance(int val)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.