Class PlaceholderController

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

public class PlaceholderController extends Object implements AutoCloseable
A PlaceholderController allows to add and update placeholders in an editor.
Since:
3.2
  • 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.
    • add

      @NotNull public final @NotNull ContentBlock add(@NotNull @NotNull Rectangle box, @NotNull @NotNull String inputFile, @NotNull @NotNull MimeType mimeType, @NotNull @NotNull String userData, boolean selectOnAdd, @NotNull @NotNull PlaceholderController.PlaceholderInteractivityOptions interactivityOptions)
      Adds a new placeholder image to the part.
      Parameters:
      box - the position of the new image (view coordinates in pixel).
      inputFile - the image file to add.
      mimeType - the mime type that specifies the format of inputFile.
      userData - custom additional data.
      selectOnAdd - true to select the image when it is added, otherwise false.
      interactivityOptions - the allowed interactivity features.
      Returns:
      the block associated with the newly added placeholder.
      Throws:
      IllegalArgumentException - when the dimensions of box are not valid.
      IllegalArgumentException - when mimeType is not an image type.
      IllegalStateException - when inputFile is not a valid image file.
      IllegalStateException - when editor is not associated with a Raw Content part.
      IllegalStateException - when an I/O operation fails.
    • update

      public final void update(@NotNull @NotNull ContentSelection placeholder, @NotNull @NotNull Rectangle box, @NotNull @NotNull String inputFile, @NotNull @NotNull MimeType mimeType, @NotNull @NotNull String userData)
      Updates the specified placeholder image and moves it to the front.
      Parameters:
      placeholder - the placeholder image to update.
      box - the position of the new image (view coordinates in pixel).
      inputFile - the image file to add.
      mimeType - the mime type that specifies the format of inputFile.
      userData - custom additional data.
      Throws:
      IllegalArgumentException - when placeholder is not a valid placeholder image.
      IllegalArgumentException - when the dimensions of box are not valid.
      IllegalArgumentException - when mimeType is not an image type.
      IllegalStateException - when inputFile is not a valid image file.
      IllegalStateException - when editor is not associated with a Raw Content part.
    • setUserData

      public final void setUserData(@NotNull @NotNull ContentSelection placeholder, @NotNull @NotNull String userData)
      Sets the custom user data of a placeholder image.
      Parameters:
      placeholder - the placeholder image to update.
      userData - custom additional data.
      Throws:
      IllegalArgumentException - when placeholder is not a valid placeholder image.
      IllegalStateException - when editor is not associated with a Raw Content part.
    • getUserData

      @NotNull public final @NotNull String getUserData(@NotNull @NotNull ContentSelection placeholder)
      Returns the user data corresponding to a placeholder image.
      Parameters:
      placeholder - the placeholder image.
      Returns:
      the user data.
      Throws:
      IllegalArgumentException - when placeholder is not a valid placeholder image.
      IllegalStateException - when editor is not associated with a Raw Content part.
    • setVisible

      public final void setVisible(@NotNull @NotNull ContentSelection placeholder, boolean visible)
      Set a placeholder image visibility.
      Parameters:
      placeholder - the placeholder image to update.
      visible - true to set the placeholder image visble, otherwise it will be set invisible
      Throws:
      IllegalArgumentException - when placeholder is not a valid placeholder image.
      IllegalStateException - when editor is not associated with a Raw Content part.
    • isVisible

      public final boolean isVisible(@NotNull @NotNull ContentSelection placeholder)
      Returns the visiblity of a placeholder image.
      Parameters:
      placeholder - the placeholder image to update.
      Returns:
      true if the placeholder image is visible, otherwise false.
      Throws:
      IllegalArgumentException - when placeholder is not a valid placeholder image.
      IllegalStateException - when editor is not associated with a Raw Content part.
    • isPlaceholder

      public final boolean isPlaceholder(@NotNull @NotNull ContentSelection selection)
      Indicates whether a content block is a placeholder.
      Parameters:
      selection - the contentSelection.
      Returns:
      true if selection is a placeholder, otherwise false.
      Throws:
      IllegalStateException - when editor is not associated with a Raw Content part.