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
    • Property Detail

      • range

        javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> rangeProperty
        The start and end positions in the area as an IndexRange.
        See Also:
        getRange()
      • length

        javafx.beans.value.ObservableValue<java.lang.Integer> lengthProperty
        The length of the selection
        See Also:
        getLength()
      • paragraphSpan

        javafx.beans.value.ObservableValue<java.lang.Integer> paragraphSpanProperty
        The number of paragraphs the selection spans
        See Also:
        getParagraphSpan()
      • selectedText

        javafx.beans.value.ObservableValue<java.lang.String> selectedTextProperty
        See Also:
        getSelectedText()
      • startPosition

        javafx.beans.value.ObservableValue<java.lang.Integer> startPositionProperty
        See Also:
        getStartPosition()
      • startParagraphIndex

        javafx.beans.value.ObservableValue<java.lang.Integer> startParagraphIndexProperty
        See Also:
        getStartParagraphIndex()
      • startColumnPosition

        javafx.beans.value.ObservableValue<java.lang.Integer> startColumnPositionProperty
        See Also:
        getStartColumnPosition()
      • endPosition

        javafx.beans.value.ObservableValue<java.lang.Integer> endPositionProperty
        See Also:
        getEndPosition()
      • endParagraphIndex

        javafx.beans.value.ObservableValue<java.lang.Integer> endParagraphIndexProperty
        See Also:
        getEndParagraphIndex()
      • endColumnPosition

        javafx.beans.value.ObservableValue<java.lang.Integer> endColumnPositionProperty
        See Also:
        getEndColumnPosition()
      • selectionBounds

        javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> selectionBoundsProperty
        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.
        See Also:
        getSelectionBounds()
      • beingUpdated

        javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty
    • Method Detail

      • rangeProperty

        javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> rangeProperty()
        The start and end positions in the area as an IndexRange.
        See Also:
        getRange()
      • getRange

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

        javafx.beans.value.ObservableValue<java.lang.Integer> lengthProperty()
        The length of the selection
        See Also:
        getLength()
      • getLength

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

        javafx.beans.value.ObservableValue<java.lang.Integer> paragraphSpanProperty()
        The number of paragraphs the selection spans
        See Also:
        getParagraphSpan()
      • 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:
      • selectedTextProperty

        javafx.beans.value.ObservableValue<java.lang.String> selectedTextProperty()
        See Also:
        getSelectedText()
      • getSelectedText

        java.lang.String getSelectedText()
        Gets the value of the property selectedText.
        Property description:
      • startPositionProperty

        javafx.beans.value.ObservableValue<java.lang.Integer> startPositionProperty()
        See Also:
        getStartPosition()
      • getStartPosition

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

        javafx.beans.value.ObservableValue<java.lang.Integer> startParagraphIndexProperty()
        See Also:
        getStartParagraphIndex()
      • getStartParagraphIndex

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

        javafx.beans.value.ObservableValue<java.lang.Integer> startColumnPositionProperty()
        See Also:
        getStartColumnPosition()
      • getStartColumnPosition

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

        javafx.beans.value.ObservableValue<java.lang.Integer> endPositionProperty()
        See Also:
        getEndPosition()
      • getEndPosition

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

        javafx.beans.value.ObservableValue<java.lang.Integer> endParagraphIndexProperty()
        See Also:
        getEndParagraphIndex()
      • getEndParagraphIndex

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

        javafx.beans.value.ObservableValue<java.lang.Integer> endColumnPositionProperty()
        See Also:
        getEndColumnPosition()
      • getEndColumnPosition

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

        javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> selectionBoundsProperty()
        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.
        See Also:
        getSelectionBounds()
      • getSelectionBounds

        java.util.Optional<javafx.geometry.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()
      • beingUpdatedProperty

        javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty()
      • 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,
                                        java.text.BreakIterator breakIterator)
      • updateStartByBreaksBackward

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

        void updateEndTo​(int position)
      • updateEndTo

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

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

        void updateEndByBreaksBackward​(int numOfBreaks,
                                       java.text.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

        java.lang.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; }