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 class
Defines how a placeholder shall behave regarding user interactions. -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull ContentBlock
add
(@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 void
close()
protected void
finalize()
final @NotNull String
getUserData
(@NotNull ContentSelection placeholder) Returns the user data corresponding to a placeholder image.final boolean
isClosed()
Tells whether theclose()
method has been called.final boolean
isPlaceholder
(@NotNull ContentSelection selection) Indicates whether a content block is a placeholder.final boolean
isVisible
(@NotNull ContentSelection placeholder) Returns the visiblity of a placeholder image.final void
setUserData
(@NotNull ContentSelection placeholder, @NotNull String userData) Sets the custom user data of a placeholder image.final void
setVisible
(@NotNull ContentSelection placeholder, boolean visible) Set a placeholder image visibility.final void
update
(@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:
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.
-
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
-true
to 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 ofbox
are not valid.IllegalArgumentException
- whenmimeType
is not an image type.IllegalStateException
- wheninputFile
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 ofinputFile
.userData
- custom additional data.- Throws:
IllegalArgumentException
- whenplaceholder
is not a valid placeholder image.IllegalArgumentException
- when the dimensions ofbox
are not valid.IllegalArgumentException
- whenmimeType
is not an image type.IllegalStateException
- wheninputFile
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
- whenplaceholder
is 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
- whenplaceholder
is 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
-true
to set the placeholder image visble, otherwise it will be set invisible- Throws:
IllegalArgumentException
- whenplaceholder
is 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:
true
if the placeholder image is visible, otherwisefalse
.- Throws:
IllegalArgumentException
- whenplaceholder
is 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:
true
if selection is a placeholder, otherwisefalse
.- Throws:
IllegalStateException
- when editor is not associated with a Raw Content part.
-