public class CachingStrokeRecognizer extends Object implements StrokeRecognizer
The uncached version results in a lot of wasted computation on the part of the basic recognizer. With a cache, the sequence looks like this:
Since we expect most users will want to use a single basic recognizer, this should save a lot of unnecessary computation. Having this caching behavior in its own class makes it self-contained and possibly reusable.
| Constructor and Description |
|---|
CachingStrokeRecognizer(StrokeRecognizer target)
Cache the recognitions of the given target recognizer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Manually clear the cache.
|
boolean |
hasStrokeChanged(TimedStroke s)
Return whether or not the given stroke is changed relative to
the previous cached version.
|
RecognitionSet |
strokeCompleted(TimedStroke s)
Perform recognition in the target if the given stroke hasn't
changed since the last time this method was called.
|
RecognitionSet |
strokeModified(TimedStroke s)
Perform recognition in the target if the given stroke hasn't
changed since the last time this method was called.
|
RecognitionSet |
strokeStarted(TimedStroke s)
Perform recognition in the target if the given stroke hasn't
changed since the last time this method was called.
|
public CachingStrokeRecognizer(StrokeRecognizer target)
public void clear()
public boolean hasStrokeChanged(TimedStroke s)
This method can be overridden to make the caching more accurate or more sophisticated. For example it could be configured to perform recognition only after "N" vertices have been added.
public RecognitionSet strokeCompleted(TimedStroke s)
strokeCompleted in interface StrokeRecognizerpublic RecognitionSet strokeModified(TimedStroke s)
strokeModified in interface StrokeRecognizerpublic RecognitionSet strokeStarted(TimedStroke s)
strokeStarted in interface StrokeRecognizerCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.