Top Description Fields Constructors Methods
org.fxmisc.richtext

public Class SelectionImpl<PS, SEG, S>

extends Object
implements Selection<PS, SEG, S>, Comparable<SelectionImpl<PS, SEG, S>>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, org.fxmisc.richtext.Selection
Known Direct Subclasses
org.fxmisc.richtext.LineSelection
Imports
javafx.beans.value.ObservableValue, javafx.geometry.Bounds, javafx.scene.control.IndexRange, org.fxmisc.richtext.model.PlainTextChange, .StyledDocument, .TwoDimensional.Position, org.reactfx.EventStream, .EventStreams, .Subscription, .Suspendable, .SuspendableNo, org.reactfx.value.SuspendableVal, .Val, .Var, java.text.BreakIterator, java.util.Optional, java.util.function.Consumer, .Function, .IntSupplier

Default implementation for Selection.

Field Summary

Modifier and TypeField and Description
private final GenericStyledArea<PS, SEG, S>
private final SuspendableNo
private final SuspendableVal<Optional<Bounds>>
private final Consumer<SelectionPath>
private final SuspendableNo
private final EventStream<?>
private final Val<TwoDimensional.Position>
private final Val<Integer>
private final Val<Integer>
private final SuspendableVal<Integer>
private final Var<IndexRange>
private final SuspendableVal<Integer>
private final String
private final Val<Integer>
private final SuspendableVal<IndexRange>
private final SuspendableVal<StyledDocument<PS, SEG, S>>
private final SuspendableVal<String>
private final Var<TwoDimensional.Position>
private final Val<Integer>
private final Val<Integer>
private final SuspendableVal<Integer>
private Subscription

Constructor Summary

AccessConstructor and Description
public
SelectionImpl(String
must be unique and is also used as a StyleClass for configuration via CSS using selectors from Path, Shape, and Node.
name
,
GenericStyledArea<PS, SEG, S> area)

Creates a selection with both the start and end position at 0.

public
SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, Consumer<SelectionPath> configurePath)

Creates a selection with customized configuration via configurePath with both the start and end position at 0.

public
SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, int startPosition, int endPosition)

Creates a selection.

pack-priv
SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, int startPosition, int endPosition, SuspendableNo dependentBeingUpdated)

Creates a selection that is to be used in a CaretSelectionBind.

pack-priv
SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, int startPosition, int endPosition, SuspendableNo dependentBeingUpdated, Consumer<SelectionPath> configurePath)

Creates a selection that is to be used in a CaretSelectionBind with customized configuration.

pack-priv
SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, IndexRange range, SuspendableNo dependentBeingUpdated)

Creates a selection that is to be used in a CaretSelectionBind.

pack-priv
SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, IndexRange range, SuspendableNo dependentBeingUpdated, Consumer<SelectionPath> configurePath)

Creates a selection that is to be used in a CaretSelectionBind with customized configuration and starting at the given range.

Method Summary

Modifier and TypeMethod and Description
public final ObservableValue<Boolean>
public int
compareTo(SelectionImpl<PS, SEG, S> o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public void
configureSelectionPath(SelectionPath path)

Implements org.fxmisc.richtext.Selection.configureSelectionPath.

Configures a SelectionPath that will be used to render a portion or all of this selection on a single paragraph.

public void
dispose()

Implements org.fxmisc.richtext.Selection.dispose.

Disposes the selection and prevents memory leaks

public final ObservableValue<Integer>
public final ObservableValue<Integer>
public final ObservableValue<Integer>
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public GenericStyledArea<PS, SEG, S>
getArea()

Implements org.fxmisc.richtext.Selection.getArea.

Gets the area with which this selection is associated

public final int
public final int
public final int
public final int
public final int
public final IndexRange
public final StyledDocument<PS, SEG, S>
public final String
public final Optional<Bounds>
public String
getSelectionName()

Implements org.fxmisc.richtext.Selection.getSelectionName.

Gets the name of this selection.

public final int
public final int
public final int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final boolean
public final ObservableValue<Integer>
lengthProperty()

Implements org.fxmisc.richtext.Selection.lengthProperty.

The length of the selection

private <T> void
manageSubscription(EventStream<T> stream, Consumer<T> consumer)

private void
private void
moveBoundary(Selection.Direction direction, int amount, int oldBoundaryPosition, Function<Integer, IndexRange> updatedRange)

private void
moveBoundary(IntSupplier textPosition, Function<Integer, Boolean> boundsCheckPasses, Function<Integer, IndexRange> updatedRange)

public final ObservableValue<Integer>
paragraphSpanProperty()

Implements org.fxmisc.richtext.Selection.paragraphSpanProperty.

The number of paragraphs the selection spans

public final ObservableValue<IndexRange>
rangeProperty()

Implements org.fxmisc.richtext.Selection.rangeProperty.

The start and end positions in the area as an IndexRange.

public void
public final ObservableValue<StyledDocument<PS, SEG, S>>
public final ObservableValue<String>
public final ObservableValue<Optional<Bounds>>
selectionBoundsProperty()

Implements org.fxmisc.richtext.Selection.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.

public void
public void
selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)

