Class Editor
- All Implemented Interfaces:
AutoCloseable
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull ContentBlockAdds a new block to the part.final @NotNull ContentBlockaddBlock(float x, float y, @NotNull String blockType, @NotNull MimeType mimeType, @NotNull String data) Adds a new block to the part and fills it with data.final @NotNull ContentBlockAdds a new image to the part.final voidaddListener(@NotNull IEditorListener listener) Adds the specified listener to this editor.final voidapplyStyle(@NotNull ContentSelection selection, @NotNull String style) Applies CSS style properties to a content selection.final booleancanRedo()Tells whether redo can be performed on the part or notfinal booleancanUndo()Tells whether undo can be performed on the part or notvoidclampViewOffset(@NotNull Point viewOffset) Clamps the supplied view offset to the area that ensures standard scrolling behavior.final voidclear()Removes all content from the part.final voidclose()final voidconvert(@Nullable ContentSelection selection, @NotNull ConversionState targetState) Converts the specified content to digital form.final voidcopy(@Nullable ContentSelection selection) Copies a selection to the internal clipboard.final voiddrawStroke(@NotNull PointerEvent[] events, @NotNull ICanvas canvas) Draws pointer events with current editor style settings on the given canvas.final voiderase(@NotNull ContentSelection selection) Erases a content selection from the part.final @NotNull Stringexport_(@Nullable ContentSelection selection, @NotNull MimeType mimeType) Exports the specified content.final Stringexport_(@Nullable ContentSelection selection, @NotNull MimeType mimeType, @Nullable ParameterSet overrideConfiguration) Exports the specified content.final voidexport_(@Nullable ContentSelection selection, @NotNull OutputStream outputStream, @NotNull MimeType mimeType, @Nullable IImagePainter imagePainter) Exports the specified content.final voidexport_(@Nullable ContentSelection selection, @NotNull OutputStream outputStream, @NotNull MimeType mimeType, @Nullable IImagePainter imagePainter, @Nullable ParameterSet overrideConfiguration) Exports the specified content.final voidexport_(@Nullable ContentSelection selection, @NotNull String outputFilePath, @NotNull MimeType mimeType, @Nullable IImagePainter imagePainter) Exports the specified content.final voidexport_(@Nullable ContentSelection selection, @NotNull String outputFilePath, @NotNull MimeType mimeType, @Nullable IImagePainter imagePainter, @Nullable ParameterSet overrideConfiguration) Exports the specified content.final voidexport_(@Nullable ContentSelection selection, @NotNull String outputFilePath, @Nullable IImagePainter imagePainter) Exports the specified content.final voidexport_(@Nullable ContentSelection selection, @NotNull String outputFilePath, @Nullable IImagePainter imagePainter, @Nullable ParameterSet overrideConfiguration) Exports the specified content.protected voidfinalize()final @NotNull EnumSet<ContentSelectionMode>Returns the available selection modes for the active content selection associated with this editor.final @NotNull String[]getAvailableSelectionTypes(@NotNull ContentSelection selection) Returns the available types for a selection.final @Nullable ContentBlockgetBlockById(@NotNull String id) Returns the content block associated with a givenid.@NotNull RectanglegetBox(@NotNull ContentSelection selection) Returns the box that represents the position of a selection.final @NotNull ConfigurationReturns theConfigurationassociated with this editor.@NotNull EnumSet<ConversionState>getConversionState(@NotNull ContentSelection selection) Returns the current conversion state of a selection, as a set of ConversionState values.final @NotNull EngineReturns theEngineto which this editor is attached.final @NotNull String[]getIncludedBlocks(@NotNull ContentSelection selection) Returns the content block ids included in the specified content selection.final @NotNull IndentationLevelsgetIndentationLevels(@NotNull ContentSelection selection) Warning: This is a Beta API.final @NotNull String[]getIntersectingBlocks(@NotNull ContentSelection selection) Returns the content block ids intersecting with the specified content selection.final @NotNull MathSolverControllerReturns theMathSolverControllerassociated with this editor.final @Nullable ContentPartgetPart()Returns the part managed by this editor.final @NotNull PlaceholderControllerReturns thePlaceholderControllerassociated with this editor.final intThe number of operations that can be redone.final intThe number of operations that can be undone.final @NotNull RendererReturns theRendererassociated with this editor.final @Nullable ContentBlockReturns the content block at the root of the current part.final @NotNull ContentSelectionReturns the content selection associated with this editor.final @NotNull ContentSelectionModeReturns the selection mode of the active content selection associated with this editor.final @NotNull MimeType[]getSupportedAddBlockDataMimeTypes(@NotNull String type) Returns the supported formats for adding a new block with data.final @NotNull String[]Returns the types of blocks that can be added to the part.final @NotNull MimeType[]getSupportedExportMimeTypes(@Nullable ContentSelection selection) Returns the supported export formats for specified content.final @NotNull MimeType[]getSupportedImportMimeTypes(@Nullable ContentSelection selection) Returns the supported import formats for specified content.final @NotNull ConversionState[]getSupportedTargetConversionStates(@Nullable ContentSelection selection) Returns the supported target conversion states for the specified content.final @NotNull EnumSet<TextFormat>getSupportedTextFormats(@NotNull ContentSelection selection) Returns the supported text formats for specified content selection.final @NotNull StringgetTheme()Returns the rendering theme style sheet, in CSS format.final @NotNull ToolControllerReturns theToolControllerassociated with this editor.final @NotNull EnumSet<TransformError>getTransformStatus(@Nullable ContentSelection selection, @NotNull Transform transform) Checks if a transformation is allowed on a content selection.final @NotNull StringgetUndoRedoIdAt(int stackIndex) Returns the id of an undo or redo action, based on its position in the stack index.final intReturns the number of operations performed on the part, since content part was opened.final intThe height of the view.final intThe width of the view.final booleanTells if this editor has an active content selection.final @Nullable ContentBlockhitBlock(float x, float y) Return the block at the given position, ornullif there is no block at that position.final @Nullable ContentSelectionhitSelection(float x, float y) Returns the active content selection at the given position, ornullif there is no active content selection at that position.final voidimport_(@NotNull MimeType mimeType, @NotNull String data, @Nullable ContentSelection selection) Imports data into the part or a selection.final voidimport_(@NotNull MimeType mimeType, @NotNull String data, @Nullable ContentSelection selection, @Nullable ParameterSet overrideConfiguration) Imports data into the part or a selection.final voidindent(@NotNull ContentSelection selection, int offset) Warning: This is a Beta API.final booleanisClosed()Tells whether theclose()method has been called.final booleanisEmpty(@Nullable ContentSelection selection) Checks whether a block is empty.final booleanisIdle()Checks whether part modification operations are over.final booleanChecks whether scrolling on the part is allowed at this time.final voidpaste(float x, float y) Pastes the content of the internal clipboard at a given position.final voidpointerCancel(int pointerId) Cancels an ongoing pointer trace.final @Nullable StringpointerDown(float x, float y, long t, float f, float tilt, float orientation, @NotNull PointerType pointerType, int pointerId) Registers a pointer down event.final @Nullable StringpointerDown(float x, float y, long t, float f, @NotNull PointerType pointerType, int pointerId) Registers a pointer down event.final voidpointerEvents(@NotNull PointerEvent[] events, boolean processGestures) Registers a list of pointer events.final voidpointerMove(float x, float y, long t, float f, float tilt, float orientation, @NotNull PointerType pointerType, int pointerId) Registers a pointer move event.final voidpointerMove(float x, float y, long t, float f, @NotNull PointerType pointerType, int pointerId) Registers a pointer move event.final voidpointerUp(float x, float y, long t, float f, float tilt, float orientation, @NotNull PointerType pointerType, int pointerId) Registers a pointer up event.final voidpointerUp(float x, float y, long t, float f, @NotNull PointerType pointerType, int pointerId) Registers a pointer up event.final voidredo()Redo the last action reverted byundoon part.final voidRemoves the gesture handler from this editor, if any.final voidremoveListener(@NotNull IEditorListener listener) Removes the specified listener from this editor.final voidsetFontMetricsProvider(@Nullable IFontMetricsProvider fontMetricsProvider) Sets a font metrics provider to this editor.final voidsetGestureHandler(@Nullable IGestureHandler handler) Registers the specified gesture handler to this editor.final voidsetPart(@Nullable ContentPart part) Sets the part managed by this editor.final voidsetSelection(@Nullable ContentSelection selection) Sets the specified content selection as the active content selection in this editor.final voidsetSelectionMode(@NotNull ContentSelectionMode mode) Sets the specified selection mode to the active content selection associated with this editor.final voidsetSelectionType(@NotNull ContentSelection selection, @NotNull String type, boolean forceSingleBlock) Sets a selection to the specified type.final voidsetTextFormat(@NotNull ContentSelection selection, @NotNull TextFormat format) Applies Format to all text blocks in selection.final voidChanges the rendering theme style sheet, from a buffer containing CSS styling information.final voidsetViewSize(int width, int height) Sets the size of the view.@NotNull StringtoString()Returns a String representation of the object, with its active part and package.@NotNull StringtoString(@NotNull ContentSelection selection) Returns a String representation of a selection, with its part type and box.final voidtransform(@NotNull ContentSelection selection, @NotNull Transform transform) Transforms a selection.final voidundo()Undo the last action on part.final voidWaits until part modification operations are over.
-
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.
-
addListener
Adds the specified listener to this editor.- Parameters:
listener- the listener to be added.- Throws:
IllegalStateException- when this editor is closed.IllegalArgumentException- whenlisteneris null.
-
removeListener
Removes the specified listener from this editor.- Parameters:
listener- the listener to be removed.- Throws:
IllegalStateException- when this editor is closed.IllegalArgumentException- whenlisteneris null.
-
setGestureHandler
Registers the specified gesture handler to this editor.- Parameters:
handler- the gesture handler to be used.- Throws:
IllegalStateException- when this editor is closed.- Since:
- 2.1
-
removeGestureHandler
public final void removeGestureHandler()Removes the gesture handler from this editor, if any.- Throws:
IllegalStateException- when this editor is closed.- Since:
- 2.1
-
setFontMetricsProvider
public final void setFontMetricsProvider(@Nullable @Nullable IFontMetricsProvider fontMetricsProvider) Sets a font metrics provider to this editor.- Parameters:
fontMetricsProvider- aIFontMetricsProvider.- Throws:
IllegalStateException- when this editor is closed.
-
getEngine
Returns theEngineto which this editor is attached.- Returns:
- the engine.
-
getRenderer
Returns theRendererassociated with this editor.- Returns:
- the renderer.
-
getPlaceholderController
Returns thePlaceholderControllerassociated with this editor.Note: do not close the returned object as it is owned by the editor.
- Returns:
- the placeholder controller.
- Since:
- 3.2
-
getMathSolverController
Returns theMathSolverControllerassociated with this editor.Note: do not close the returned object as it is owned by the editor.
- Returns:
- the math solver controller.
- Since:
- 4.0
-
getToolController
Returns theToolControllerassociated with this editor.Note: do not close the returned object as it is owned by the editor.
- Returns:
- the tool controller.
- Since:
- 2.0
-
getPart
Returns the part managed by this editor.- Returns:
- the part.
-
setPart
Sets the part managed by this editor.- Parameters:
part- the part.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when noIFontMetricsProviderhas been set, viasetFontMetricsProvider(IFontMetricsProvider)).IllegalStateException- whenpartis already bound.IllegalStateException- when this editor cannot be configured.
-
clear
public final void clear()Removes all content from the part.- Throws:
IllegalStateException- when this editor is closed.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
canUndo
public final boolean canUndo()Tells whether undo can be performed on the part or not- Returns:
trueif undo can be performed, otherwisefalse.- Throws:
IllegalStateException- when this editor is closed.
-
undo
public final void undo()Undo the last action on part.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when undo operations failed.
-
canRedo
public final boolean canRedo()Tells whether redo can be performed on the part or not- Returns:
trueif redo can be performed, otherwisefalse.- Throws:
IllegalStateException- when this editor is closed.
-
redo
public final void redo()Redo the last action reverted byundoon part.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when redo operations failed.
-
getUndoStackIndex
public final int getUndoStackIndex()Returns the number of operations performed on the part, since content part was opened.Note: the undo stack is partially purged from time to time to control memory consumption. The number of possible undo operations at a given time is provided by
getPossibleUndoCount(), while the total number of operations since content part was opened is provided bygetUndoStackIndex().- Returns:
- the number of operations performed on the part.
- Throws:
IllegalStateException- when this editor is not associated with a part.IllegalStateException- when this editor is closed.- Since:
- 1.1
-
getPossibleUndoCount
public final int getPossibleUndoCount()The number of operations that can be undone.- Returns:
- the number of operations that can be undone.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.- Since:
- 1.1
-
getPossibleRedoCount
public final int getPossibleRedoCount()The number of operations that can be redone.- Returns:
- the number of operations that can be redone.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.- Since:
- 1.2
-
getUndoRedoIdAt
Returns the id of an undo or redo action, based on its position in the stack index. Valid stack index values range from (current stack index - possible undo count) to (current stack index + possible redo count - 1).- Parameters:
stackIndex- the index in the stack of the undo/redo action to retrieve.- Returns:
- the id of the undo/redo operation at the specific index in the undo/redo stack.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- whenstackIndexis invalid.IllegalStateException- when this editor is not associated with a part.- Since:
- 1.2
-
pointerDown
@Nullable public final @Nullable String pointerDown(float x, float y, long t, float f, @NotNull @NotNull PointerType pointerType, int pointerId) Registers a pointer down event.- Parameters:
x- pointer event x coordinate (view coordinates in pixel).y- pointer event y coordinate (view coordinates in pixel).t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].pointerType- the type of input.pointerId- the id of the pointer.- Returns:
- the render item identifier of the starting stroke if any, otherwise
null. - Throws:
IllegalStateException- when this editor is closed.NullPointerException- whenpointerTypeis null.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number or is negative.UnsupportedOperationException- whenpointerDown()has already been called.IllegalStateException- in "Text Document" parts, when no view size is set.
-
pointerDown
@Nullable public final @Nullable String pointerDown(float x, float y, long t, float f, float tilt, float orientation, @NotNull @NotNull PointerType pointerType, int pointerId) Registers a pointer down event.- Parameters:
x- pointer event x coordinate (view coordinates in pixel).y- pointer event y coordinate (view coordinates in pixel).t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].tilt- the tilt in radians.0is perpendicular,Pi/2if flat on screen.orientation- the orientation in radians.0is pointing up,-Pi/2is left,Pi/2is right,+/-Piis down.pointerType- the type of input.pointerId- the id of the pointer.- Returns:
- the render item identifier of the starting stroke if any, otherwise
null. - Throws:
IllegalStateException- when this editor is closed.NullPointerException- whenpointerTypeis null.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number or is negative.IllegalArgumentException- whentiltis not a number or is outside [0, Pi/2].IllegalArgumentException- whenorientationis not a number or is outside [-Pi, Pi].UnsupportedOperationException- whenpointerDown()has already been called.IllegalStateException- in "Text Document" parts, when no view size is set.- Since:
- 4.0
-
pointerMove
public final void pointerMove(float x, float y, long t, float f, @NotNull @NotNull PointerType pointerType, int pointerId) Registers a pointer move event.- Parameters:
x- pointer event x coordinate (view coordinates in pixel).y- pointer event y coordinate (view coordinates in pixel).t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].pointerType- the type of input.pointerId- the id of the pointer.- Throws:
IllegalStateException- when this editor is closed.NullPointerException- whenpointerTypeis null.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number or is negative.IllegalArgumentException- when stroke has too many points.UnsupportedOperationException- whenpointerDown()has not been called before.
-
pointerMove
public final void pointerMove(float x, float y, long t, float f, float tilt, float orientation, @NotNull @NotNull PointerType pointerType, int pointerId) Registers a pointer move event.- Parameters:
x- pointer event x coordinate (view coordinates in pixel).y- pointer event y coordinate (view coordinates in pixel).t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].tilt- the tilt in radians.0is perpendicular,Pi/2if flat on screen.orientation- the orientation in radians.0is pointing up,-Pi/2is left,Pi/2is right,+/-Piis down.pointerType- the type of input.pointerId- the id of the pointer.- Throws:
IllegalStateException- when this editor is closed.NullPointerException- whenpointerTypeis null.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number or is negative.IllegalArgumentException- whentiltis not a number or is outside [0, Pi/2].IllegalArgumentException- whenorientationis not a number or is outside [-Pi, Pi].IllegalArgumentException- when stroke has too many points.UnsupportedOperationException- whenpointerDown()has not been called before.- Since:
- 4.0
-
pointerUp
public final void pointerUp(float x, float y, long t, float f, @NotNull @NotNull PointerType pointerType, int pointerId) Registers a pointer up event.- Parameters:
x- pointer event x coordinate (view coordinates in pixel).y- pointer event y coordinate (view coordinates in pixel).t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].pointerType- the type of input.pointerId- the id of the pointer.- Throws:
IllegalStateException- when this editor is closed.NullPointerException- whenpointerTypeis null.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number or is negative.UnsupportedOperationException- whenpointerDown()has not been called before.
-
pointerUp
public final void pointerUp(float x, float y, long t, float f, float tilt, float orientation, @NotNull @NotNull PointerType pointerType, int pointerId) Registers a pointer up event.- Parameters:
x- pointer event x coordinate (view coordinates in pixel).y- pointer event y coordinate (view coordinates in pixel).t- pointer event timestamp, in ms since Unix EPOCH.f- normalized pressure, in [0,1].tilt- the tilt in radians.0is perpendicular,Pi/2if flat on screen.orientation- the orientation in radians.0is pointing up,-Pi/2is left,Pi/2is right,+/-Piis down.pointerType- the type of input.pointerId- the id of the pointer.- Throws:
IllegalStateException- when this editor is closed.NullPointerException- whenpointerTypeis null.IllegalArgumentException- whenxis not a number.IllegalArgumentException- whenyis not a number.IllegalArgumentException- whentexceeds year 9999.IllegalArgumentException- whenfis not a number or is negative.IllegalArgumentException- whentiltis not a number or is outside [0, Pi/2].IllegalArgumentException- whenorientationis not a number or is outside [-Pi, Pi].UnsupportedOperationException- whenpointerDown()has not been called before.- Since:
- 4.0
-
pointerCancel
public final void pointerCancel(int pointerId) Cancels an ongoing pointer trace.- Parameters:
pointerId- the id of the pointer.- Throws:
IllegalStateException- when this editor is closed.
-
pointerEvents
Registers a list of pointer events.- Parameters:
events- the list of events (view coordinates in pixel).processGestures- tells whether to process gestures or not.- Throws:
IllegalStateException- when this editor is closed.NullPointerException- when events is null.NullPointerException- when a pointer event contains a nullpointerType.IllegalArgumentException- when a pointer event contains incorrect data.IllegalArgumentException- when a stroke has too many points.IllegalArgumentException- when events contain more than20strokes and processGestures istrue.UnsupportedOperationException- when event sequence is not allowed.
-
setViewSize
public final void setViewSize(int width, int height) Sets the size of the view.- Parameters:
width- the view width (view coordinates in pixel).height- the view height (view coordinates in pixel).- Throws:
IllegalStateException- when this editor is closed.IllegalArgumentException- whenwidthorheightis negative.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
getViewWidth
public final int getViewWidth()The width of the view.- Returns:
- the width of the view (view coordinates in pixel).
- Throws:
IllegalStateException- when this editor is closed.- Since:
- 1.3
-
getViewHeight
public final int getViewHeight()The height of the view.- Returns:
- the height of the view (view coordinates in pixel).
- Throws:
IllegalStateException- when this editor is closed.- Since:
- 1.3
-
clampViewOffset
Clamps the supplied view offset to the area that ensures standard scrolling behavior. For "Text" and "Text Document" it allows scrolling one screen outside of the view box downward. For other part types it allows scrolling one screen outside of the view box in each direction.- Parameters:
viewOffset- the view offset to clamp (document coordinates in mm).- Throws:
IllegalStateException- when this editor is closed.
-
setTheme
Changes the rendering theme style sheet, from a buffer containing CSS styling information.- Parameters:
styleSheet- the style sheet, in CSS format.- Throws:
IllegalStateException- when this editor is closed.IllegalArgumentException- whenstyleSheetis invalid.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
getTheme
Returns the rendering theme style sheet, in CSS format.- Returns:
- the style sheet, in CSS format.
- Throws:
IllegalStateException- when this editor is closed.
-
getRootBlock
Returns the content block at the root of the current part.- Returns:
- the root content block.
- Throws:
IllegalStateException- when this editor is closed.
-
getBlockById
Returns the content block associated with a givenid.- Parameters:
id- the identifier of the block.- Returns:
- the content block associated with
idornullif there is no such block in the current part. - Throws:
IllegalStateException- when this editor is closed.
-
isEmpty
Checks whether a block is empty.- Parameters:
selection- the selection to check,nullmeans check the full part.- Returns:
trueif selection is empty or invalid or editor is not associated with a part, otherwisefalse.- Throws:
IllegalStateException- when this editor is closed.
-
getSupportedAddBlockTypes
Returns the types of blocks that can be added to the part.Note: to add a Placeholder block, please use the Editor's PlaceholderController.
- Returns:
- an array of the supported new content block types.
- Throws:
IllegalStateException- when this editor is closed.
-
getSupportedAddBlockDataMimeTypes
@NotNull public final @NotNull MimeType[] getSupportedAddBlockDataMimeTypes(@NotNull @NotNull String type) Returns the supported formats for adding a new block with data.- Parameters:
type- the type of the new block.- Returns:
- an array of the supported mime types.
- Throws:
IllegalStateException- when this editor is closed.
-
addBlock
@NotNull public final @NotNull ContentBlock addBlock(float x, float y, @NotNull @NotNull String blockType) Adds a new block to the part.- Parameters:
x- the approximate x position of the new block (view coordinates in pixel).y- the approximate y position of the new block (view coordinates in pixel).blockType- the type of the new block.- Returns:
- block the newly added block.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- if type is not supported by current part type.IllegalStateException- if editor is not configured.IllegalStateException- if a block already exists at this position, and is not a "Container" block.IllegalStateException- if empty space around position is too small for a new block.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
addBlock
@NotNull public final @NotNull ContentBlock addBlock(float x, float y, @NotNull @NotNull String blockType, @NotNull @NotNull MimeType mimeType, @NotNull @NotNull String data) Adds a new block to the part and fills it with data.- Parameters:
x- the approximate x position of the new block (view coordinates in pixel).y- the approximate y position of the new block (view coordinates in pixel).blockType- the type of the new block.mimeType- the mime type that specifies the format ofdata.data- the data to put in the new block.- Returns:
- block the newly added block.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- if type is not supported by current part type.IllegalStateException- if editor is not configured.IllegalStateException- if a block already exists at this position, and is not a "Container" block.IllegalStateException- if empty space around position is too small for a new block.IllegalStateException- when the content of data could not be added to the new block.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
addImage
@NotNull public final @NotNull ContentBlock addImage(float x, float y, @NotNull @NotNull File inputFile, @NotNull @NotNull MimeType mimeType) throws NullPointerException, IllegalArgumentException, IOException Adds a new image to the part.Note: in a "Text Document" part, this method creates a new "Drawing" block in which the image will be added.
- Parameters:
x- the approximate x position of the new image (view coordinates in pixel).y- the approximate y position of the new image (view coordinates in pixel).inputFile- the image file to add.mimeType- the mime type that specifies the format ofinputFile.- Returns:
- the block associated with the newly added image. In a ContentPart of type "Text Document", this will be a block of type "Drawing".
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- if editor is not configured.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifmimeTypeis null.NullPointerException- ifinputFileis null.IllegalStateException- ifinputFiledoes not exist.IllegalArgumentException- if the mime type is not an image format.IllegalStateException- if a block already exists at this position, and is not a "Container" block.IllegalStateException- if empty space around position is too small for a new block.IOException- if an I/O operation fails.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
erase
Erases a content selection from the part.- Parameters:
selection- the content selection to erase.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalArgumentException- when selection isnull.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
hitBlock
Return the block at the given position, ornullif there is no block at that position.- Parameters:
x- the hit position x coordinate (view coordinates in pixel).y- the hit position y coordinate (view coordinates in pixel).- Returns:
- the block below hit position, or
nullif no block was found. - Throws:
IllegalStateException- when this editor is closed.
-
getSupportedTargetConversionStates
@NotNull public final @NotNull ConversionState[] getSupportedTargetConversionStates(@Nullable @Nullable ContentSelection selection) Returns the supported target conversion states for the specified content.- Parameters:
selection- the selection for which the supported target conversion states are requested,nullmeans convert full part.- Returns:
- an array of the supported target conversion states.
-
convert
public final void convert(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull ConversionState targetState) Converts the specified content to digital form.- Parameters:
selection- the selection to convert,nullmeans convert full part.targetState- the target conversion state for the selection.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- if editor is not configured.IllegalArgumentException- when the target conversion state is not reachable from the current state of the specified selection.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
getSupportedExportMimeTypes
@NotNull public final @NotNull MimeType[] getSupportedExportMimeTypes(@Nullable @Nullable ContentSelection selection) Returns the supported export formats for specified content.- Parameters:
selection- the selection to request,nullmeans full part.- Returns:
- an array of the supported mime types.
- Throws:
IllegalStateException- when this editor is closed.
-
export_
@NotNull public final @NotNull String export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull MimeType mimeType) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.mimeType- the mime type that specifies the output format.- Returns:
- the exported content.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifmimeTypeis null.IllegalArgumentException- if the mime type is not a textual format.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().
-
export_
public final void export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull OutputStream outputStream, @NotNull @NotNull MimeType mimeType, @Nullable @Nullable IImagePainter imagePainter) throws NullPointerException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.outputStream- the stream to export to.mimeType- the MIME type that specifies the desired output format.imagePainter- an image painter that is required for some output formats. If you know that the specified output format does not require it you can leave it null.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifoutputStreamis null.NullPointerException- ifmimeTypeis null.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().
-
export_
public final void export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull OutputStream outputStream, @NotNull @NotNull MimeType mimeType, @Nullable @Nullable IImagePainter imagePainter, @Nullable @Nullable ParameterSet overrideConfiguration) throws NullPointerException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.outputStream- the stream to export to.mimeType- the MIME type that specifies the desired output format.imagePainter- an image painter that is required for some output formats. If you know that the specified output format does not require it you can leave it null.overrideConfiguration- the extra configuration used when exporting.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifoutputStreamis null.NullPointerException- ifmimeTypeis null.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().IllegalArgumentException- ifoverrideConfigurationis invalid.
-
export_
public final void export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull String outputFilePath, @Nullable @Nullable IImagePainter imagePainter) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.outputFilePath- the path of the file to export to.imagePainter- an image painter that is required for some output formats. If you know that the specified output format does not require it you can leave it null.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifoutputFilePathis null.IllegalArgumentException- ifoutputFilePathis invalid.IllegalArgumentException- if the mime type cannot be determined from the output file name.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().
-
export_
public final void export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull String outputFilePath, @NotNull @NotNull MimeType mimeType, @Nullable @Nullable IImagePainter imagePainter) throws NullPointerException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.outputFilePath- the path of the file to export to.mimeType- the mime type that specifies the output format.imagePainter- an image painter that is required for some output formats. If you know that the specified output format does not require it you can leave it null.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifoutputFilePathis null.IllegalArgumentException- ifoutputFilePathis invalid.NullPointerException- ifmimeTypeis null.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().
-
export_
public final String export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull MimeType mimeType, @Nullable @Nullable ParameterSet overrideConfiguration) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.mimeType- the mime type that specifies the output format.overrideConfiguration- the extra configuration used when exporting.- Returns:
- the exported content.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifmimeTypeis null.IllegalArgumentException- if the mime type is not a textual format.IllegalStateException- if there is nothing to export.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().IllegalArgumentException- ifoverrideConfigurationis invalid.- Since:
- 1.2
-
export_
public final void export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull String outputFilePath, @Nullable @Nullable IImagePainter imagePainter, @Nullable @Nullable ParameterSet overrideConfiguration) throws NullPointerException, IllegalArgumentException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.outputFilePath- the path of the file to export to.imagePainter- an image painter that is required for some output formats. If you know that the specified output format does not require it you can leave it null.overrideConfiguration- the extra configuration used when exporting.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifoutputFilePathis null.IllegalArgumentException- ifoutputFilePathis invalid.IllegalArgumentException- if the mime type cannot be determined from the output file name.IllegalStateException- if there is nothing to export.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().IllegalArgumentException- ifoverrideConfigurationis invalid.- Since:
- 1.2
-
export_
public final void export_(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull String outputFilePath, @NotNull @NotNull MimeType mimeType, @Nullable @Nullable IImagePainter imagePainter, @Nullable @Nullable ParameterSet overrideConfiguration) throws NullPointerException, IllegalStateException, IOException Exports the specified content.- Parameters:
selection- the selection to export,nullmeans export full part.outputFilePath- the path of the file to export to.mimeType- the mime type that specifies the output format.imagePainter- an image painter that is required for some output formats. If you know that the specified output format does not require it you can leave it null.overrideConfiguration- the extra configuration used when exporting.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- ifoutputFilePathis null.IllegalArgumentException- ifoutputFilePathis invalid.NullPointerException- ifmimeTypeis null.IllegalStateException- if there is nothing to export.IllegalStateException- if the specified mime type is not supported.IOException- if an I/O operation fails.IllegalStateException- when there are some ongoing operations on the part that prevent export, seeisIdle().IllegalArgumentException- ifoverrideConfigurationis invalid.- Since:
- 1.2
-
getSupportedImportMimeTypes
@NotNull public final @NotNull MimeType[] getSupportedImportMimeTypes(@Nullable @Nullable ContentSelection selection) Returns the supported import formats for specified content.- Parameters:
selection- the selection to request,nullmeans full part.- Returns:
- an array of the supported mime types.
- Throws:
IllegalStateException- when this editor is closed.
-
import_
public final void import_(@NotNull @NotNull MimeType mimeType, @NotNull @NotNull String data, @Nullable @Nullable ContentSelection selection) throws IllegalStateException Imports data into the part or a selection.- Parameters:
mimeType- the mime type that specifies the format ofdata.data- the data to import.selection- the target content selection, or null to let editor detect the target.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when the specified mime type is not supported.IllegalStateException- whendatacould not be imported.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
import_
public final void import_(@NotNull @NotNull MimeType mimeType, @NotNull @NotNull String data, @Nullable @Nullable ContentSelection selection, @Nullable @Nullable ParameterSet overrideConfiguration) throws IllegalStateException Imports data into the part or a selection.- Parameters:
mimeType- the mime type that specifies the format ofdata.data- the data to import.selection- the target content selection, or null to let editor detect the target.overrideConfiguration- the extra configuration used when importing.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when the specified mime type is not supported.IllegalStateException- whendatacould not be imported.IllegalArgumentException- ifoverrideConfigurationis invalid.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
copy
Copies a selection to the internal clipboard.- Parameters:
selection- the selection to copy,nullmeans full part.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when selection cannot be copied.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
paste
Pastes the content of the internal clipboard at a given position. Internal clipboard is filled by callingcopy(ContentSelection). If internal clipboard is empty, this does nothing.Note: Following limitation applies: the part managed by this editor must be a "Text Document" and clipboard must contain a single block, that is not a "Container", from a "Text Document".
- Parameters:
x- the target pasted selection x coordinate (view coordinates in pixel).y- the target pasted selection y coordinate (view coordinates in pixel).- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when content of the clipboard cannot be pasted on the part.UnsupportedOperationException- when a sequence of pointer events is ongoing.
-
isIdle
public final boolean isIdle()Checks whether part modification operations are over.- Returns:
trueif there are no pending operations.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.
-
waitForIdle
public final void waitForIdle()Waits until part modification operations are over.- Throws:
IllegalStateException- when this editor is closed.
-
isScrollAllowed
public final boolean isScrollAllowed()Checks whether scrolling on the part is allowed at this time.- Returns:
trueif scrolling is allowed.- Throws:
IllegalStateException- when this editor is closed.
-
getConfiguration
Returns theConfigurationassociated with this editor.Note: do not close the returned object as it is owned by the editor.
- Returns:
- the editor configuration.
- Throws:
IllegalStateException- when this editor is closed.
-
drawStroke
public final void drawStroke(@NotNull @NotNull PointerEvent[] events, @NotNull @NotNull ICanvas canvas) Draws pointer events with current editor style settings on the given canvas.Note: For use with extra-brushes, first call:
canvas.setKeepGLRenderer(true).- Parameters:
events- the list of events (view coordinates in pixel).canvas- the canvas on which editor should send the drawing commands.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- when events is null.NullPointerException- when canvas is null.NullPointerException- when a pointer event contains a nullpointerType.IllegalArgumentException- when when renderer configuration is invalid.IllegalArgumentException- when a pointer event contains incorrect data.IllegalArgumentException- when a stroke has too many points.UnsupportedOperationException- when events sequence is not allowed.- Since:
- 1.5.1
-
hasSelection
public final boolean hasSelection()Tells if this editor has an active content selection.- Returns:
trueif the editor has an active content selection, otherwisefalse.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.- Since:
- 2.0
-
getSelection
Returns the content selection associated with this editor. Note this content selection is empty if the editor has nothing selected.- Returns:
- the current content selection.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.- Since:
- 2.0
-
setSelection
Sets the specified content selection as the active content selection in this editor. Note it unsets the active content selection if the specified content selection is empty ornull.- Parameters:
selection- the content selection to set as active.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.0
-
hitSelection
Returns the active content selection at the given position, ornullif there is no active content selection at that position.- Parameters:
x- the hit position x coordinate (view coordinates in pixel).y- the hit position y coordinate (view coordinates in pixel).- Returns:
- the content selection below the hit position (i.e. the active content selection),
otherwise
null. - Throws:
IllegalStateException- when this editor is closed.- Since:
- 2.0
-
getIntersectingBlocks
@NotNull public final @NotNull String[] getIntersectingBlocks(@NotNull @NotNull ContentSelection selection) Returns the content block ids intersecting with the specified content selection.- Parameters:
selection- the content selection on which to get the intersecting block ids.- Returns:
- an array that contains all the content block ids intersecting with the content selection.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalArgumentException- when selection isnull.- Since:
- 2.0
-
getIncludedBlocks
@NotNull public final @NotNull String[] getIncludedBlocks(@NotNull @NotNull ContentSelection selection) Returns the content block ids included in the specified content selection.- Parameters:
selection- the content selection on which to get the included block ids.- Returns:
- an array that contains all the content block ids included in the content selection.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalArgumentException- when selection isnull.- Since:
- 2.0
-
getTransformStatus
@NotNull public final @NotNull EnumSet<TransformError> getTransformStatus(@Nullable @Nullable ContentSelection selection, @NotNull @NotNull Transform transform) Checks if a transformation is allowed on a content selection.- Parameters:
selection- the content selection on which to check the transformation.transform- the transformation to check.- Returns:
- an error code from enum
TransformError. - Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.NullPointerException- when transform isnull.- Since:
- 2.0
-
transform
public final void transform(@NotNull @NotNull ContentSelection selection, @NotNull @NotNull Transform transform) Transforms a selection.- Parameters:
selection- the content selection on which to apply the transformation.transform- the transformation to apply.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalArgumentException- when selection isnull.IllegalArgumentException- when transform is not valid for this operation.NullPointerException- when transform isnull.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.0
-
applyStyle
public final void applyStyle(@NotNull @NotNull ContentSelection selection, @NotNull @NotNull String style) Applies CSS style properties to a content selection.- Parameters:
selection- the content selection on which to apply the style.style- the CSS style properties to apply.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.0
-
setTextFormat
public final void setTextFormat(@NotNull @NotNull ContentSelection selection, @NotNull @NotNull TextFormat format) Applies Format to all text blocks in selection.- Parameters:
selection- the content selection on which to apply the format.format- the format to apply.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.0
-
getSupportedTextFormats
@NotNull public final @NotNull EnumSet<TextFormat> getSupportedTextFormats(@NotNull @NotNull ContentSelection selection) Returns the supported text formats for specified content selection.- Parameters:
selection- the content selection on which to get all formats.- Returns:
- an array that contains all the formats of selection.
- Throws:
IllegalStateException- when this editor is closed.- Since:
- 2.0
-
getSelectionMode
Returns the selection mode of the active content selection associated with this editor.- Returns:
- the selection mode of the current content selection.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.- Since:
- 2.0
-
setSelectionMode
Sets the specified selection mode to the active content selection associated with this editor.- Parameters:
mode- the selection mode to set on the active content selection.- Throws:
IllegalArgumentException- when the mode is not supported.IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.0
-
getAvailableSelectionModes
Returns the available selection modes for the active content selection associated with this editor.- Returns:
- an array that contains all the available selection modes.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.- Since:
- 2.0
-
setSelectionType
public final void setSelectionType(@NotNull @NotNull ContentSelection selection, @NotNull @NotNull String type, boolean forceSingleBlock) Sets a selection to the specified type.- Parameters:
selection- the content selection on which to set the type.type- the content type to set. SeegetAvailableSelectionTypes(ContentSelection).forceSingleBlock-trueto force converting the selection to a single block,falseotherwise.- Throws:
IllegalArgumentException- when the type is not supported.IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when selection is not valid.IllegalStateException- when selection is not compatible with the type.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.0.1
-
getAvailableSelectionTypes
@NotNull public final @NotNull String[] getAvailableSelectionTypes(@NotNull @NotNull ContentSelection selection) Returns the available types for a selection.- Parameters:
selection- the content selection on which to get the types.- Returns:
- an array that contains all the available selection types.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when selection is not valid.- Since:
- 2.0.1
-
getIndentationLevels
@NotNull public final @NotNull IndentationLevels getIndentationLevels(@NotNull @NotNull ContentSelection selection) Warning: This is a Beta API.Returns the indentation levels of a selection.
- Parameters:
selection- the content selection on which to get indentation levels.- Returns:
- the indentation levels of the selection.
- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when selection is not valid.- Since:
- 2.1
-
indent
Warning: This is a Beta API.Indents/de-indents a selection by the specified offset. Note resulting indentation levels will be clamped to
[0, max_indentation[. SeegetIndentationLevels(ContentSelection).- Parameters:
selection- the content selection to indent/de-indent.offset- the number of levels to indent/de-indent the selection.- Throws:
IllegalStateException- when this editor is closed.IllegalStateException- when this editor is not associated with a part.IllegalStateException- when selection is not valid.IllegalStateException- when selection is not indentable.UnsupportedOperationException- when a sequence of pointer events is ongoing.- Since:
- 2.1
-
getBox
Returns the box that represents the position of a selection.- Parameters:
selection- the content selection for which the box is requested.- Returns:
- the box of this selection (document coordinates in mm).
- Throws:
IllegalStateException- when this selection is closed.IllegalStateException- when selection is invalid.- Since:
- 3.0
-
getConversionState
@NotNull public @NotNull EnumSet<ConversionState> getConversionState(@NotNull @NotNull ContentSelection selection) Returns the current conversion state of a selection, as a set of ConversionState values.- Parameters:
selection- the content selection for which the conversion state is requested.- Returns:
- the conversion state of this selection.
- Throws:
IllegalStateException- when this selection is closed.IllegalStateException- when selection is invalid.- Since:
- 3.0
-
toString
Returns a String representation of the object, with its active part and package. -
toString
Returns a String representation of a selection, with its part type and box.- Returns:
- the representation of a selection.
- Throws:
IllegalStateException- when the selection is closed.IllegalStateException- when the selection is invalid.- Since:
- 4.0
-