Package com.myscript.iink
Class OffscreenEditor
java.lang.Object
com.myscript.iink.OffscreenEditor
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionfinal voidaddListener(@NotNull IOffscreenEditorListener listener) Adds the specified listener to this offscreen editor.final String[]addStrokes(@NotNull PointerEvent[] events, boolean processGestures) Adds strokes.final voidclear()Removes all content from the part.final voidclose()final voidErases the specified items.final @NotNull StringExports the specified items.final Stringexport_(@NotNull String[] itemIds, @NotNull MimeType mimeType, @Nullable ParameterSet overrideConfiguration) Exports the specified items.protected voidfinalize()final @NotNull String[]getAvailableItemsTypes(@NotNull String[] itemIds) Returns the available types for the specified items.final @NotNull ConfigurationReturns theConfigurationassociated with this offscreen editor.final @NotNull EngineReturns theEngineto which this offscreen editor is attached.final @Nullable HistoryManagerReturns theHistoryManagerto which this offscreen editor is attached if any.final @NotNull MathSolverControllerReturns theMathSolverControllerassociated with this offscreen editor.final @Nullable ContentPartgetPart()Returns the part managed by this offscreen editor.final @NotNull StringReturns the block id at the root of the current part.final floatReturns the scale to convert input horizontal coordinates unit into mm, such that (X coordinate unit * scaleX = mm).final floatReturns the scale to convert input vertical coordinates unit into mm, such that (Y coordinate unit * scaleY = mm).final @NotNull MimeType[]getSupportedExportMimeTypes(@NotNull String[] itemIds) Returns the supported export formats for specified items.final @NotNull EnumSet<TransformError>getTransformStatus(@NotNull String[] itemIds, @NotNull Transform transform) Checks if a transformation is allowed on the specified items.final booleanisClosed()Tells whether theclose()method has been called.final booleanisIdle()Checks whether part modification operations are over.final voidRemoves the gesture handler from this offscreen editor, if any.final voidremoveListener(@NotNull IOffscreenEditorListener listener) Removes the specified listener from this offscreen editor.final String[]replaceStrokes(@NotNull String[] itemIds, @NotNull PointerEvent[] events) Replaces strokes.final voidsetGestureHandler(@Nullable IOffscreenGestureHandler handler) Registers the specified gesture handler to this offscreen editor.final voidsetItemsType(@NotNull String[] itemIds, @NotNull String type, boolean forceSingleBlock) Sets the classification of the specified items to a given type.final voidsetPart(@Nullable ContentPart part) Sets the part managed by this offscreen editor.final voidTransforms the specified items.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.
-
addListener
Adds the specified listener to this offscreen editor.- Parameters:
listener- the listener to be added.- Throws:
IllegalStateException- when this offscreen editor is closed.IllegalArgumentException- whenlistenerisnull.
-
removeListener
Removes the specified listener from this offscreen editor.- Parameters:
listener- the listener to be removed.- Throws:
IllegalStateException- when this offscreen editor is closed.IllegalArgumentException- whenlistenerisnull.
-
setGestureHandler
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
Returns theEngineto which this offscreen editor is attached.- Returns:
- the engine.
-
getConfiguration
Returns theConfigurationassociated 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
Returns theHistoryManagerto 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
Returns theMathSolverControllerassociated 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
Returns the part managed by this offscreen editor.- Returns:
- the part.
-
setPart
Sets the part managed by this offscreen editor.- Parameters:
part- the part.- Throws:
IllegalStateException- when this offscreen editor is closed.IllegalStateException- whenpartis 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:
trueif 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
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
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 isnull.IllegalStateException- when events contain anullpointer 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 than20strokes and processGestures istrue.NullPointerException- when a pointer event contains anullpointerType.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 isnull.IllegalStateException- when itemIds contains anullitem id.IllegalArgumentException- when itemIds is empty.NullPointerException- when events isnull.IllegalStateException- when events contains anullpointer 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 anullpointerType.UnsupportedOperationException- when event sequence is not allowed.
-
erase
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 isnull.IllegalStateException- when itemIds contains anullitem 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 isnull.IllegalStateException- when itemIds contains anullitem id.IllegalArgumentException- when item ids are not valid.NullPointerException- when transform isnull.
-
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 isnull.IllegalStateException- when itemIds contains anullitem id.IllegalArgumentException- when item ids are not valid.NullPointerException- when transform isnull.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 isnull.IllegalStateException- when itemIds contains anullitem 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 isnull.IllegalStateException- when itemIds contains anullitem id.IllegalArgumentException- when item ids are not valid.NullPointerException- ifmimeTypeisnull.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, seeisIdle().
-
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 isnull.IllegalStateException- when itemIds contains anullitem id.IllegalArgumentException- when item ids are not valid.NullPointerException- ifmimeTypeisnull.IllegalArgumentException- if the mime type is not a textual format.IllegalStateException- if the specified mime type is not supported.IllegalArgumentException- ifoverrideConfigurationis invalid.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().
-
getAvailableItemsTypes
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 isnull.IllegalStateException- when itemIds contains anullitem 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-trueto force converting the items to a single block, otherwisefalse.- Throws:
IllegalStateException- when this offscreen editor is closed.IllegalStateException- when this offscreen editor is not associated with a part.NullPointerException- when itemIds isnull.IllegalStateException- when itemIds contains anullitem id.IllegalArgumentException- when item ids are not valid.NullPointerException- when type isnull.IllegalArgumentException- when items are not compatible with the type.- Since:
- 3.1
-