Implements org.fxmisc.richtext.Selection.selectRange.

Selects the given range.

public void
selectRange(int startPosition, int endPosition)

Implements org.fxmisc.richtext.Selection.selectRange.

Selects the given range.

private void
public void
selectWord(int wordPositionInArea)

Implements org.fxmisc.richtext.Selection.selectWord.

public final ObservableValue<Integer>
public final ObservableValue<Integer>
public final ObservableValue<Integer>
private int
textPosition(int row, int col)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
private void
updateEndByBreaks(int numOfBreaks, BreakIterator breakIterator, boolean forwardsNotBackwards)

public void
public void
public void
public void
updateEndTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Selection.updateEndTo.

private void
updateSelectionByBreaks(int numOfBreaks, BreakIterator breakIterator, boolean followingNotPreceding, boolean updateStartNotEnd)

public void
private void
updateStartByBreaks(int numOfBreaks, BreakIterator breakIterator, boolean forwardsNotBackwards)

public void
public void
public void
public void
updateStartTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Selection.updateStartTo.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

areaback to summary
private final GenericStyledArea<PS, SEG, S> area
beingUpdatedback to summary
private final SuspendableNo beingUpdated
boundsback to summary
private final SuspendableVal<Optional<Bounds>> bounds
configurePathback to summary
private final Consumer<SelectionPath> configurePath
dependentBeingUpdatedback to summary
private final SuspendableNo dependentBeingUpdated
dirtyback to summary
private final EventStream<?> dirty
end2DPositionback to summary
private final Val<TwoDimensional.Position> end2DPosition
endColumnPositionback to summary
private final Val<Integer> endColumnPosition
endParagraphIndexback to summary
private final Val<Integer> endParagraphIndex
endPositionback to summary
private final SuspendableVal<Integer> endPosition
internalRangeback to summary
private final Var<IndexRange> internalRange
lengthback to summary
private final SuspendableVal<Integer> length
nameback to summary
private final String name
paragraphSpanback to summary
private final Val<Integer> paragraphSpan
rangeback to summary
private final SuspendableVal<IndexRange> range
selectedDocumentback to summary
private final SuspendableVal<StyledDocument<PS, SEG, S>> selectedDocument
selectedTextback to summary
private final SuspendableVal<String> selectedText
start2DPositionback to summary
private final Var<TwoDimensional.Position> start2DPosition
startColumnPositionback to summary
private final Val<Integer> startColumnPosition
startParagraphIndexback to summary
private final Val<Integer> startParagraphIndex
startPositionback to summary
private final SuspendableVal<Integer> startPosition
subscriptionback to summary
private Subscription subscription

Constructor Detail

SelectionImplback to summary
public SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area)

Creates a selection with both the start and end position at 0.

Parameters
name:String

must be unique and is also used as a StyleClass for configuration via CSS using selectors from Path, Shape, and Node.

SelectionImplback to summary
public SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, Consumer<SelectionPath> configurePath)

Creates a selection with customized configuration via configurePath with both the start and end position at 0.

SelectionImplback to summary
public SelectionImpl(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.

SelectionImplback to summary
pack-priv SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, int startPosition, int endPosition, SuspendableNo dependentBeingUpdated)

Creates a selection that is to be used in a CaretSelectionBind.

SelectionImplback to summary
pack-priv SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, int startPosition, int endPosition, SuspendableNo dependentBeingUpdated, Consumer<SelectionPath> configurePath)

Creates a selection that is to be used in a CaretSelectionBind with customized configuration.

SelectionImplback to summary
pack-priv SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, IndexRange range, SuspendableNo dependentBeingUpdated)

Creates a selection that is to be used in a CaretSelectionBind. It adds the style class selection to any SelectionPath used to render this selection.

SelectionImplback to summary
pack-priv SelectionImpl(String name, GenericStyledArea<PS, SEG, S> area, IndexRange range, SuspendableNo dependentBeingUpdated, Consumer<SelectionPath> configurePath)

Creates a selection that is to be used in a CaretSelectionBind with customized configuration and starting at the given range.

Method Detail

beingUpdatedPropertyback to summary
public final ObservableValue<Boolean> beingUpdatedProperty()

Implements org.fxmisc.richtext.Selection.beingUpdatedProperty.

