Package com.myscript.iink
Class ItemIdHelper
java.lang.Object
com.myscript.iink.ItemIdHelper
- All Implemented Interfaces:
AutoCloseable
An ItemIdHelper allows working with item ids (e.g. strokes, glyphs, primitives, objects).
It is associated with an offscreen editor.
- Since:
- 2.1
-
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()final @NotNull String[]combine(@NotNull String[] itemIds1, @NotNull String[] itemIds2, @NotNull ItemIdCombinationModifier mode) Combines two item ids lists.protected voidfinalize()final @NotNull RectanglegetBlockBox(@NotNull String blockId) Returns the bounding box of a block.final @NotNull String[]getBlockChildrenIds(@NotNull String blockId) Returns the children block ids of a block.final @NotNull StringgetBlockParentId(@NotNull String blockId) Returns the parent block id of a block.final @NotNull StringgetBlockType(@NotNull String blockId) Returns the type of a block.final @NotNull StringgetFullItemId(@NotNull String partialItemId) Returns the full item id associated with a partial item id.final @NotNull StringgetItemParentId(@NotNull String itemId) Returns the parent block id of an item.final @NotNull RectanglegetItemsBox(@NotNull String[] itemIds) Returns the bounding box of an item ids list.final @NotNull String[]getItemsByBlockId(@NotNull String blockId) Returns the item ids associated with a given block id.final @NotNull PointerEvent[]getPointsForItemId(@NotNull String itemId) Returns the pointer events of an item.final booleanisClosed()Tells whether theclose()method has been called.final booleanChecks whether a block is empty.final booleanisPartialItem(@NotNull String itemId) Checks if an item is partial.final @NotNull String[]toCanonicalItemIds(@NotNull String[] itemIds) Converts an item ids list to its canonical form.
-
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.
-
isEmpty
Checks whether a block is empty.- Parameters:
blockId- the block id to check.- Returns:
trueif block is empty or invalid or parent editor is not associated with a part, otherwisefalse.- Throws:
IllegalStateException- when this item id helper is closed.
-
getBlockType
Returns the type of a block.- Parameters:
blockId- the identifier of the block.- Returns:
- the block type associated with
blockIdor empty if there is no such block in the current part. - Throws:
IllegalStateException- when this item id helper is closed.- Since:
- 3.0
-
getBlockBox
Returns the bounding box of a block.- Parameters:
blockId- the identifier of the block.- Returns:
- the bounding box (with coordinates in input units) associated with
blockIdor empty if there is no such block in the current part. - Throws:
IllegalStateException- when this item id helper is closed.- Since:
- 3.0
-
getItemsBox
Returns the bounding box of an item ids list.- Parameters:
itemIds- the item ids list.- Returns:
- the bounding box (with coordinates in input units) associated with
itemIds. - Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when itemIds is null.IllegalStateException- when itemIds contains a null item id.IllegalArgumentException- when an item id is invalid.- Since:
- 3.0
-
getBlockChildrenIds
Returns the children block ids of a block.- Parameters:
blockId- the identifier of the block.- Returns:
- the children block ids associated with
blockIdor empty if there is no such block in the current part. - Throws:
IllegalStateException- when this item id helper is closed.- Since:
- 3.0
-
getBlockParentId
Returns the parent block id of a block.- Parameters:
blockId- the identifier of the block.- Returns:
- the parent block id associated with
blockIdor empty if block is root or if there is no such block in the current part. - Throws:
IllegalStateException- when this item id helper is closed.- Since:
- 3.0
-
getItemParentId
Returns the parent block id of an item.- Parameters:
itemId- the identifier of the item.- Returns:
- the parent block id associated with
itemId. - Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when itemId is null.IllegalArgumentException- when item id is invalid.- Since:
- 3.0
-
getItemsByBlockId
Returns the item ids associated with a given block id.- Parameters:
blockId- the identifier of the block.- Returns:
- the item ids associated with
blockIdor empty if there is no such block in the current part. - Throws:
IllegalStateException- when this item id helper is closed.
-
combine
@NotNull public final @NotNull String[] combine(@NotNull @NotNull String[] itemIds1, @NotNull @NotNull String[] itemIds2, @NotNull @NotNull ItemIdCombinationModifier mode) Combines two item ids lists.- Parameters:
itemIds1- the first item ids list to combine.itemIds2- the second item ids list to combine.mode- the modifier specifying the combination mode.- Returns:
- the combined list of item ids.
- Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when itemIds1 is null.NullPointerException- when itemIds2 is null.IllegalStateException- when itemIds1 contains a null item id.IllegalStateException- when itemIds2 contains a null item id.NullPointerException- when mode is null.IllegalArgumentException- when an item id is invalid.IllegalArgumentException- when mode is not a valid ItemIdCombinationModifier value.
-
isPartialItem
Checks if an item is partial.- Parameters:
itemId- the item id to check.- Returns:
trueif item is partial,falseotherwise.- Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when itemId is null.IllegalArgumentException- when item id is invalid.
-
getFullItemId
Returns the full item id associated with a partial item id.- Parameters:
partialItemId- the partial item id.- Returns:
- the full item id.
- Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when partialItemId is null.IllegalArgumentException- when partial item id is invalid.
-
getPointsForItemId
Returns the pointer events of an item.- Parameters:
itemId- the item id.- Returns:
- the pointer events of the item (with coordinates in input units).
- Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when itemId is null.IllegalArgumentException- when item id is invalid.
-
toCanonicalItemIds
Converts an item ids list to its canonical form.- Parameters:
itemIds- the item ids list.- Returns:
- the canonical form of the item ids list.
- Throws:
IllegalStateException- when this item id helper is closed.IllegalStateException- when editor is not associated with a part.NullPointerException- when itemIds is null.IllegalStateException- when itemIds contains a null item id.IllegalArgumentException- when an item id is invalid.
-