Package com.myscript.iink
Class Recognizer
java.lang.Object
com.myscript.iink.Recognizer
- All Implemented Interfaces:
AutoCloseable
The Recognizer runs background handwriting recognition on ink.
- Since:
- 2.1
-
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddListener(@NotNull IRecognizerListener listener) Adds the specified listener to this recognizer.final voidApplies the configuration changes to this recognizer.final voidclear()Removes all content from the recognizer.final voidclose()protected voidfinalize()final @NotNull ConfigurationReturns theConfigurationassociated with this recognizer.final @NotNull EngineReturns theEngineto which this recognizer is attached.final @NotNull StringReturns the result of the recognition since the last call toclear().floatReturns the scale to convert input horizontal coordinates unit into mm, such that (X coordinate unit * scaleX = mm).floatReturns the scale to convert input vertical coordinates unit into mm, such that (Y coordinate unit * scaleY = mm).final @NotNull MimeType[]Returns the supported result formats.final booleanisClosed()Tells whether theclose()method has been called.final booleanisIdle()Checks whether part modification operations are over.final voidCancels an ongoing pointer trace.final @Nullable StringpointerDown(float x, float y, long t, float f) Registers a pointer down event.final voidpointerEvents(@NotNull PointerEvent[] events) Registers a list of pointer events.final voidpointerMove(float x, float y, long t, float f) Registers a pointer move event.final voidpointerUp(float x, float y, long t, float f) Registers a pointer up event.final voidremoveListener(@NotNull IRecognizerListener listener) Removes the specified listener from this recognizer.@NotNull StringtoString()Returns a String representation of the object, with its active part and package.final voidWaits until part modification operations are over.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
public final boolean isClosed()Tells whether theclose()method has been called. Once an object is closed any method will throwIllegalStateException.- Returns:
trueif this object is closed.
-
getEngine
Returns theEngineto which this recognizer is attached.- Returns:
- the engine.
-
addListener
Adds the specified listener to this recognizer.- Parameters:
listener- the listener to be added.- Throws:
IllegalStateException- when this recognizer is closed.IllegalArgumentException- whenlisteneris null.
-
removeListener
Removes the specified listener from this recognizer.- Parameters:
listener- the listener to be removed.- Throws:
IllegalStateException- when this recognizer is closed.IllegalArgumentException- whenlisteneris null.
-
applyConfiguration
public final void applyConfiguration()Applies the configuration changes to this recognizer. For example, if you changed the language of the recognizer, call this API to ensure the recognizer will take the change into account- Throws:
UnsupportedOperationException- when there is an ongoing pointer trace.IllegalStateException- when there are some ongoing operations, seeisIdle().IllegalStateException- when the configuration cannot be applied to this recognizer.IllegalStateException- when this recognizer is closed.- Since:
- 4.5.0
-
clear
public final void clear()Removes all content from the recognizer.- Throws:
UnsupportedOperationException- when there is an ongoing pointer trace.IllegalStateException- when this recognizer is closed.
-
getScaleX
public float getScaleX()Returns the scale to convert input horizontal coordinates unit into mm, such that (X coordinate unit * scaleX = mm).- Returns:
- the horizontal scale.
- Throws:
IllegalStateException- when this recognizer is closed.
-
getScaleY
public float getScaleY()Returns the scale to convert input vertical coordinates unit into mm, such that (Y coordinate unit * scaleY = mm).- Returns:
- the vertical scale.
- Throws:
IllegalStateException- when this recognizer is closed.
-
pointerDown
Registers a pointer down event.- Parameters:
x- pointer event x coordinate.y- pointer event y coordinate.t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].- Returns:
- the render item identifier of the starting stroke if any, otherwise
null. - Throws:
IllegalStateException- when this recognizer is closed.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number.IllegalArgumentException- whenfis negative.UnsupportedOperationException- whenpointerDown()has already been called.
-
pointerMove
public final void pointerMove(float x, float y, long t, float f) Registers a pointer move event.- Parameters:
x- pointer event x coordinate.y- pointer event y coordinate.t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].- Throws:
IllegalStateException- when this recognizer is closed.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number.IllegalArgumentException- whenfis negative.IllegalArgumentException- when stroke has too many points.UnsupportedOperationException- whenpointerDown()has not been called before.
-
pointerUp
public final void pointerUp(float x, float y, long t, float f) Registers a pointer up event.- Parameters:
x- pointer event x coordinate.y- pointer event y coordinate.t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].- Throws:
IllegalStateException- when this recognizer is closed.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number.IllegalArgumentException- whenfis negative.UnsupportedOperationException- whenpointerDown()has not been called before.
-
pointerCancel
public final void pointerCancel()Cancels an ongoing pointer trace.- Throws:
IllegalStateException- when this recognizer is closed.
-
pointerEvents
Registers a list of pointer events.- Parameters:
events- the list of events.- Throws:
IllegalStateException- when this recognizer is closed.NullPointerException- when events is null.IllegalArgumentException- when a pointer event contains incorrect data.IllegalArgumentException- when stroke has too many points.UnsupportedOperationException- when event sequence is not allowed.
-
isIdle
public final boolean isIdle()Checks whether part modification operations are over.- Returns:
trueif there are no pending operations.- Throws:
IllegalStateException- when this recognizer is closed.IllegalStateException- when this recognizer is not associated with a part.
-
waitForIdle
public final void waitForIdle()Waits until part modification operations are over.- Throws:
IllegalStateException- when this recognizer is closed.
-
getConfiguration
Returns theConfigurationassociated with this recognizer.Note: do not close the returned object as it is owned by the recognizer.
- Returns:
- the recognizer configuration.
- Throws:
IllegalStateException- when this recognizer is closed.
-
getSupportedResultMimeTypes
Returns the supported result formats.- Returns:
- an array of the supported mime types.
- Throws:
IllegalStateException- when this recognizer is closed.
-
getResult
Returns the result of the recognition since the last call toclear().- Parameters:
mimeType- the mime type that specifies the output format.- Returns:
- the exported content.
- Throws:
IllegalStateException- when this recognizer is closed.NullPointerException- ifmimeTypeis null.IllegalArgumentException- if the mime type is not a textual format.UnsupportedOperationException- if the specified mime type is not supported.IllegalStateException- when there are some ongoing operations, seeisIdle().
-
toString
Returns a String representation of the object, with its active part and package.
-