Annotations
@Override
compareToback to summary
public int compareTo(SelectionImpl<PS, SEG, S> o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Annotations
@Override
configureSelectionPathback to summary
public void configureSelectionPath(SelectionPath path)

Implements org.fxmisc.richtext.Selection.configureSelectionPath.

Doc from org.fxmisc.richtext.Selection.configureSelectionPath.

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.

Annotations
@Override
disposeback to summary
public void dispose()

Implements org.fxmisc.richtext.Selection.dispose.

Doc from org.fxmisc.richtext.Selection.dispose.

Disposes the selection and prevents memory leaks

Annotations
@Override
endColumnPositionPropertyback to summary
public final ObservableValue<Integer> endColumnPositionProperty()

Implements org.fxmisc.richtext.Selection.endColumnPositionProperty.

Annotations
@Override
endParagraphIndexPropertyback to summary
public final ObservableValue<Integer> endParagraphIndexProperty()

Implements org.fxmisc.richtext.Selection.endParagraphIndexProperty.

Annotations
@Override
endPositionPropertyback to summary
public final ObservableValue<Integer> endPositionProperty()

Implements org.fxmisc.richtext.Selection.endPositionProperty.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getAreaback to summary
public GenericStyledArea<PS, SEG, S> getArea()

Implements org.fxmisc.richtext.Selection.getArea.

Doc from org.fxmisc.richtext.Selection.getArea.

Gets the area with which this selection is associated

Annotations
@Override
getEndColumnPositionback to summary
public final int getEndColumnPosition()

Implements org.fxmisc.richtext.Selection.getEndColumnPosition.

Annotations
@Override
getEndParagraphIndexback to summary
public final int getEndParagraphIndex()

Implements org.fxmisc.richtext.Selection.getEndParagraphIndex.

Annotations
@Override
getEndPositionback to summary
public final int getEndPosition()

Implements org.fxmisc.richtext.Selection.getEndPosition.

Annotations
@Override
getLengthback to summary
public final int getLength()

Implements org.fxmisc.richtext.Selection.getLength.

Annotations
@Override
getParagraphSpanback to summary
public final int getParagraphSpan()

Implements org.fxmisc.richtext.Selection.getParagraphSpan.

Annotations
@Override
getRangeback to summary
public final IndexRange getRange()

Implements org.fxmisc.richtext.Selection.getRange.

Annotations
@Override
getSelectedDocumentback to summary
public final StyledDocument<PS, SEG, S> getSelectedDocument()

Implements org.fxmisc.richtext.Selection.getSelectedDocument.

Annotations
@Override
getSelectedTextback to summary
public final String getSelectedText()

Implements org.fxmisc.richtext.Selection.getSelectedText.

Annotations
@Override
getSelectionBoundsback to summary
public final Optional<Bounds> getSelectionBounds()

Implements org.fxmisc.richtext.Selection.getSelectionBounds.

Annotations
@Override
getSelectionNameback to summary
public String getSelectionName()

Implements org.fxmisc.richtext.Selection.getSelectionName.

Doc from org.fxmisc.richtext.Selection.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; }

Annotations
@Override
getStartColumnPositionback to summary
public final int getStartColumnPosition()

Implements org.fxmisc.richtext.Selection.getStartColumnPosition.

Annotations
@Override
getStartParagraphIndexback to summary
public final int getStartParagraphIndex()

Implements org.fxmisc.richtext.Selection.getStartParagraphIndex.

Annotations
@Override
getStartPositionback to summary
public final int getStartPosition()

Implements org.fxmisc.richtext.Selection.getStartPosition.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
isBeingUpdatedback to summary
public final boolean isBeingUpdated()

Implements org.fxmisc.richtext.Selection.isBeingUpdated.

Annotations
@Override
lengthPropertyback to summary
public final ObservableValue<Integer> lengthProperty()

Implements org.fxmisc.richtext.Selection.lengthProperty.

Doc from org.fxmisc.richtext.Selection.lengthProperty.

The length of the selection

Annotations
@Override
manageSubscriptionback to summary
private <T> void manageSubscription(EventStream<T> stream, Consumer<T> consumer)
manageSubscriptionback to summary
private void manageSubscription(Subscription s)
moveBoundaryback to summary
private void moveBoundary(Selection.Direction direction, int amount, int oldBoundaryPosition, Function<Integer, IndexRange> updatedRange)
moveBoundaryback to summary
private void moveBoundary(IntSupplier textPosition, Function<Integer, Boolean> boundsCheckPasses, Function<Integer, IndexRange> updatedRange)
paragraphSpanPropertyback to summary
public final ObservableValue<Integer> paragraphSpanProperty()

Implements org.fxmisc.richtext.Selection.paragraphSpanProperty.

