Interface Selection<PS,​SEG,​S>

  • Type Parameters:
    PS - type for StyledDocument's paragraph style; only necessary when using the "selectedDocument" getter or property
    SEG - type for StyledDocument's segment type; only necessary when using the "selectedDocument" getter or property
    S - type for StyledDocument's segment style; only necessary when using the "selectedDocument" getter or property
    All Known Subinterfaces:
    CaretSelectionBind<PS,​SEG,​S>
    All Known Implementing Classes:
    SelectionImpl

    public interface Selection<PS,​SEG,​S>
    An object for encapsulating a selection in a given area.

    "Position" refers to the place in-between characters. In other words, every "|" in "|t|e|x|t|" is a valid position. There are two kinds of positions used here:

    1. getStartPosition()/getEndPosition(), which refers to a position somewhere in the entire area's content. It's bounds are 0 <= x <= area.getLength().
    2. getStartColumnPosition()/getEndColumnPosition(), which refers to a position somewhere in the current paragraph. It's bounds are 0 <= x <= area.getParagraphLength(index).
    Note: when parameter names are "position" without the "column" prefix, they refer to the position in the entire area.

    For type safety, getSelectedDocument() requires the same generic types from StyledDocument. This means that one must write a lot of boilerplate for the generics: Selection<Collection<String>, StyledText<Collection<String>>, Collection<String>> selection. However, this is only necessary if one is using getSelectedDocument() or selectedDocumentProperty(). If you are not going to use the "selectedDocument" getter or property, then just write the much simpler Selection<?, ?, ?> selection.

    See Also:
    CaretSelectionBind, Caret
    • Method Detail

      • getRange

        IndexRange getRange()
        Gets the value of the property range.
        Property description:
        The start and end positions in the area as an IndexRange.
      • getLength

        int getLength()
        Gets the value of the property length.
        Property description:
        The length of the selection
      • getParagraphSpan

        int getParagraphSpan()
        Gets the value of the property paragraphSpan.
        Property description:
        The number of paragraphs the selection spans
      • getSelectedDocument

        StyledDocument<PS,​SEG,​S> getSelectedDocument()
        Gets the value of the property selectedDocument.
        Property description:
      • getSelectedText

        String getSelectedText()
        Gets the value of the property selectedText.
        Property description:
      • getStartPosition

        int getStartPosition()
        Gets the value of the property startPosition.
        Property description:
      • getStartParagraphIndex

        int getStartParagraphIndex()
        Gets the value of the property startParagraphIndex.
        Property description:
      • getStartColumnPosition

        int getStartColumnPosition()
        Gets the value of the property startColumnPosition.
        Property description:
      • getEndPosition

        int getEndPosition()
        Gets the value of the property endPosition.
        Property description:
      • getEndParagraphIndex

        int getEndParagraphIndex()
        Gets the value of the property endParagraphIndex.
        Property description:
      • getEndColumnPosition

        int getEndColumnPosition()
        Gets the value of the property endColumnPosition.
        Property description:
      • getSelectionBounds

        Optional<Bounds> getSelectionBounds()
        Gets the value of the property selectionBounds.
        Property description:
        The selectionBoundsProperty of the selection in the Screen's coordinate system if something is selected and visible in the viewport, or Optional.empty() if selection is not visible in the viewport.
      • isBeingUpdated

        boolean isBeingUpdated()
      • selectRange

        void selectRange​(int startParagraphIndex,
                         int startColPosition,
                         int endParagraphIndex,
                         int endColPosition)
        Selects the given range.

        Caution: see TextEditingArea.getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

      • selectRange

        void selectRange​(int startPosition,
                         int endPosition)
        Selects the given range.
      • updateStartTo

        void updateStartTo​(int position)
      • updateStartTo

        void updateStartTo​(int paragraphIndex,
                           int columnPosition)
      • updateStartByBreaksForward

        void updateStartByBreaksForward​(int numOfBreaks,
                                        BreakIterator breakIterator)
      • updateStartByBreaksBackward

        void updateStartByBreaksBackward​(int numOfBreaks,
                                         BreakIterator breakIterator)
      • updateEndTo

        void updateEndTo​(int position)
      • updateEndTo

        void updateEndTo​(int paragraphIndex,
                         int columnPosition)
      • updateEndByBreaksForward

        void updateEndByBreaksForward​(int numOfBreaks,
                                      BreakIterator breakIterator)
      • updateEndByBreaksBackward

        void updateEndByBreaksBackward​(int numOfBreaks,
                                       BreakIterator breakIterator)
      • selectAll

        void selectAll()
      • selectParagraph

        void selectParagraph​(int paragraphIndex)
      • selectWord

        void selectWord​(int wordPositionInArea)
      • deselect

        default void deselect()
        Clears the selection via selectRange(getStartPosition(), getStartPosition()).
      • configureSelectionPath

        void configureSelectionPath​(SelectionPath path)
        Configures a SelectionPath that will be used to render a portion or all of this selection on a single paragraph. When the selection is a multi-paragraph selection, one path will be used to render that portion of the selection on a paragraph.
      • dispose

        void dispose()
        Disposes the selection and prevents memory leaks
      • getSelectionName

        String getSelectionName()
        Gets the name of this selection. Each selection in an area must have a unique name.
        The name is also used as a StyleClass, so the Selection can be styled using CSS selectors from Path, Shape, and Node eg:
        .styled-text-area .my-selection { -fx-fill: lime; }