Class Editor

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Editor
    extends java.lang.Object
    implements java.lang.AutoCloseable
    The Editor is the entry point by which modification is associated to a part. An editor is associated with a single part.
    See Also:
    ContentPart
    • Method Detail

      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • close

        public final void close()
        Specified by:
        close in interface java.lang.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.
      • addListener

        public final void addListener​(@NotNull
                                      @NotNull IEditorListener listener)
        Adds the specified listener to this editor.
        Parameters:
        listener - the listener to be added.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalArgumentException - when listener is null.
      • removeListener

        public final void removeListener​(@NotNull
                                         @NotNull IEditorListener listener)
        Removes the specified listener from this editor.
        Parameters:
        listener - the listener to be removed.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalArgumentException - when listener is null.
      • setFontMetricsProvider

        public final void setFontMetricsProvider​(@Nullable
                                                 @Nullable IFontMetricsProvider fontMetricsProvider)
        Sets a font metrics provider to this editor.
        Parameters:
        fontMetricsProvider - a IFontMetricsProvider.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • getEngine

        @NotNull
        public final @NotNull Engine getEngine()
        Returns the Engine to which this editor is attached.
        Returns:
        the engine.
      • getRenderer

        @NotNull
        public final @NotNull Renderer getRenderer()
        Returns the Renderer associated with this editor.
        Returns:
        the renderer.
      • getToolController

        @NotNull
        public final @NotNull ToolController getToolController()
        Returns the ToolController associated 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

        @Nullable
        public final @Nullable ContentPart getPart()
        Returns the part managed by this editor.
        Returns:
        the part.
      • setPart

        public final void setPart​(@Nullable
                                  @Nullable ContentPart part)
        Sets the part managed by this editor.
        Parameters:
        part - the part.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when no IFontMetricsProvider has been set, via setFontMetricsProvider(IFontMetricsProvider)).
        java.lang.IllegalStateException - when part is already bound.
        java.lang.IllegalStateException - when this editor cannot be configured.
      • clear

        public final void clear()
        Removes all content from the part.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • canUndo

        public final boolean canUndo()
        Tells whether undo can be performed on the part or not
        Returns:
        true if undo can be performed, otherwise false.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • undo

        public final void undo()
        Undo the last action on part.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when undo operations failed.
      • canRedo

        public final boolean canRedo()
        Tells whether redo can be performed on the part or not
        Returns:
        true if redo can be performed, otherwise false.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • redo

        public final void redo()
        Redo the last action reverted by undo on part.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.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 by getUndoStackIndex().

        Returns:
        the number of operations performed on the part.
        Throws:
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        1.2
      • getUndoRedoIdAt

        @NotNull
        public final @NotNull java.lang.String getUndoRedoIdAt​(int stackIndex)
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when stackIndex is invalid.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        1.2
      • pointerDown

        @Nullable
        public final @Nullable java.lang.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.
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.NullPointerException - when pointerType is null.
        java.lang.IllegalArgumentException - when x is not a number.
        java.lang.IllegalArgumentException - when y is not a number.
        java.lang.IllegalArgumentException - when t exceeds year 9999.
        java.lang.IllegalArgumentException - when f is not a number.
        java.lang.IllegalArgumentException - when f is negative.
        java.lang.UnsupportedOperationException - when pointerDown() has already been called.
        java.lang.IllegalStateException - in "Text Document" parts, when no view size is set.
      • 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.
        pointerType - the type of input.
        pointerId - the id of the pointer.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.NullPointerException - when pointerType is null.
        java.lang.IllegalArgumentException - when x is not a number.
        java.lang.IllegalArgumentException - when y is not a number.
        java.lang.IllegalArgumentException - when t exceeds year 9999.
        java.lang.IllegalArgumentException - when f is not a number.
        java.lang.IllegalArgumentException - when f is negative.
        java.lang.UnsupportedOperationException - when pointerDown() has not been called before.
      • 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.
        pointerType - the type of input.
        pointerId - the id of the pointer.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.NullPointerException - when pointerType is null.
        java.lang.IllegalArgumentException - when x is not a number.
        java.lang.IllegalArgumentException - when y is not a number.
        java.lang.IllegalArgumentException - when t exceeds year 9999.
        java.lang.IllegalArgumentException - when f is not a number.
        java.lang.IllegalArgumentException - when f is negative.
        java.lang.UnsupportedOperationException - when pointerDown() has not been called before.
      • pointerCancel

        public final void pointerCancel​(int pointerId)
        Cancels an ongoing pointer trace.
        Parameters:
        pointerId - the id of the pointer.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • pointerEvents

        public final void pointerEvents​(@NotNull
                                        @NotNull PointerEvent[] events,
                                        boolean processGestures)
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.NullPointerException - when events is null.
        java.lang.NullPointerException - when a pointer event contains a null pointerType.
        java.lang.IllegalArgumentException - when a pointer event contains incorrect data.
        java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalArgumentException - when width or height is negative.
      • getViewWidth

        public final int getViewWidth()
        The width of the view.
        Returns:
        the width of the view (view coordinates in pixel).
        Throws:
        java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        Since:
        1.3
      • clampViewOffset

        public void clampViewOffset​(@NotNull
                                    @NotNull Point viewOffset)
        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:
        java.lang.IllegalStateException - when this editor is closed.
      • setTheme

        public final void setTheme​(@NotNull
                                   @NotNull java.lang.String styleSheet)
        Changes the rendering theme style sheet, from a buffer containing CSS styling information.
        Parameters:
        styleSheet - the style sheet, in CSS format.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalArgumentException - when styleSheet is invalid.
      • getTheme

        @NotNull
        public final @NotNull java.lang.String getTheme()
        Returns the rendering theme style sheet, in CSS format.
        Returns:
        the style sheet, in CSS format.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • getRootBlock

        @Nullable
        public final @Nullable ContentBlock getRootBlock()
        Returns the content block at the root of the current part.
        Returns:
        the root content block.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • getBlockById

        @Nullable
        public final @Nullable ContentBlock getBlockById​(@NotNull
                                                         @NotNull java.lang.String id)
        Returns the content block associated with a given id.
        Parameters:
        id - the identifier of the block.
        Returns:
        the content block associated with id or null if there is no such block in the current part.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • isEmpty

        public final boolean isEmpty​(@Nullable
                                     @Nullable ContentSelection selection)
        Checks whether a block is empty.
        Parameters:
        selection - the selection to check, null means check the full part.
        Returns:
        true if selection is empty or invalid or editor is not associated with a part, otherwise false.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • getSupportedAddBlockTypes

        @NotNull
        public final @NotNull java.lang.String[] getSupportedAddBlockTypes()
        Returns the types of blocks that can be added to the part.

        Note: new blocks can be added only to a content part with type "Text Document". "Text" blocks are automatically created but other blocks must be added via addBlock(float, float, String). Blocks cannot be added on other types of part.

        Returns:
        an array of the supported new content block types.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • getSupportedAddBlockDataMimeTypes

        @NotNull
        public final @NotNull MimeType[] getSupportedAddBlockDataMimeTypes​(@NotNull
                                                                           @NotNull java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
      • addBlock

        @NotNull
        public final @NotNull ContentBlock addBlock​(float x,
                                                    float y,
                                                    @NotNull
                                                    @NotNull java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - if type is not supported by current part type.
        java.lang.IllegalStateException - if editor is not configured.
        java.lang.IllegalStateException - if a block already exists at this position, and is not a "Container" block.
        java.lang.IllegalStateException - if empty space around position is too small for a new block.
      • addBlock

        @NotNull
        public final @NotNull ContentBlock addBlock​(float x,
                                                    float y,
                                                    @NotNull
                                                    @NotNull java.lang.String blockType,
                                                    @NotNull
                                                    @NotNull MimeType mimeType,
                                                    @NotNull
                                                    @NotNull java.lang.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 of data.
        data - the data to put in the new block.
        Returns:
        block the newly added block.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - if type is not supported by current part type.
        java.lang.IllegalStateException - if editor is not configured.
        java.lang.IllegalStateException - if a block already exists at this position, and is not a "Container" block.
        java.lang.IllegalStateException - if empty space around position is too small for a new block.
        java.lang.IllegalStateException - when the content of data could not be added to the new block.
      • addImage

        @NotNull
        public final @NotNull ContentBlock addImage​(float x,
                                                    float y,
                                                    @NotNull
                                                    @NotNull java.io.File inputFile,
                                                    @NotNull
                                                    @NotNull MimeType mimeType)
                                             throws java.lang.NullPointerException,
                                                    java.lang.IllegalArgumentException,
                                                    java.io.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 of inputFile.
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - if editor is not configured.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.NullPointerException - if inputFile is null.
        java.lang.IllegalStateException - if inputFile does not exist.
        java.lang.IllegalArgumentException - if the mime type is not an image format.
        java.lang.IllegalStateException - if a block already exists at this position, and is not a "Container" block.
        java.lang.IllegalStateException - if empty space around position is too small for a new block.
        java.io.IOException - if an I/O operation fails.
      • erase

        public final void erase​(@NotNull
                                @NotNull ContentSelection selection)
        Erases a content selection from the part.
        Parameters:
        selection - the content selection to erase.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalArgumentException - when selection is null.
      • hitBlock

        @Nullable
        public final @Nullable ContentBlock hitBlock​(float x,
                                                     float y)
        Return the block at the given position, or null if 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 null if no block was found.
        Throws:
        java.lang.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, null means 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, null means convert full part.
        targetState - the target conversion state for the selection.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - if editor is not configured.
        java.lang.IllegalArgumentException - when the target conversion state is not reachable from the current state of the specified selection.
      • 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, null means full part.
        Returns:
        an array of the supported mime types.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • export_

        @NotNull
        public final @NotNull java.lang.String export_​(@Nullable
                                                       @Nullable ContentSelection selection,
                                                       @NotNull
                                                       @NotNull MimeType mimeType)
                                                throws java.lang.NullPointerException,
                                                       java.lang.IllegalArgumentException,
                                                       java.lang.IllegalStateException,
                                                       java.lang.UnsupportedOperationException,
                                                       java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means export full part.
        mimeType - the mime type that specifies the output format.
        Returns:
        the exported content.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.IllegalArgumentException - if the mime type is not a textual format.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
      • export_

        public final void export_​(@Nullable
                                  @Nullable ContentSelection selection,
                                  @NotNull
                                  @NotNull java.io.OutputStream outputStream,
                                  @NotNull
                                  @NotNull MimeType mimeType,
                                  @Nullable
                                  @Nullable IImagePainter imagePainter)
                           throws java.lang.NullPointerException,
                                  java.lang.IllegalStateException,
                                  java.lang.UnsupportedOperationException,
                                  java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if outputStream is null.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
      • export_

        public final void export_​(@Nullable
                                  @Nullable ContentSelection selection,
                                  @NotNull
                                  @NotNull java.io.OutputStream outputStream,
                                  @NotNull
                                  @NotNull MimeType mimeType,
                                  @Nullable
                                  @Nullable IImagePainter imagePainter,
                                  @Nullable
                                  @Nullable ParameterSet overrideConfiguration)
                           throws java.lang.NullPointerException,
                                  java.lang.IllegalStateException,
                                  java.lang.UnsupportedOperationException,
                                  java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if outputStream is null.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
        java.lang.IllegalArgumentException - if overrideConfiguration is invalid.
      • export_

        public final void export_​(@Nullable
                                  @Nullable ContentSelection selection,
                                  @NotNull
                                  @NotNull java.lang.String outputFilePath,
                                  @Nullable
                                  @Nullable IImagePainter imagePainter)
                           throws java.lang.NullPointerException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.IllegalStateException,
                                  java.lang.UnsupportedOperationException,
                                  java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if outputFilePath is null.
        java.lang.IllegalArgumentException - if outputFilePath is invalid.
        java.lang.IllegalArgumentException - if the mime type cannot be determined from the output file name.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
      • export_

        public final void export_​(@Nullable
                                  @Nullable ContentSelection selection,
                                  @NotNull
                                  @NotNull java.lang.String outputFilePath,
                                  @NotNull
                                  @NotNull MimeType mimeType,
                                  @Nullable
                                  @Nullable IImagePainter imagePainter)
                           throws java.lang.NullPointerException,
                                  java.lang.IllegalStateException,
                                  java.lang.UnsupportedOperationException,
                                  java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if outputFilePath is null.
        java.lang.IllegalArgumentException - if outputFilePath is invalid.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
      • export_

        public final java.lang.String export_​(@Nullable
                                              @Nullable ContentSelection selection,
                                              @NotNull
                                              @NotNull MimeType mimeType,
                                              @Nullable
                                              @Nullable ParameterSet overrideConfiguration)
                                       throws java.lang.NullPointerException,
                                              java.lang.IllegalArgumentException,
                                              java.lang.IllegalStateException,
                                              java.lang.UnsupportedOperationException,
                                              java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means export full part.
        mimeType - the mime type that specifies the output format.
        overrideConfiguration - the extra configuration used when exporting.
        Returns:
        the exported content.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.IllegalArgumentException - if the mime type is not a textual format.
        java.lang.IllegalStateException - if there is nothing to export.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
        java.lang.IllegalArgumentException - if overrideConfiguration is invalid.
        Since:
        1.2
      • export_

        public final void export_​(@Nullable
                                  @Nullable ContentSelection selection,
                                  @NotNull
                                  @NotNull java.lang.String outputFilePath,
                                  @Nullable
                                  @Nullable IImagePainter imagePainter,
                                  @Nullable
                                  @Nullable ParameterSet overrideConfiguration)
                           throws java.lang.NullPointerException,
                                  java.lang.IllegalArgumentException,
                                  java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if outputFilePath is null.
        java.lang.IllegalArgumentException - if outputFilePath is invalid.
        java.lang.IllegalArgumentException - if the mime type cannot be determined from the output file name.
        java.lang.IllegalStateException - if there is nothing to export.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
        java.lang.IllegalArgumentException - if overrideConfiguration is invalid.
        Since:
        1.2
      • export_

        public final void export_​(@Nullable
                                  @Nullable ContentSelection selection,
                                  @NotNull
                                  @NotNull java.lang.String outputFilePath,
                                  @NotNull
                                  @NotNull MimeType mimeType,
                                  @Nullable
                                  @Nullable IImagePainter imagePainter,
                                  @Nullable
                                  @Nullable ParameterSet overrideConfiguration)
                           throws java.lang.NullPointerException,
                                  java.lang.IllegalStateException,
                                  java.lang.UnsupportedOperationException,
                                  java.io.IOException
        Exports the specified content.
        Parameters:
        selection - the selection to export, null means 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - if outputFilePath is null.
        java.lang.IllegalArgumentException - if outputFilePath is invalid.
        java.lang.NullPointerException - if mimeType is null.
        java.lang.IllegalStateException - if there is nothing to export.
        java.lang.UnsupportedOperationException - if the specified mime type is not supported.
        java.io.IOException - if an I/O operation fails.
        java.lang.IllegalStateException - when there are some ongoing operations on the part that prevent export, see isIdle().
        java.lang.IllegalArgumentException - if overrideConfiguration is 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, null means full part.
        Returns:
        an array of the supported mime types.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • import_

        public final void import_​(@NotNull
                                  @NotNull MimeType mimeType,
                                  @NotNull
                                  @NotNull java.lang.String data,
                                  @Nullable
                                  @Nullable ContentSelection selection)
                           throws java.lang.IllegalStateException
        Imports data into the part or a selection.
        Parameters:
        mimeType - the mime type that specifies the format of data.
        data - the data to import.
        selection - the target content selection, or null to let editor detect the target.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - when the specified mime type is not supported.
        java.lang.IllegalStateException - when data could not be imported.
      • import_

        public final void import_​(@NotNull
                                  @NotNull MimeType mimeType,
                                  @NotNull
                                  @NotNull java.lang.String data,
                                  @Nullable
                                  @Nullable ContentSelection selection,
                                  @Nullable
                                  @Nullable ParameterSet overrideConfiguration)
                           throws java.lang.IllegalStateException
        Imports data into the part or a selection.
        Parameters:
        mimeType - the mime type that specifies the format of data.
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - when the specified mime type is not supported.
        java.lang.IllegalStateException - when data could not be imported.
        java.lang.IllegalArgumentException - if overrideConfiguration is invalid.
      • copy

        public final void copy​(@Nullable
                               @Nullable ContentSelection selection)
                        throws java.lang.IllegalStateException
        Copies a selection to the internal clipboard.
        Parameters:
        selection - the selection to copy, null means full part.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - when selection cannot be copied.
      • paste

        public final void paste​(float x,
                                float y)
                         throws java.lang.IllegalStateException
        Pastes the content of the internal clipboard at a given position. Internal clipboard is filled by calling copy(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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - when content of the clipboard cannot be pasted on the part.
      • isIdle

        public final boolean isIdle()
        Checks whether part modification operations are over.
        Returns:
        true if there are no pending operations.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
      • waitForIdle

        public final void waitForIdle()
        Waits until part modification operations are over.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • isScrollAllowed

        public final boolean isScrollAllowed()
        Checks whether scrolling on the part is allowed at this time.
        Returns:
        true if scrolling is allowed.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
      • getConfiguration

        @NotNull
        public final @NotNull Configuration getConfiguration()
        Returns the Configuration associated with this editor.

        Note: do not close the returned object as it is owned by the editor.

        Returns:
        the editor configuration.
        Throws:
        java.lang.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.
        Parameters:
        events - the list of events (view coordinates in pixel).
        canvas - the canvas on which editor should send the drawing commands.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - when events is null.
        java.lang.NullPointerException - when a pointer event contains a null pointerType.
        java.lang.IllegalArgumentException - when when renderer configuration is invalid.
        java.lang.IllegalArgumentException - when a pointer event contains incorrect data.
        java.lang.UnsupportedOperationException - when events sequence is invalid.
        Since:
        1.5.1
      • hasSelection

        public final boolean hasSelection()
        Tells if this editor has an active content selection.
        Returns:
        true if the editor has an active content selection, otherwise false.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • getSelection

        @NotNull
        public final @NotNull ContentSelection 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • setSelection

        public final void setSelection​(@Nullable
                                       @Nullable ContentSelection selection)
        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 or null.
        Parameters:
        selection - the content selection to set as active.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • hitSelection

        @Nullable
        public final @Nullable ContentSelection hitSelection​(float x,
                                                             float y)
        Returns the active content selection at the given position, or null if 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:
        java.lang.IllegalStateException - when this editor is closed.
        Since:
        2.0
      • getIntersectingBlocks

        @NotNull
        public final @NotNull java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalArgumentException - when selection is null.
        Since:
        2.0
      • getIncludedBlocks

        @NotNull
        public final @NotNull java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalArgumentException - when selection is null.
        Since:
        2.0
      • getTransformStatus

        @NotNull
        public final @NotNull java.util.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.NullPointerException - when transform is null.
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalArgumentException - when selection is null.
        java.lang.IllegalArgumentException - when transform is not valid for this operation.
        java.lang.NullPointerException - when transform is null.
        Since:
        2.0
      • applyStyle

        public final void applyStyle​(@NotNull
                                     @NotNull ContentSelection selection,
                                     @NotNull
                                     @NotNull java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • getSupportedTextFormats

        @NotNull
        public final @NotNull java.util.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:
        java.lang.IllegalStateException - when this editor is closed.
        Since:
        2.0
      • getSelectionMode

        @NotNull
        public final @NotNull ContentSelectionMode getSelectionMode()
        Returns the selection mode of the active content selection associated with this editor.
        Returns:
        the selection mode of the current content selection.
        Throws:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • setSelectionMode

        public final void setSelectionMode​(@NotNull
                                           @NotNull ContentSelectionMode mode)
        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:
        java.lang.IllegalArgumentException - when the mode is not supported.
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • getAvailableSelectionModes

        @NotNull
        public final @NotNull java.util.EnumSet<ContentSelectionMode> 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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        Since:
        2.0
      • setSelectionType

        public final void setSelectionType​(@NotNull
                                           @NotNull ContentSelection selection,
                                           @NotNull
                                           @NotNull java.lang.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. See #getAvailableSelectionTypes().
        forceSingleBlock - true to force converting the selection to a single block, false otherwise.
        Throws:
        java.lang.IllegalArgumentException - when the type is not supported.
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - when selection is not valid.
        java.lang.IllegalStateException - when selection is not compatible with the type.
        Since:
        2.0.1
      • getAvailableSelectionTypes

        @NotNull
        public final @NotNull java.lang.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:
        java.lang.IllegalStateException - when this editor is closed.
        java.lang.IllegalStateException - when this editor is not associated with a part.
        java.lang.IllegalStateException - when selection is not valid.
        Since:
        2.0.1