Interface Selection<PS,SEG,S>
-
- Type Parameters:
PS
- type forStyledDocument
's paragraph style; only necessary when using the "selectedDocument" getter or propertySEG
- type forStyledDocument
's segment type; only necessary when using the "selectedDocument" getter or propertyS
- type forStyledDocument
'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:-
getStartPosition()
/getEndPosition()
, which refers to a position somewhere in the entire area's content. It's bounds are0 <= x <= area.getLength()
. -
getStartColumnPosition()
/getEndColumnPosition()
, which refers to a position somewhere in the current paragraph. It's bounds are0 <= x <= area.getParagraphLength(index)
.
For type safety,
getSelectedDocument()
requires the same generic types fromStyledDocument
. 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 usinggetSelectedDocument()
orselectedDocumentProperty()
. If you are not going to use the "selectedDocument" getter or property, then just write the much simplerSelection<?, ?, ?> selection
.- See Also:
CaretSelectionBind
,Caret
-
-
Property Summary
Properties Type Property Description javafx.beans.value.ObservableValue<java.lang.Boolean>
beingUpdated
javafx.beans.value.ObservableValue<java.lang.Integer>
endColumnPosition
javafx.beans.value.ObservableValue<java.lang.Integer>
endParagraphIndex
javafx.beans.value.ObservableValue<java.lang.Integer>
endPosition
javafx.beans.value.ObservableValue<java.lang.Integer>
length
The length of the selectionjavafx.beans.value.ObservableValue<java.lang.Integer>
paragraphSpan
The number of paragraphs the selection spansjavafx.beans.value.ObservableValue<javafx.scene.control.IndexRange>
range
The start and end positions in the area as anIndexRange
.javafx.beans.value.ObservableValue<StyledDocument<PS,SEG,S>>
selectedDocument
javafx.beans.value.ObservableValue<java.lang.String>
selectedText
javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>>
selectionBounds
The selectionBoundsProperty of the selection in the Screen's coordinate system if something is selected and visible in the viewport, orOptional.empty()
if selection is not visible in the viewport.javafx.beans.value.ObservableValue<java.lang.Integer>
startColumnPosition
javafx.beans.value.ObservableValue<java.lang.Integer>
startParagraphIndex
javafx.beans.value.ObservableValue<java.lang.Integer>
startPosition
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Selection.Direction
Specifies whether to update the start/end value of a selection to the left (towards 0) or right (away from 0)
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description javafx.beans.value.ObservableValue<java.lang.Boolean>
beingUpdatedProperty()
void
configureSelectionPath(SelectionPath path)
Configures aSelectionPath
that will be used to render a portion or all of this selection on a single paragraph.default void
deselect()
Clears the selection viaselectRange(getStartPosition(), getStartPosition())
.void
dispose()
Disposes the selection and prevents memory leaksjavafx.beans.value.ObservableValue<java.lang.Integer>
endColumnPositionProperty()
javafx.beans.value.ObservableValue<java.lang.Integer>
endParagraphIndexProperty()
javafx.beans.value.ObservableValue<java.lang.Integer>
endPositionProperty()
GenericStyledArea<PS,SEG,S>
getArea()
Gets the area with which this selection is associatedint
getEndColumnPosition()
Gets the value of the property endColumnPosition.int
getEndParagraphIndex()
Gets the value of the property endParagraphIndex.int
getEndPosition()
Gets the value of the property endPosition.int
getLength()
Gets the value of the property length.int
getParagraphSpan()
Gets the value of the property paragraphSpan.javafx.scene.control.IndexRange
getRange()
Gets the value of the property range.StyledDocument<PS,SEG,S>
getSelectedDocument()
Gets the value of the property selectedDocument.java.lang.String
getSelectedText()
Gets the value of the property selectedText.java.util.Optional<javafx.geometry.Bounds>
getSelectionBounds()
Gets the value of the property selectionBounds.java.lang.String
getSelectionName()
Gets the name of this selection.int
getStartColumnPosition()
Gets the value of the property startColumnPosition.int
getStartParagraphIndex()
Gets the value of the property startParagraphIndex.int
getStartPosition()
Gets the value of the property startPosition.boolean
isBeingUpdated()
javafx.beans.value.ObservableValue<java.lang.Integer>
lengthProperty()
The length of the selectionjavafx.beans.value.ObservableValue<java.lang.Integer>
paragraphSpanProperty()
The number of paragraphs the selection spansjavafx.beans.value.ObservableValue<javafx.scene.control.IndexRange>
rangeProperty()
The start and end positions in the area as anIndexRange
.void
selectAll()
javafx.beans.value.ObservableValue<StyledDocument<PS,SEG,S>>
selectedDocumentProperty()
javafx.beans.value.ObservableValue<java.lang.String>
selectedTextProperty()
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, orOptional.empty()
if selection is not visible in the viewport.void
selectParagraph(int paragraphIndex)
void
selectRange(int startPosition, int endPosition)
Selects the given range.void
selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)
Selects the given range.void
selectWord(int wordPositionInArea)
javafx.beans.value.ObservableValue<java.lang.Integer>
startColumnPositionProperty()
javafx.beans.value.ObservableValue<java.lang.Integer>
startParagraphIndexProperty()
javafx.beans.value.ObservableValue<java.lang.Integer>
startPositionProperty()
void
updateEndBy(int amount, Selection.Direction direction)
void
updateEndByBreaksBackward(int numOfBreaks, java.text.BreakIterator breakIterator)
void
updateEndByBreaksForward(int numOfBreaks, java.text.BreakIterator breakIterator)
void
updateEndTo(int position)
void
updateEndTo(int paragraphIndex, int columnPosition)
void
updateStartBy(int amount, Selection.Direction direction)
void
updateStartByBreaksBackward(int numOfBreaks, java.text.BreakIterator breakIterator)
void
updateStartByBreaksForward(int numOfBreaks, java.text.BreakIterator breakIterator)
void
updateStartTo(int position)
void
updateStartTo(int paragraphIndex, int columnPosition)
-
-
-
Property Detail
-
range
javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> rangeProperty
The start and end positions in the area as anIndexRange
.- 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()
-
selectedDocument
javafx.beans.value.ObservableValue<StyledDocument<PS,SEG,S>> selectedDocumentProperty
- See Also:
getSelectedDocument()
-
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, orOptional.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 anIndexRange
.- 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
-
selectedDocumentProperty
javafx.beans.value.ObservableValue<StyledDocument<PS,SEG,S>> selectedDocumentProperty()
- See Also:
getSelectedDocument()
-
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, orOptional.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.
-
updateStartBy
void updateStartBy(int amount, Selection.Direction direction)
-
updateEndBy
void updateEndBy(int amount, Selection.Direction direction)
-
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 viaselectRange(getStartPosition(), getStartPosition())
.
-
configureSelectionPath
void configureSelectionPath(SelectionPath path)
Configures aSelectionPath
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; }
-
getArea
GenericStyledArea<PS,SEG,S> getArea()
Gets the area with which this selection is associated
-
-