Doc from org.fxmisc.richtext.Selection.paragraphSpanProperty.

The number of paragraphs the selection spans

Annotations
@Override
rangePropertyback to summary
public final ObservableValue<IndexRange> rangeProperty()

Implements org.fxmisc.richtext.Selection.rangeProperty.

Doc from org.fxmisc.richtext.Selection.rangeProperty.

The start and end positions in the area as an IndexRange.

Annotations
@Override
selectAllback to summary
public void selectAll()

Implements org.fxmisc.richtext.Selection.selectAll.

Annotations
@Override
selectedDocumentPropertyback to summary
public final ObservableValue<StyledDocument<PS, SEG, S>> selectedDocumentProperty()

Implements org.fxmisc.richtext.Selection.selectedDocumentProperty.

Annotations
@Override
selectedTextPropertyback to summary
public final ObservableValue<String> selectedTextProperty()

Implements org.fxmisc.richtext.Selection.selectedTextProperty.

Annotations
@Override
selectionBoundsPropertyback to summary
public final ObservableValue<Optional<Bounds>> selectionBoundsProperty()

Implements org.fxmisc.richtext.Selection.selectionBoundsProperty.

Doc from org.fxmisc.richtext.Selection.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.

Annotations
@Override
selectParagraphback to summary
public void selectParagraph(int paragraphIndex)

Implements org.fxmisc.richtext.Selection.selectParagraph.

Annotations
@Override
selectRangeback to summary
public void selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)

Implements org.fxmisc.richtext.Selection.selectRange.

Doc from org.fxmisc.richtext.Selection.selectRange.

Selects the given range.

Caution

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

Annotations
@Override
selectRangeback to summary
public void selectRange(int startPosition, int endPosition)

Implements org.fxmisc.richtext.Selection.selectRange.

Doc from org.fxmisc.richtext.Selection.selectRange.

Selects the given range.

Annotations
@Override
selectRangeback to summary
private void selectRange(IndexRange range)
selectWordback to summary
public void selectWord(int wordPositionInArea)

Implements org.fxmisc.richtext.Selection.selectWord.

Annotations
@Override
startColumnPositionPropertyback to summary
public final ObservableValue<Integer> startColumnPositionProperty()

Implements org.fxmisc.richtext.Selection.startColumnPositionProperty.

Annotations
@Override
startParagraphIndexPropertyback to summary
public final ObservableValue<Integer> startParagraphIndexProperty()

Implements org.fxmisc.richtext.Selection.startParagraphIndexProperty.

Annotations
@Override
startPositionPropertyback to summary
public final ObservableValue<Integer> startPositionProperty()

Implements org.fxmisc.richtext.Selection.startPositionProperty.

Annotations
@Override
textPositionback to summary
private int textPosition(int row, int col)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
updateEndByback to summary
public void updateEndBy(int amount, Selection.Direction direction)

Implements org.fxmisc.richtext.Selection.updateEndBy.

Annotations
@Override
updateEndByBreaksback to summary
private void updateEndByBreaks(int numOfBreaks, BreakIterator breakIterator, boolean forwardsNotBackwards)
updateEndByBreaksBackwardback to summary
public void updateEndByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Selection.updateEndByBreaksBackward.

Annotations
@Override
updateEndByBreaksForwardback to summary
public void updateEndByBreaksForward(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Selection.updateEndByBreaksForward.

Annotations
@Override
updateEndToback to summary
public void updateEndTo(int position)

Implements org.fxmisc.richtext.Selection.updateEndTo.

Annotations
@Override
updateEndToback to summary
public void updateEndTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Selection.updateEndTo.

Annotations
@Override
updateSelectionByBreaksback to summary
private void updateSelectionByBreaks(int numOfBreaks, BreakIterator breakIterator, boolean followingNotPreceding, boolean updateStartNotEnd)
updateStartByback to summary
public void updateStartBy(int amount, Selection.Direction direction)

Implements org.fxmisc.richtext.Selection.updateStartBy.

Annotations
@Override
updateStartByBreaksback to summary
private void updateStartByBreaks(int numOfBreaks, BreakIterator breakIterator, boolean forwardsNotBackwards)
updateStartByBreaksBackwardback to summary
public void updateStartByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Selection.updateStartByBreaksBackward.

Annotations
@Override
updateStartByBreaksForwardback to summary
public void updateStartByBreaksForward(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Selection.updateStartByBreaksForward.

Annotations
@Override
updateStartToback to summary
public void updateStartTo(int position)

Implements org.fxmisc.richtext.Selection.updateStartTo.

Annotations
@Override
updateStartToback to summary
public void updateStartTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Selection.updateStartTo.

Annotations
@Override