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 void
addListener
(@NotNull IRecognizerListener listener) Adds the specified listener to this recognizer.final void
clear()
Removes all content from the recognizer.final void
close()
protected void
finalize()
final @NotNull Configuration
Returns theConfiguration
associated with this recognizer.final @NotNull Engine
Returns theEngine
to which this recognizer is attached.final @NotNull String
Returns the result of the recognition since the last call toclear()
.float
Returns the scale to convert input horizontal coordinates unit into mm, such that (X coordinate unit * scaleX = mm).float
Returns 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 boolean
isClosed()
Tells whether theclose()
method has been called.final boolean
isIdle()
Checks whether part modification operations are over.final void
Cancels an ongoing pointer trace.final @Nullable String
pointerDown
(float x, float y, long t, float f) Registers a pointer down event.final void
pointerEvents
(@NotNull PointerEvent[] events) Registers a list of pointer events.final void
pointerMove
(float x, float y, long t, float f) Registers a pointer move event.final void
pointerUp
(float x, float y, long t, float f) Registers a pointer up event.final void
removeListener
(@NotNull IRecognizerListener listener) Removes the specified listener from this recognizer.@NotNull String
toString()
Returns a String representation of the object, with its active part and package.final void
Waits until part modification operations are over.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
-
isClosed
public final boolean isClosed()Tells whether theclose()
method has been called. Once an object is closed any method will throwIllegalStateException
.- Returns:
true
if this object is closed.
-
getEngine
Returns theEngine
to 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
- whenlistener
is null.
-
removeListener
Removes the specified listener from this recognizer.- Parameters:
listener
- the listener to be removed.- Throws:
IllegalStateException
- when this recognizer is closed.IllegalArgumentException
- whenlistener
is null.
-
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 (view coordinates in pixel).y
- pointer event y coordinate (view coordinates in pixel).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
- whenx
is not a number.IllegalArgumentException
- wheny
is not a number.IllegalArgumentException
- whent
exceeds year 9999.IllegalArgumentException
- whenf
is not a number.IllegalArgumentException
- whenf
is 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 (view coordinates in pixel).y
- pointer event y coordinate (view coordinates in pixel).t
- pointer event timestamp, in ms since Unix EPOCH.f
- normalized pressure, in [0,1].- Throws:
IllegalStateException
- when this recognizer is closed.IllegalArgumentException
- whenx
is not a number.IllegalArgumentException
- wheny
is not a number.IllegalArgumentException
- whent
exceeds year 9999.IllegalArgumentException
- whenf
is not a number.IllegalArgumentException
- whenf
is 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 (view coordinates in pixel).y
- pointer event y coordinate (view coordinates in pixel).t
- pointer event timestamp, in ms since Unix EPOCH.f
- normalized pressure, in [0,1].- Throws:
IllegalStateException
- when this recognizer is closed.IllegalArgumentException
- whenx
is not a number.IllegalArgumentException
- wheny
is not a number.IllegalArgumentException
- whent
exceeds year 9999.IllegalArgumentException
- whenf
is not a number.IllegalArgumentException
- whenf
is 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 (view coordinates in pixel).- 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:
true
if 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 theConfiguration
associated 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
- ifmimeType
is 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.
-