Top Description Fields Constructors Methods
org.fxmisc.richtext

public Class CaretNode

extends Path
implements Caret, Comparable<CaretNode>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, org.fxmisc.richtext.Caret
Imports
javafx.beans.property.ObjectProperty, javafx.beans.value.ObservableValue, javafx.css.CssMetaData, .StyleConverter, .Styleable, .StyleableObjectProperty, javafx.geometry.Bounds, javafx.scene.shape.Path, org.fxmisc.richtext.model.PlainTextChange, .TwoDimensional, org.reactfx.EventStream, .EventStreams, .StateMachine, .Subscription, .Suspendable, .SuspendableNo, org.reactfx.value.SuspendableVal, .Val, .Var, java.text.BreakIterator, java.time.Duration, java.util.ArrayList, .Collections, .List, .Optional, .OptionalInt, java.util.function.Consumer

Default implementation for a Caret. Since only one Path object is used per caret, the model and view were combined into one item to grant easier access to and modification of CSS-related properties. Caution must be exercised when depending on Path-related properties in any way (e.g. boundsInLocalProperty(), parentProperty(), etc.). Also, caretBoundsProperty() is distinguishable from boundsInLocalProperty().

This class adds the css property "-rtfx-blink-rate" (blinkRateProperty()}

Field Summary

Modifier and TypeField and Description
private static final EventStream<Boolean>
private static final EventStream<Boolean>
private final GenericStyledArea<?, ?, ?>
private final SuspendableNo
private final StyleableObjectProperty<Duration>
blinkRate

Controls the blink rate of the caret, when one is displayed.

private final SuspendableVal<Optional<Bounds>>
private final SuspendableVal<Integer>
private static final List<CssMetaData<? extends Styleable, ?>>
private final SuspendableNo
private final EventStream<?>
private static final Duration
private final Var<Integer>
private final SuspendableVal<OptionalInt>
private final String
private final SuspendableVal<Integer>
private final SuspendableVal<Integer>
private final Var<Caret.CaretVisibility>
private Subscription
private Optional<ParagraphBox.CaretOffsetX>

Constructor Summary

AccessConstructor and Description
public
CaretNode(String name, GenericStyledArea<?, ?, ?> area)

public
CaretNode(String name, GenericStyledArea<?, ?, ?> area, int startingPosition)

public
CaretNode(String name, GenericStyledArea<?, ?, ?> area, SuspendableNo dependentBeingUpdated, int startingPosition)

Method Summary

Modifier and TypeMethod and Description
public final SuspendableNo
public ObjectProperty<Duration>
blinkRateProperty()

Implements org.fxmisc.richtext.Caret.blinkRateProperty.

The blink rate of the caret.

private static EventStream<Boolean>
booleanPulse(Duration javafxDuration, EventStream<?> restartImpulse)

public final ObservableValue<Optional<Bounds>>
caretBoundsProperty()

Implements org.fxmisc.richtext.Caret.caretBoundsProperty.

The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional#empty() if caret is not visible in the viewport.

public final void
clearTargetOffset()

Implements org.fxmisc.richtext.Caret.clearTargetOffset.

Clears the caret's x offset

public final ObservableValue<Integer>
columnPositionProperty()

Implements org.fxmisc.richtext.Caret.columnPositionProperty.

The column position of the caret on its given line

