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 ObservableValue<Boolean>
beingUpdated
ObservableValue<Integer>
endColumnPosition
ObservableValue<Integer>
endParagraphIndex
ObservableValue<Integer>
endPosition
ObservableValue<Integer>
length
The length of the selectionObservableValue<Integer>
paragraphSpan
The number of paragraphs the selection spansObservableValue<IndexRange>
range
The start and end positions in the area as anIndexRange
.ObservableValue<StyledDocument<PS,SEG,S>>
selectedDocument
ObservableValue<String>
selectedText
ObservableValue<Optional<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.ObservableValue<Integer>
startColumnPosition
ObservableValue<Integer>
startParagraphIndex
ObservableValue<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 ObservableValue<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 leaksObservableValue<Integer>
endColumnPositionProperty()
ObservableValue<Integer>
endParagraphIndexProperty()
ObservableValue<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.IndexRange
getRange()
Gets the value of the property range.StyledDocument<PS,SEG,S>
getSelectedDocument()
Gets the value of the property selectedDocument.String
getSelectedText()
Gets the value of the property selectedText.Optional<Bounds>
getSelectionBounds()
Gets the value of the property selectionBounds.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()
ObservableValue<Integer>
lengthProperty()
The length of the selectionObservableValue<Integer>
paragraphSpanProperty()
The number of paragraphs the selection spansObservableValue<IndexRange>
rangeProperty()
The start and end positions in the area as anIndexRange
.void
selectAll()
ObservableValue<StyledDocument<PS,SEG,S>>
selectedDocumentProperty()
ObservableValue<String>
selectedTextProperty()
ObservableValue<Optional<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)
ObservableValue<Integer>
startColumnPositionProperty()
ObservableValue<Integer>
startParagraphIndexProperty()
ObservableValue<Integer>
startPositionProperty()
void
updateEndBy(int amount, Selection.Direction direction)
void
updateEndByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)
void
updateEndByBreaksForward(int numOfBreaks, BreakIterator breakIterator)
void
updateEndTo(int position)
void
updateEndTo(int paragraphIndex, int columnPosition)
void
updateStartBy(int amount, Selection.Direction direction)
void
updateStartByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)
void
updateStartByBreaksForward(int numOfBreaks, BreakIterator breakIterator)
void
updateStartTo(int position)
void
updateStartTo(int paragraphIndex, int columnPosition)
-
-
-
Property Detail
-
range
ObservableValue<IndexRange> rangeProperty
The start and end positions in the area as anIndexRange
.- See Also:
getRange()
-
length
ObservableValue<Integer> lengthProperty
The length of the selection- See Also:
getLength()
-
paragraphSpan
ObservableValue<Integer> paragraphSpanProperty
The number of paragraphs the selection spans- See Also:
getParagraphSpan()
-
selectedDocument
ObservableValue<StyledDocument<PS,SEG,S>> selectedDocumentProperty
- See Also:
getSelectedDocument()
-
selectedText
ObservableValue<String> selectedTextProperty
- See Also:
getSelectedText()
-
startPosition
ObservableValue<Integer> startPositionProperty
- See Also:
getStartPosition()
-
startParagraphIndex
ObservableValue<Integer> startParagraphIndexProperty
- See Also:
getStartParagraphIndex()
-
startColumnPosition
ObservableValue<Integer> startColumnPositionProperty
- See Also:
getStartColumnPosition()
-
endPosition
ObservableValue<Integer> endPositionProperty
- See Also:
getEndPosition()
-
endParagraphIndex
ObservableValue<Integer> endParagraphIndexProperty
- See Also:
getEndParagraphIndex()
-
endColumnPosition
ObservableValue<Integer> endColumnPositionProperty
- See Also:
getEndColumnPosition()
-
selectionBounds
ObservableValue<Optional<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
ObservableValue<Boolean> beingUpdatedProperty
-
-
Method Detail
-
rangeProperty
ObservableValue<IndexRange> rangeProperty()
The start and end positions in the area as anIndexRange
.- See Also:
getRange()
-
getRange
IndexRange getRange()
Gets the value of the property range.- Property description:
- The start and end positions in the area as an
IndexRange
.
-
lengthProperty
ObservableValue<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
ObservableValue<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
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
ObservableValue<String> selectedTextProperty()
- See Also:
getSelectedText()
-
getSelectedText
String getSelectedText()
Gets the value of the property selectedText.- Property description:
-
startPositionProperty
ObservableValue<Integer> startPositionProperty()
- See Also:
getStartPosition()
-
getStartPosition
int getStartPosition()
Gets the value of the property startPosition.- Property description:
-
startParagraphIndexProperty
ObservableValue<Integer> startParagraphIndexProperty()
- See Also:
getStartParagraphIndex()
-
getStartParagraphIndex
int getStartParagraphIndex()
Gets the value of the property startParagraphIndex.- Property description:
-
startColumnPositionProperty
ObservableValue<Integer> startColumnPositionProperty()
- See Also:
getStartColumnPosition()
-
getStartColumnPosition
int getStartColumnPosition()
Gets the value of the property startColumnPosition.- Property description:
-
endPositionProperty
ObservableValue<Integer> endPositionProperty()
- See Also:
getEndPosition()
-
getEndPosition
int getEndPosition()
Gets the value of the property endPosition.- Property description:
-
endParagraphIndexProperty
ObservableValue<Integer> endParagraphIndexProperty()
- See Also:
getEndParagraphIndex()
-
getEndParagraphIndex
int getEndParagraphIndex()
Gets the value of the property endParagraphIndex.- Property description:
-
endColumnPositionProperty
ObservableValue<Integer> endColumnPositionProperty()
- See Also:
getEndColumnPosition()
-
getEndColumnPosition
int getEndColumnPosition()
Gets the value of the property endColumnPosition.- Property description:
-
selectionBoundsProperty
ObservableValue<Optional<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
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()
-
beingUpdatedProperty
ObservableValue<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, 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 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
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
-
-