Package org.fxmisc.richtext
Class SelectionImpl<PS,SEG,S>
- java.lang.Object
-
- org.fxmisc.richtext.SelectionImpl<PS,SEG,S>
-
- All Implemented Interfaces:
java.lang.Comparable<SelectionImpl<PS,SEG,S>>
,Selection<PS,SEG,S>
public class SelectionImpl<PS,SEG,S> extends java.lang.Object implements Selection<PS,SEG,S>, java.lang.Comparable<SelectionImpl<PS,SEG,S>>
Default implementation forSelection
.
-
-
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/interfaces inherited from interface org.fxmisc.richtext.Selection
Selection.Direction
-
-
Constructor Summary
Constructors Constructor Description SelectionImpl(java.lang.String name, GenericStyledArea<PS,SEG,S> area)
Creates a selection with both the start and end position at 0.SelectionImpl(java.lang.String name, GenericStyledArea<PS,SEG,S> area, int startPosition, int endPosition)
Creates a selection.SelectionImpl(java.lang.String name, GenericStyledArea<PS,SEG,S> area, java.util.function.Consumer<SelectionPath> configurePath)
Creates a selection with customized configuration viaconfigurePath
with both the start and end position at 0.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.value.ObservableValue<java.lang.Boolean>
beingUpdatedProperty()
int
compareTo(SelectionImpl<PS,SEG,S> o)
void
configureSelectionPath(SelectionPath path)
Configures aSelectionPath
that will be used to render a portion or all of this selection on a single paragraph.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()
boolean
equals(java.lang.Object obj)
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.int
hashCode()
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()
java.lang.String
toString()
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
public final javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> rangeProperty
- Specified by:
rangeProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getRange()
-
length
public final javafx.beans.value.ObservableValue<java.lang.Integer> lengthProperty
- Specified by:
lengthProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getLength()
-
paragraphSpan
public final javafx.beans.value.ObservableValue<java.lang.Integer> paragraphSpanProperty
- Specified by:
paragraphSpanProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getParagraphSpan()
-
selectedDocument
public final javafx.beans.value.ObservableValue<StyledDocument<PS,SEG,S>> selectedDocumentProperty
- Specified by:
selectedDocumentProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getSelectedDocument()
-
selectedText
public final javafx.beans.value.ObservableValue<java.lang.String> selectedTextProperty
- Specified by:
selectedTextProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getSelectedText()
-
startPosition
public final javafx.beans.value.ObservableValue<java.lang.Integer> startPositionProperty
- Specified by:
startPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getStartPosition()
-
startParagraphIndex
public final javafx.beans.value.ObservableValue<java.lang.Integer> startParagraphIndexProperty
- Specified by:
startParagraphIndexProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getStartParagraphIndex()
-
startColumnPosition
public final javafx.beans.value.ObservableValue<java.lang.Integer> startColumnPositionProperty
- Specified by:
startColumnPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getStartColumnPosition()
-
endPosition
public final javafx.beans.value.ObservableValue<java.lang.Integer> endPositionProperty
- Specified by:
endPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getEndPosition()
-
endParagraphIndex
public final javafx.beans.value.ObservableValue<java.lang.Integer> endParagraphIndexProperty
- Specified by:
endParagraphIndexProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getEndParagraphIndex()
-
endColumnPosition
public final javafx.beans.value.ObservableValue<java.lang.Integer> endColumnPositionProperty
- Specified by:
endColumnPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getEndColumnPosition()
-
selectionBounds
public final javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> selectionBoundsProperty
- Specified by:
selectionBoundsProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getSelectionBounds()
-
beingUpdated
public final javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty
- Specified by:
beingUpdatedProperty
in interfaceSelection<PS,SEG,S>
-
-
Constructor Detail
-
SelectionImpl
public SelectionImpl(java.lang.String name, GenericStyledArea<PS,SEG,S> area)
Creates a selection with both the start and end position at 0.- Parameters:
name
- must be unique and is also used as a StyleClass for configuration via CSS using selectors from Path, Shape, and Node.
-
SelectionImpl
public SelectionImpl(java.lang.String name, GenericStyledArea<PS,SEG,S> area, java.util.function.Consumer<SelectionPath> configurePath)
Creates a selection with customized configuration viaconfigurePath
with both the start and end position at 0.
-
SelectionImpl
public SelectionImpl(java.lang.String name, GenericStyledArea<PS,SEG,S> area, int startPosition, int endPosition)
Creates a selection. Name must be unique and is also used as a StyleClass for configuration via CSS using selectors from Path, Shape, and Node.
-
-
Method Detail
-
getRange
public final javafx.scene.control.IndexRange getRange()
Gets the value of the property range.
-
rangeProperty
public final javafx.beans.value.ObservableValue<javafx.scene.control.IndexRange> rangeProperty()
Description copied from interface:Selection
The start and end positions in the area as anIndexRange
.- Specified by:
rangeProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getRange()
-
getLength
public final int getLength()
Gets the value of the property length.
-
lengthProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> lengthProperty()
Description copied from interface:Selection
The length of the selection- Specified by:
lengthProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getLength()
-
getParagraphSpan
public final int getParagraphSpan()
Gets the value of the property paragraphSpan.- Specified by:
getParagraphSpan
in interfaceSelection<PS,SEG,S>
- Property description:
-
paragraphSpanProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> paragraphSpanProperty()
Description copied from interface:Selection
The number of paragraphs the selection spans- Specified by:
paragraphSpanProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getParagraphSpan()
-
selectedDocumentProperty
public final javafx.beans.value.ObservableValue<StyledDocument<PS,SEG,S>> selectedDocumentProperty()
- Specified by:
selectedDocumentProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getSelectedDocument()
-
getSelectedDocument
public final StyledDocument<PS,SEG,S> getSelectedDocument()
Gets the value of the property selectedDocument.- Specified by:
getSelectedDocument
in interfaceSelection<PS,SEG,S>
- Property description:
-
getSelectedText
public final java.lang.String getSelectedText()
Gets the value of the property selectedText.- Specified by:
getSelectedText
in interfaceSelection<PS,SEG,S>
- Property description:
-
selectedTextProperty
public final javafx.beans.value.ObservableValue<java.lang.String> selectedTextProperty()
- Specified by:
selectedTextProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getSelectedText()
-
getStartPosition
public final int getStartPosition()
Gets the value of the property startPosition.- Specified by:
getStartPosition
in interfaceSelection<PS,SEG,S>
- Property description:
-
startPositionProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> startPositionProperty()
- Specified by:
startPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getStartPosition()
-
getStartParagraphIndex
public final int getStartParagraphIndex()
Gets the value of the property startParagraphIndex.- Specified by:
getStartParagraphIndex
in interfaceSelection<PS,SEG,S>
- Property description:
-
startParagraphIndexProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> startParagraphIndexProperty()
- Specified by:
startParagraphIndexProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getStartParagraphIndex()
-
getStartColumnPosition
public final int getStartColumnPosition()
Gets the value of the property startColumnPosition.- Specified by:
getStartColumnPosition
in interfaceSelection<PS,SEG,S>
- Property description:
-
startColumnPositionProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> startColumnPositionProperty()
- Specified by:
startColumnPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getStartColumnPosition()
-
getEndPosition
public final int getEndPosition()
Gets the value of the property endPosition.- Specified by:
getEndPosition
in interfaceSelection<PS,SEG,S>
- Property description:
-
endPositionProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> endPositionProperty()
- Specified by:
endPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getEndPosition()
-
getEndParagraphIndex
public final int getEndParagraphIndex()
Gets the value of the property endParagraphIndex.- Specified by:
getEndParagraphIndex
in interfaceSelection<PS,SEG,S>
- Property description:
-
endParagraphIndexProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> endParagraphIndexProperty()
- Specified by:
endParagraphIndexProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getEndParagraphIndex()
-
getEndColumnPosition
public final int getEndColumnPosition()
Gets the value of the property endColumnPosition.- Specified by:
getEndColumnPosition
in interfaceSelection<PS,SEG,S>
- Property description:
-
endColumnPositionProperty
public final javafx.beans.value.ObservableValue<java.lang.Integer> endColumnPositionProperty()
- Specified by:
endColumnPositionProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getEndColumnPosition()
-
getSelectionBounds
public final java.util.Optional<javafx.geometry.Bounds> getSelectionBounds()
Gets the value of the property selectionBounds.- Specified by:
getSelectionBounds
in interfaceSelection<PS,SEG,S>
- Property description:
-
selectionBoundsProperty
public final javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> selectionBoundsProperty()
Description copied from interface:Selection
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.- Specified by:
selectionBoundsProperty
in interfaceSelection<PS,SEG,S>
- See Also:
getSelectionBounds()
-
isBeingUpdated
public final boolean isBeingUpdated()
- Specified by:
isBeingUpdated
in interfaceSelection<PS,SEG,S>
-
beingUpdatedProperty
public final javafx.beans.value.ObservableValue<java.lang.Boolean> beingUpdatedProperty()
- Specified by:
beingUpdatedProperty
in interfaceSelection<PS,SEG,S>
-
getArea
public GenericStyledArea<PS,SEG,S> getArea()
Description copied from interface:Selection
Gets the area with which this selection is associated
-
getSelectionName
public java.lang.String getSelectionName()
Description copied from interface:Selection
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; }- Specified by:
getSelectionName
in interfaceSelection<PS,SEG,S>
-
selectRange
public void selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)
Description copied from interface:Selection
Selects the given range.Caution: see
TextEditingArea.getAbsolutePosition(int, int)
to know how the column index argument can affect the returned position.- Specified by:
selectRange
in interfaceSelection<PS,SEG,S>
-
selectRange
public void selectRange(int startPosition, int endPosition)
Description copied from interface:Selection
Selects the given range.- Specified by:
selectRange
in interfaceSelection<PS,SEG,S>
-
updateStartBy
public void updateStartBy(int amount, Selection.Direction direction)
- Specified by:
updateStartBy
in interfaceSelection<PS,SEG,S>
-
updateEndBy
public void updateEndBy(int amount, Selection.Direction direction)
- Specified by:
updateEndBy
in interfaceSelection<PS,SEG,S>
-
updateStartTo
public void updateStartTo(int position)
- Specified by:
updateStartTo
in interfaceSelection<PS,SEG,S>
-
updateStartTo
public void updateStartTo(int paragraphIndex, int columnPosition)
- Specified by:
updateStartTo
in interfaceSelection<PS,SEG,S>
-
updateStartByBreaksForward
public void updateStartByBreaksForward(int numOfBreaks, java.text.BreakIterator breakIterator)
- Specified by:
updateStartByBreaksForward
in interfaceSelection<PS,SEG,S>
-
updateStartByBreaksBackward
public void updateStartByBreaksBackward(int numOfBreaks, java.text.BreakIterator breakIterator)
- Specified by:
updateStartByBreaksBackward
in interfaceSelection<PS,SEG,S>
-
updateEndTo
public void updateEndTo(int position)
- Specified by:
updateEndTo
in interfaceSelection<PS,SEG,S>
-
updateEndTo
public void updateEndTo(int paragraphIndex, int columnPosition)
- Specified by:
updateEndTo
in interfaceSelection<PS,SEG,S>
-
updateEndByBreaksForward
public void updateEndByBreaksForward(int numOfBreaks, java.text.BreakIterator breakIterator)
- Specified by:
updateEndByBreaksForward
in interfaceSelection<PS,SEG,S>
-
updateEndByBreaksBackward
public void updateEndByBreaksBackward(int numOfBreaks, java.text.BreakIterator breakIterator)
- Specified by:
updateEndByBreaksBackward
in interfaceSelection<PS,SEG,S>
-
selectParagraph
public void selectParagraph(int paragraphIndex)
- Specified by:
selectParagraph
in interfaceSelection<PS,SEG,S>
-
selectWord
public void selectWord(int wordPositionInArea)
- Specified by:
selectWord
in interfaceSelection<PS,SEG,S>
-
configureSelectionPath
public void configureSelectionPath(SelectionPath path)
Description copied from interface:Selection
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.- Specified by:
configureSelectionPath
in interfaceSelection<PS,SEG,S>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(SelectionImpl<PS,SEG,S> o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<PS>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-