public int
compareTo(CaretNode o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public void
dispose()

Implements org.fxmisc.richtext.Caret.dispose.

Disposes the caret and prevents memory leaks

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

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

public GenericStyledArea<?, ?, ?>
getArea()

Implements org.fxmisc.richtext.Caret.getArea.

Gets the area with which this caret is associated.

public Duration
public final Optional<Bounds>
public final String
getCaretName()

Implements org.fxmisc.richtext.Caret.getCaretName.

Gets the name of this caret.

public static List<CssMetaData<? extends Styleable, ?>>
getClassCssMetaData()

Hides javafx.scene.shape.Shape.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public final int
public List<CssMetaData<? extends Styleable, ?>>
getCssMetaData()

Overrides javafx.scene.shape.Shape.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

public final OptionalInt
public final int
public final int
public final Caret.CaretVisibility
public final ParagraphBox.CaretOffsetX
getTargetOffset()

Implements org.fxmisc.richtext.Caret.getTargetOffset.

Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final boolean
public final ObservableValue<OptionalInt>
lineIndexProperty()

Implements org.fxmisc.richtext.Caret.lineIndexProperty.

The line index of a multi-line paragraph that contains this caret

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

private void
public void
moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Caret.moveBreaksBackwards.

Moves the caret backwards by the number of breaks.

public void
moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Caret.moveBreaksForwards.

Moves the caret forwards by the number of breaks.

private void
moveContentBreaks(int
the number of breaks
numOfBreaks
,
BreakIterator
the type of iterator to use
breakIterator
,
boolean followingNotPreceding)

Helper method for reducing duplicate code

public void
moveTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the given position in the area.

public void
moveTo(int position)

Implements org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the given position in the area.

public void
moveToAreaEnd()

Implements org.fxmisc.richtext.Caret.moveToAreaEnd.

Moves the caret to the end of the area.

public void
moveToNextChar()

Implements org.fxmisc.richtext.Caret.moveToNextChar.

Moves the caret forward one char in the text.

public void
moveToParEnd()

Implements org.fxmisc.richtext.Caret.moveToParEnd.

Moves the caret to the end of the current paragraph.

public void
moveToParStart()

Implements org.fxmisc.richtext.Caret.moveToParStart.

Moves the caret to the beginning of the current paragraph.

public void
moveToPrevChar()

Implements org.fxmisc.richtext.Caret.moveToPrevChar.

Moves the caret backward one char in the text.

public final ObservableValue<Integer>
paragraphIndexProperty()

Implements org.fxmisc.richtext.Caret.paragraphIndexProperty.

The paragraph index that contains this caret

public final ObservableValue<Integer>
positionProperty()

Implements org.fxmisc.richtext.Caret.positionProperty.

The position of the caret within the text

public void
public final void
public final Var<Caret.CaretVisibility>
showCaretProperty()

Implements org.fxmisc.richtext.Caret.showCaretProperty.

Whether to display the caret or not.

private int
textPosition(int row, int col)

public String
toString()

Overrides javafx.scene.shape.Path.toString.

Returns a string representation of this Path object.

Inherited from javafx.scene.shape.Path:
fillRulePropertygetElementsgetFillRulesetFillRule

Field Detail

ALWAYS_FALSEback to summary
private static final EventStream<Boolean> ALWAYS_FALSE
ALWAYS_TRUEback to summary
private static final EventStream<Boolean> ALWAYS_TRUE
areaback to summary
private final GenericStyledArea<?, ?, ?> area
beingUpdatedback to summary
private final SuspendableNo beingUpdated
blinkRateback to summary
private final StyleableObjectProperty<Duration> blinkRate

Controls the blink rate of the caret, when one is displayed. Setting the duration to zero disables blinking.

boundsback to summary
private final SuspendableVal<Optional<Bounds>> bounds
columnPositionback to summary
private final SuspendableVal<Integer> columnPosition
CSS_META_DATA_LISTback to summary
private static final List<CssMetaData<? extends Styleable, ?>> CSS_META_DATA_LIST
dependentBeingUpdatedback to summary
private final SuspendableNo dependentBeingUpdated
dirtyback to summary
private final EventStream<?> dirty
HALF_A_SECONDback to summary
private static final Duration HALF_A_SECOND
internalTextPositionback to summary
private final Var<Integer> internalTextPosition
lineIndexback to summary
private final SuspendableVal<OptionalInt> lineIndex
nameback to summary
private final String name
paragraphIndexback to summary
private final SuspendableVal<Integer> paragraphIndex
positionback to summary
private final SuspendableVal<Integer> position
showCaretback to summary
private final Var<Caret.CaretVisibility> showCaret
subscriptionsback to summary
private Subscription subscriptions
targetOffsetback to summary
private Optional<ParagraphBox.CaretOffsetX> targetOffset

Constructor Detail

CaretNodeback to summary
public CaretNode(String name, GenericStyledArea<?, ?, ?> area)
CaretNodeback to summary
public CaretNode(String name, GenericStyledArea<?, ?, ?> area, int startingPosition)
CaretNodeback to summary
public CaretNode(String name, GenericStyledArea<?, ?, ?> area, SuspendableNo dependentBeingUpdated, int startingPosition)

Method Detail

beingUpdatedPropertyback to summary
public final SuspendableNo beingUpdatedProperty()

Implements org.fxmisc.richtext.Caret.beingUpdatedProperty.

Annotations
@Override
blinkRatePropertyback to summary
public ObjectProperty<Duration> blinkRateProperty()

Implements org.fxmisc.richtext.Caret.blinkRateProperty.

The blink rate of the caret. Can be styled from CSS using the "-rtfx-blink-rate" property.

Annotations
@Override
booleanPulseback to summary
private static EventStream<Boolean> booleanPulse(Duration javafxDuration, EventStream<?> restartImpulse)
caretBoundsPropertyback to summary
public final ObservableValue<Optional<Bounds>> caretBoundsProperty()

Implements org.fxmisc.richtext.Caret.caretBoundsProperty.

Doc from org.fxmisc.richtext.Caret.caretBoundsProperty.

The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional#empty() if caret is not visible in the viewport.

Annotations
@Override
clearTargetOffsetback to summary
public final void clearTargetOffset()

Implements org.fxmisc.richtext.Caret.clearTargetOffset.

Doc from org.fxmisc.richtext.Caret.clearTargetOffset.

Clears the caret's x offset

Annotations
@Override
columnPositionPropertyback to summary
public final ObservableValue<Integer> columnPositionProperty()

Implements org.fxmisc.richtext.Caret.columnPositionProperty.

Doc from org.fxmisc.richtext.Caret.columnPositionProperty.

The column position of the caret on its given line

Annotations
@Override
compareToback to summary
public int compareTo(CaretNode 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
disposeback to summary
public void dispose()

Implements org.fxmisc.richtext.Caret.dispose.

Doc from org.fxmisc.richtext.Caret.dispose.

Disposes the caret and prevents memory leaks

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<?, ?, ?> getArea()

Implements org.fxmisc.richtext.Caret.getArea.

Doc from org.fxmisc.richtext.Caret.getArea.

Gets the area with which this caret is associated.

Annotations
@Override
getBlinkRateback to summary
public Duration getBlinkRate()

Implements org.fxmisc.richtext.Caret.getBlinkRate.

Annotations
@Override
getCaretBoundsback to summary
public final Optional<Bounds> getCaretBounds()

Implements org.fxmisc.richtext.Caret.getCaretBounds.

Annotations
@Override
getCaretNameback to summary
public final String getCaretName()

Implements org.fxmisc.richtext.Caret.getCaretName.

Doc from org.fxmisc.richtext.Caret.getCaretName.

Gets the name of this caret. Each caret that is added to an area must have a unique name since it is used to distinguish it from others in a Set.

Annotations
@Override
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.shape.Shape.getClassCssMetaData.

Doc from javafx.scene.shape.Shape.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

getColumnPositionback to summary
public final int getColumnPosition()

Implements org.fxmisc.richtext.Caret.getColumnPosition.

Annotations
@Override
getCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()

Overrides javafx.scene.shape.Shape.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.shape.Shape.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

Annotations
@Override
getLineIndexback to summary
public final OptionalInt getLineIndex()

Implements org.fxmisc.richtext.Caret.getLineIndex.

Annotations
@Override
getParagraphIndexback to summary
public final int getParagraphIndex()

Implements org.fxmisc.richtext.Caret.getParagraphIndex.

Annotations
@Override
getPositionback to summary
public final int getPosition()

Implements org.fxmisc.richtext.Caret.getPosition.

Annotations
@Override
getShowCaretback to summary
public final Caret.CaretVisibility getShowCaret()

Implements org.fxmisc.richtext.Caret.getShowCaret.

Annotations
@Override
getTargetOffsetback to summary
public final ParagraphBox.CaretOffsetX getTargetOffset()

Implements org.fxmisc.richtext.Caret.getTargetOffset.

Doc from org.fxmisc.richtext.Caret.getTargetOffset.

Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.

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.Caret.isBeingUpdated.

Annotations
@Override
lineIndexPropertyback to summary
public final ObservableValue<OptionalInt> lineIndexProperty()

Implements org.fxmisc.richtext.Caret.lineIndexProperty.

Doc from org.fxmisc.richtext.Caret.lineIndexProperty.

The line index of a multi-line paragraph that contains this caret

Annotations
@Override
manageSubscriptionback to summary
private <T> void manageSubscription(EventStream<T> stream, Consumer<T> subscriber)
manageSubscriptionback to summary
private void manageSubscription(Subscription s)
moveBreaksBackwardsback to summary
public void moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Caret.moveBreaksBackwards.

Doc from org.fxmisc.richtext.Caret.moveBreaksBackwards.

Moves the caret backwards by the number of breaks.

Annotations
@Override
moveBreaksForwardsback to summary
public void moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)

Implements org.fxmisc.richtext.Caret.moveBreaksForwards.

Doc from org.fxmisc.richtext.Caret.moveBreaksForwards.

Moves the caret forwards by the number of breaks.

Annotations
@Override
moveContentBreaksback to summary
private void moveContentBreaks(int numOfBreaks, BreakIterator breakIterator, boolean followingNotPreceding)

Helper method for reducing duplicate code

Parameters
numOfBreaks:int

the number of breaks

breakIterator:BreakIterator

the type of iterator to use

followingNotPreceding:boolean

if true, use BreakIterator#following(int). Otherwise, use BreakIterator#preceding(int).

moveToback to summary
public void moveTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Caret.moveTo.

Doc from org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the given position in the area. If this caret is bound to a CaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting the CaretSelectionBind#getAnchorPosition() bounded selection's anchor} or the CaretSelectionBind#getRange() selection}.
This method can be used to achieve the special case of positioning the caret outside or inside the selection, as opposed to always being at the boundary. Use with care.

Caution

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

moveToback to summary
public void moveTo(int position)

Implements org.fxmisc.richtext.Caret.moveTo.

Doc from org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the given position in the area. If this caret is bound to a CaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting the CaretSelectionBind#getAnchorPosition() bounded selection's anchor} or the CaretSelectionBind#getRange() selection}.
This method can be used to achieve the special case of positioning the caret outside or inside the selection, as opposed to always being at the boundary. Use with care.

moveToAreaEndback to summary
public void moveToAreaEnd()

Implements org.fxmisc.richtext.Caret.moveToAreaEnd.

Doc from org.fxmisc.richtext.Caret.moveToAreaEnd.

Moves the caret to the end of the area.

Annotations
@Override
moveToNextCharback to summary
public void moveToNextChar()

Implements org.fxmisc.richtext.Caret.moveToNextChar.

Doc from org.fxmisc.richtext.Caret.moveToNextChar.

Moves the caret forward one char in the text.

Annotations
@Override
moveToParEndback to summary
public void moveToParEnd()

Implements org.fxmisc.richtext.Caret.moveToParEnd.

Doc from org.fxmisc.richtext.Caret.moveToParEnd.

Moves the caret to the end of the current paragraph.

Annotations
@Override
moveToParStartback to summary
public void moveToParStart()

Implements org.fxmisc.richtext.Caret.moveToParStart.

Doc from org.fxmisc.richtext.Caret.moveToParStart.

Moves the caret to the beginning of the current paragraph.

Annotations
@Override
moveToPrevCharback to summary
public void moveToPrevChar()

Implements org.fxmisc.richtext.Caret.moveToPrevChar.

Doc from org.fxmisc.richtext.Caret.moveToPrevChar.

Moves the caret backward one char in the text.

Annotations
@Override
paragraphIndexPropertyback to summary
public final ObservableValue<Integer> paragraphIndexProperty()

Implements org.fxmisc.richtext.Caret.paragraphIndexProperty.

Doc from org.fxmisc.richtext.Caret.paragraphIndexProperty.

The paragraph index that contains this caret

Annotations
@Override
positionPropertyback to summary
public final ObservableValue<Integer> positionProperty()

Implements org.fxmisc.richtext.Caret.positionProperty.

Doc from org.fxmisc.richtext.Caret.positionProperty.

The position of the caret within the text

Annotations
@Override
setBlinkRateback to summary
public void setBlinkRate(Duration rate)

Implements org.fxmisc.richtext.Caret.setBlinkRate.

Annotations
@Override
setShowCaretback to summary
public final void setShowCaret(Caret.CaretVisibility value)

Implements org.fxmisc.richtext.Caret.setShowCaret.

Annotations
@Override
showCaretPropertyback to summary
public final Var<Caret.CaretVisibility> showCaretProperty()

Implements org.fxmisc.richtext.Caret.showCaretProperty.

Doc from org.fxmisc.richtext.Caret.showCaretProperty.

Whether to display the caret or not. Default value is CaretVisibility#AUTO.

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

Overrides javafx.scene.shape.Path.toString.

Doc from javafx.scene.shape.Path.toString.

Returns a string representation of this Path object.

Annotations
@Override