Package com.myscript.iink
Class PlaceholderController
java.lang.Object
com.myscript.iink.PlaceholderController
- All Implemented Interfaces:
AutoCloseable
A PlaceholderController allows to add and update placeholders in an editor.
- Since:
- 3.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefines how a placeholder shall behave regarding user interactions. -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull ContentBlockadd(@NotNull Rectangle box, @NotNull String inputFile, @NotNull MimeType mimeType, @NotNull String userData, boolean selectOnAdd, @NotNull PlaceholderController.PlaceholderInteractivityOptions interactivityOptions) Adds a new placeholder image to the part.final voidclose()protected voidfinalize()final @NotNull StringgetUserData(@NotNull ContentSelection placeholder) Returns the user data corresponding to a placeholder image.final booleanisClosed()Tells whether theclose()method has been called.final booleanisPlaceholder(@NotNull ContentSelection selection) Indicates whether a content block is a placeholder.final booleanisVisible(@NotNull ContentSelection placeholder) Returns the visiblity of a placeholder image.final voidsetUserData(@NotNull ContentSelection placeholder, @NotNull String userData) Sets the custom user data of a placeholder image.final voidsetVisible(@NotNull ContentSelection placeholder, boolean visible) Set a placeholder image visibility.final voidupdate(@NotNull ContentSelection placeholder, @NotNull Rectangle box, @NotNull String inputFile, @NotNull MimeType mimeType, @NotNull String userData) Updates the specified placeholder image and moves it to the front.
-
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.
-
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 ofinputFile.userData- custom additional data.selectOnAdd-trueto select the image when it is added, otherwisefalse.interactivityOptions- the allowed interactivity features.- Returns:
- the block associated with the newly added placeholder.
- Throws:
IllegalArgumentException- when the dimensions ofboxare not valid.IllegalArgumentException- whenmimeTypeis not an image type.IllegalStateException- wheninputFileis 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 ofinputFile.userData- custom additional data.- Throws:
IllegalArgumentException- whenplaceholderis not a valid placeholder image.IllegalArgumentException- when the dimensions ofboxare not valid.IllegalArgumentException- whenmimeTypeis not an image type.IllegalStateException- wheninputFileis 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- whenplaceholderis not a valid placeholder image.IllegalStateException- when editor is not associated with a Raw Content part.
-
getUserData
Returns the user data corresponding to a placeholder image.- Parameters:
placeholder- the placeholder image.- Returns:
- the user data.
- Throws:
IllegalArgumentException- whenplaceholderis not a valid placeholder image.IllegalStateException- when editor is not associated with a Raw Content part.
-
setVisible
Set a placeholder image visibility.- Parameters:
placeholder- the placeholder image to update.visible-trueto set the placeholder image visble, otherwise it will be set invisible- Throws:
IllegalArgumentException- whenplaceholderis not a valid placeholder image.IllegalStateException- when editor is not associated with a Raw Content part.
-
isVisible
Returns the visiblity of a placeholder image.- Parameters:
placeholder- the placeholder image to update.- Returns:
trueif the placeholder image is visible, otherwisefalse.- Throws:
IllegalArgumentException- whenplaceholderis not a valid placeholder image.IllegalStateException- when editor is not associated with a Raw Content part.
-
isPlaceholder
Indicates whether a content block is a placeholder.- Parameters:
selection- the contentSelection.- Returns:
trueif selection is a placeholder, otherwisefalse.- Throws:
IllegalStateException- when editor is not associated with a Raw Content part.
-