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 void
addListener
(@NotNull IOffscreenEditorListener listener) Adds the specified listener to this offscreen editor.final String[]
addStrokes
(@NotNull PointerEvent[] events, boolean processGestures) Adds strokes.final void
clear()
Removes all content from the part.final void
close()
final void
Erases the specified items.final @NotNull String
Exports the specified items.final String
export_
(@NotNull String[] itemIds, @NotNull MimeType mimeType, @Nullable ParameterSet overrideConfiguration) Exports the specified items.protected void
finalize()
final @NotNull String[]
getAvailableItemsTypes
(@NotNull String[] itemIds) Returns the available types for the specified items.final @NotNull Configuration
Returns theConfiguration
associated with this offscreen editor.final @NotNull Engine
Returns theEngine
to which this offscreen editor is attached.final @Nullable HistoryManager
Returns theHistoryManager
to which this offscreen editor is attached if any.final @NotNull MathSolverController
Returns theMathSolverController
associated with this offscreen editor.final @Nullable ContentPart
getPart()
Returns the part managed by this offscreen editor.final @NotNull String
Returns the block id at the root of the current part.final float
Returns the scale to convert input horizontal coordinates unit into mm, such that (X coordinate unit * scaleX = mm).final float
Returns 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 boolean
isClosed()
Tells whether theclose()
method has been called.final boolean
isIdle()
Checks whether part modification operations are over.final void
Removes the gesture handler from this offscreen editor, if any.final void
removeListener
(@NotNull IOffscreenEditorListener listener) Removes the specified listener from this offscreen editor.final String[]
replaceStrokes
(@NotNull String[] itemIds, @NotNull PointerEvent[] events) Replaces strokes.final void
setGestureHandler
(@Nullable IOffscreenGestureHandler handler) Registers the specified gesture handler to this offscreen editor.final void
setItemsType
(@NotNull String[] itemIds, @NotNull String type, boolean forceSingleBlock) Sets the classification of the specified items to a given type.final void
setPart
(@Nullable ContentPart part) Sets the part managed by this offscreen editor.final void
Transforms the specified items.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.
-
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
- whenlistener
isnull
.
-
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
- whenlistener
isnull
.
-
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 theEngine
to which this offscreen editor is attached.- Returns:
- the engine.
-
getConfiguration
Returns theConfiguration
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
Returns theHistoryManager
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
Returns theMathSolverController
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
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
- whenpart
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
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 anull
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 than20
strokes and processGestures istrue
.NullPointerException
- when a pointer event contains anull
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 isnull
.IllegalStateException
- when itemIds contains anull
item id.IllegalArgumentException
- when itemIds is empty.NullPointerException
- when events isnull
.IllegalStateException
- when events contains anull
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 anull
pointerType
.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 anull
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 isnull
.IllegalStateException
- when itemIds contains anull
item 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 anull
item 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 anull
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 isnull
.IllegalStateException
- when itemIds contains anull
item id.IllegalArgumentException
- when item ids are not valid.NullPointerException
- ifmimeType
isnull
.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 anull
item id.IllegalArgumentException
- when item ids are not valid.NullPointerException
- ifmimeType
isnull
.IllegalArgumentException
- if the mime type is not a textual format.IllegalStateException
- if the specified mime type is not supported.IllegalArgumentException
- ifoverrideConfiguration
is 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 anull
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, 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 anull
item id.IllegalArgumentException
- when item ids are not valid.NullPointerException
- when type isnull
.IllegalArgumentException
- when items are not compatible with the type.- Since:
- 3.1
-