Class ItemIdHelper

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

public class ItemIdHelper extends Object implements 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 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.
    • isEmpty

      public final boolean isEmpty(@NotNull @NotNull String blockId)
      Checks whether a block is empty.
      Parameters:
      blockId - the block id to check.
      Returns:
      true if block is empty or invalid or parent editor is not associated with a part, otherwise false.
      Throws:
      IllegalStateException - when this item id helper is closed.
    • getBlockType

      @NotNull public final @NotNull String getBlockType(@NotNull @NotNull String blockId)
      Returns the type of a block.
      Parameters:
      blockId - the identifier of the block.
      Returns:
      the block type associated with blockId or empty if there is no such block in the current part.
      Throws:
      IllegalStateException - when this item id helper is closed.
      Since:
      3.0
    • getBlockBox

      @NotNull public final @NotNull Rectangle getBlockBox(@NotNull @NotNull String blockId)
      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 blockId or empty if there is no such block in the current part.
      Throws:
      IllegalStateException - when this item id helper is closed.
      Since:
      3.0
    • getItemsBox

      @NotNull public final @NotNull Rectangle getItemsBox(@NotNull @NotNull String[] itemIds)
      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

      @NotNull public final @NotNull String[] getBlockChildrenIds(@NotNull @NotNull String blockId)
      Returns the children block ids of a block.
      Parameters:
      blockId - the identifier of the block.
      Returns:
      the children block ids associated with blockId or empty if there is no such block in the current part.
      Throws:
      IllegalStateException - when this item id helper is closed.
      Since:
      3.0
    • getBlockParentId

      @NotNull public final @NotNull String getBlockParentId(@NotNull @NotNull String blockId)
      Returns the parent block id of a block.
      Parameters:
      blockId - the identifier of the block.
      Returns:
      the parent block id associated with blockId or 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

      @NotNull public final @NotNull String getItemParentId(@NotNull @NotNull String itemId)
      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

      @NotNull public final @NotNull String[] getItemsByBlockId(@NotNull @NotNull String blockId)
      Returns the item ids associated with a given block id.
      Parameters:
      blockId - the identifier of the block.
      Returns:
      the item ids associated with blockId or 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

      public final boolean isPartialItem(@NotNull @NotNull String itemId)
      Checks if an item is partial.
      Parameters:
      itemId - the item id to check.
      Returns:
      true if item is partial, false otherwise.
      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

      @NotNull public final @NotNull String getFullItemId(@NotNull @NotNull String partialItemId)
      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

      @NotNull public final @NotNull PointerEvent[] getPointsForItemId(@NotNull @NotNull String itemId)
      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

      @NotNull public final @NotNull String[] toCanonicalItemIds(@NotNull @NotNull String[] itemIds)
      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.