Class Recognizer

java.lang.Object
com.myscript.iink.Recognizer
All Implemented Interfaces:
AutoCloseable

public class Recognizer extends Object implements AutoCloseable
The Recognizer runs background handwriting recognition on ink.
Since:
2.1
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    addListener(@NotNull IRecognizerListener listener)
    Adds the specified listener to this recognizer.
    final void
    Removes all content from the recognizer.
    final void
     
    protected void
     
    final @NotNull Configuration
    Returns the Configuration associated with this recognizer.
    final @NotNull Engine
    Returns the Engine to which this recognizer is attached.
    final @NotNull String
    getResult(@NotNull MimeType mimeType)
    Returns the result of the recognition since the last call to clear().
    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
    Tells whether the close() method has been called.
    final boolean
    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
    Removes the specified listener from this recognizer.
    @NotNull String
    Returns a String representation of the object, with its active part and package.
    final void
    Waits until part modification operations are over.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • isClosed

      public final boolean isClosed()
      Tells whether the close() method has been called. Once an object is closed any method will throw IllegalStateException.
      Returns:
      true if this object is closed.
    • getEngine

      @NotNull public final @NotNull Engine getEngine()
      Returns the Engine to which this recognizer is attached.
      Returns:
      the engine.
    • addListener

      public final void addListener(@NotNull @NotNull IRecognizerListener listener)
      Adds the specified listener to this recognizer.
      Parameters:
      listener - the listener to be added.
      Throws:
      IllegalStateException - when this recognizer is closed.
      IllegalArgumentException - when listener is null.
    • removeListener

      public final void removeListener(@NotNull @NotNull IRecognizerListener listener)
      Removes the specified listener from this recognizer.
      Parameters:
      listener - the listener to be removed.
      Throws:
      IllegalStateException - when this recognizer is closed.
      IllegalArgumentException - when listener 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

      @Nullable public final @Nullable String pointerDown(float x, float y, long t, float f)
      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 - when x is not a number.
      IllegalArgumentException - when y is not a number.
      IllegalArgumentException - when t exceeds year 9999.
      IllegalArgumentException - when f is not a number.
      IllegalArgumentException - when f is negative.
      UnsupportedOperationException - when pointerDown() 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 - when x is not a number.
      IllegalArgumentException - when y is not a number.
      IllegalArgumentException - when t exceeds year 9999.
      IllegalArgumentException - when f is not a number.
      IllegalArgumentException - when f is negative.
      IllegalArgumentException - when stroke has too many points.
      UnsupportedOperationException - when pointerDown() 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 - when x is not a number.
      IllegalArgumentException - when y is not a number.
      IllegalArgumentException - when t exceeds year 9999.
      IllegalArgumentException - when f is not a number.
      IllegalArgumentException - when f is negative.
      UnsupportedOperationException - when pointerDown() has not been called before.
    • pointerCancel

      public final void pointerCancel()
      Cancels an ongoing pointer trace.
      Throws:
      IllegalStateException - when this recognizer is closed.
    • pointerEvents

      public final void pointerEvents(@NotNull @NotNull PointerEvent[] events)
      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

      @NotNull public final @NotNull Configuration getConfiguration()
      Returns the Configuration 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

      @NotNull public final @NotNull MimeType[] getSupportedResultMimeTypes()
      Returns the supported result formats.
      Returns:
      an array of the supported mime types.
      Throws:
      IllegalStateException - when this recognizer is closed.
    • getResult

      @NotNull public final @NotNull String getResult(@NotNull @NotNull MimeType mimeType)
      Returns the result of the recognition since the last call to clear().
      Parameters:
      mimeType - the mime type that specifies the output format.
      Returns:
      the exported content.
      Throws:
      IllegalStateException - when this recognizer is closed.
      NullPointerException - if mimeType 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, see isIdle().
    • toString

      @NotNull public @NotNull String toString()
      Returns a String representation of the object, with its active part and package.
      Overrides:
      toString in class Object
      Returns:
      the representation of the object.