Class OffscreenEditor

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

public class OffscreenEditor extends Object implements AutoCloseable
The OffscreenEditor is a service allowing offscreen interactivity. It is the entry point to edit an associated part and receive change notifications.
Since:
2.1
See Also:
  • 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.
    • addListener

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

      public final void removeListener(@NotNull @NotNull IOffscreenEditorListener listener)
      Removes the specified listener from this offscreen editor.
      Parameters:
      listener - the listener to be removed.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalArgumentException - when listener is null.
    • setGestureHandler

      public final void setGestureHandler(@Nullable @Nullable IOffscreenGestureHandler handler)
      Registers the specified gesture handler to this offscreen editor.
      Parameters:
      handler - the gesture handler to be used.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
    • removeGestureHandler

      public final void removeGestureHandler()
      Removes the gesture handler from this offscreen editor, if any.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
    • getEngine

      @NotNull public final @NotNull Engine getEngine()
      Returns the Engine to which this offscreen editor is attached.
      Returns:
      the engine.
    • getConfiguration

      @NotNull public final @NotNull Configuration getConfiguration()
      Returns the Configuration associated with this offscreen editor.

      Note: do not close the returned object as it is owned by the offscreen editor.

      Returns:
      the offscreen editor configuration.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
    • getHistoryManager

      @Nullable public final @Nullable HistoryManager getHistoryManager()
      Returns the HistoryManager to which this offscreen editor is attached if any.

      Note: the returned object is NOT owned by the offscreen editor and should be closed.

      Returns:
      the history manager or null.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      Since:
      3.0
    • getMathSolverController

      @NotNull public final @NotNull MathSolverController getMathSolverController()
      Returns the MathSolverController associated with this offscreen editor.

      Note: do not close the returned object as it is owned by the offscreen editor.

      Returns:
      the math solver controller.
      Since:
      4.0
    • getScaleX

      public final 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 offscreen editor is closed.
    • getScaleY

      public final 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 offscreen editor is closed.
    • getPart

      @Nullable public final @Nullable ContentPart getPart()
      Returns the part managed by this offscreen editor.
      Returns:
      the part.
    • setPart

      public final void setPart(@Nullable @Nullable ContentPart part)
      Sets the part managed by this offscreen editor.
      Parameters:
      part - the part.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when part is already bound.
      IllegalStateException - when this offscreen editor cannot be configured.
    • clear

      public final void clear()
      Removes all content from the part.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
    • isIdle

      public final boolean isIdle()
      Checks whether part modification operations are over.
      Returns:
      true if there are no pending operations.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
    • waitForIdle

      public final void waitForIdle()
      Waits until part modification operations are over.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
    • getRootBlockId

      @NotNull public final @NotNull String getRootBlockId()
      Returns the block id at the root of the current part.
      Returns:
      the root block id, empty if none.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
    • addStrokes

      public final String[] addStrokes(@NotNull @NotNull PointerEvent[] events, boolean processGestures)
      Adds strokes.
      Parameters:
      events - the strokes pointer events (with coordinates in input units).
      processGestures - tells whether to process gestures or not.
      Returns:
      the new item ids.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when events is null.
      IllegalStateException - when events contain a null pointer event.
      IllegalArgumentException - when events is empty.
      IllegalArgumentException - when a pointer event contains incorrect data.
      IllegalArgumentException - when a stroke has too many points.
      IllegalArgumentException - when events contain more than 20 strokes and processGestures is true.
      NullPointerException - when a pointer event contains a null pointerType.
      UnsupportedOperationException - when event sequence is not allowed.
    • replaceStrokes

      public final String[] replaceStrokes(@NotNull @NotNull String[] itemIds, @NotNull @NotNull PointerEvent[] events)
      Replaces strokes.
      Parameters:
      itemIds - the item ids to replace. Unknown ids are ignored.
      events - the replacing strokes pointer events (with coordinates in input units).
      Returns:
      the replacing item ids.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when itemIds is empty.
      NullPointerException - when events is null.
      IllegalStateException - when events contains a null pointer event.
      IllegalArgumentException - when events is empty.
      IllegalArgumentException - when a pointer event contains incorrect data.
      IllegalArgumentException - when a stroke has too many points.
      NullPointerException - when a pointer event contains a null pointerType.
      UnsupportedOperationException - when event sequence is not allowed.
    • erase

      public final void erase(@NotNull @NotNull String[] itemIds)
      Erases the specified items. Unknown ids are ignored.
      Parameters:
      itemIds - the item ids to erase.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
    • getTransformStatus

      @NotNull public final @NotNull EnumSet<TransformError> getTransformStatus(@NotNull @NotNull String[] itemIds, @NotNull @NotNull Transform transform)
      Checks if a transformation is allowed on the specified items.
      Parameters:
      itemIds - the item ids on which to check the transformation.
      transform - the transformation to check.
      Returns:
      an error code from enum TransformError.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
      NullPointerException - when transform is null.
    • transform

      public final void transform(@NotNull @NotNull String[] itemIds, @NotNull @NotNull Transform transform)
      Transforms the specified items.
      Parameters:
      itemIds - the item ids on which to apply the transformation.
      transform - the transformation to apply.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
      NullPointerException - when transform is null.
      IllegalArgumentException - when transform is not valid for this operation.
      IllegalStateException - when the transform is not allowed on the item ids.
    • getSupportedExportMimeTypes

      @NotNull public final @NotNull MimeType[] getSupportedExportMimeTypes(@NotNull @NotNull String[] itemIds)
      Returns the supported export formats for specified items.
      Parameters:
      itemIds - the item ids to request export mime types for, empty means full part.
      Returns:
      an array of the supported mime types, empty if not associated with a part.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
    • export_

      @NotNull public final @NotNull String export_(@NotNull @NotNull String[] itemIds, @NotNull @NotNull MimeType mimeType) throws NullPointerException, IllegalArgumentException, IllegalStateException
      Exports the specified items.
      Parameters:
      itemIds - the item ids to export, empty means full part.
      mimeType - the mime type that specifies the output format.
      Returns:
      the exported content.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
      NullPointerException - if mimeType is null.
      IllegalArgumentException - if the mime type is not a textual format.
      IllegalStateException - if the specified mime type is not supported.
      IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
    • export_

      public final String export_(@NotNull @NotNull String[] itemIds, @NotNull @NotNull MimeType mimeType, @Nullable @Nullable ParameterSet overrideConfiguration) throws NullPointerException, IllegalArgumentException, IllegalStateException
      Exports the specified items.
      Parameters:
      itemIds - the item ids to export, empty means full part.
      mimeType - the mime type that specifies the output format.
      overrideConfiguration - the extra configuration used when exporting.
      Returns:
      the exported content.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
      NullPointerException - if mimeType is null.
      IllegalArgumentException - if the mime type is not a textual format.
      IllegalStateException - if the specified mime type is not supported.
      IllegalArgumentException - if overrideConfiguration is invalid.
      IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
    • getAvailableItemsTypes

      @NotNull public final @NotNull String[] getAvailableItemsTypes(@NotNull @NotNull String[] itemIds)
      Returns the available types for the specified items. Note that this function will wait for pending gesture recognition before returning available types.
      Parameters:
      itemIds - the item ids to request types for.
      Returns:
      an array of the available types.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
      Since:
      3.1
    • setItemsType

      public final void setItemsType(@NotNull @NotNull String[] itemIds, @NotNull @NotNull String type, boolean forceSingleBlock)
      Sets the classification of the specified items to a given type. Note that this function will wait for pending gesture recognition before changing items type.
      Parameters:
      itemIds - the item ids to classify.
      type - the type to apply to the items.
      forceSingleBlock - true to force converting the items to a single block, otherwise false.
      Throws:
      IllegalStateException - when this offscreen editor is closed.
      IllegalStateException - when this offscreen editor is not associated with a part.
      NullPointerException - when itemIds is null.
      IllegalStateException - when itemIds contains a null item id.
      IllegalArgumentException - when item ids are not valid.
      NullPointerException - when type is null.
      IllegalArgumentException - when items are not compatible with the type.
      Since:
      3.1