Package org.fxmisc.richtext
Class CaretNode
- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.shape.Shape
-
- javafx.scene.shape.Path
-
- org.fxmisc.richtext.CaretNode
-
- All Implemented Interfaces:
Comparable<CaretNode>,Styleable,EventTarget,Caret
public class CaretNode extends Path implements Caret, Comparable<CaretNode>
Default implementation for aCaret. Since only onePathobject 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.Node.boundsInLocalProperty(),Node.parentProperty(), etc.). Also,caretBoundsProperty()is distinguishable fromNode.boundsInLocalProperty().This class adds the css property "-rtfx-blink-rate" (
blinkRateProperty()}
-
-
Property Summary
Properties Type Property Description SuspendableNobeingUpdatedObjectProperty<Duration>blinkRateThe blink rate of the caret.ObservableValue<Optional<Bounds>>caretBoundsThe selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.ObservableValue<Integer>columnPositionThe column position of the caret on its given lineObservableValue<OptionalInt>lineIndexThe line index of a multi-line paragraph that contains this caretObservableValue<Integer>paragraphIndexThe paragraph index that contains this caretObservableValue<Integer>positionThe position of the caret within the textVar<Caret.CaretVisibility>showCaretWhether to display the caret or not.-
Properties inherited from class javafx.scene.shape.Shape
fill, smooth, strokeDashOffset, strokeLineCap, strokeLineJoin, strokeMiterLimit, stroke, strokeType, strokeWidth
-
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.Caret
Caret.CaretVisibility
-
-
Field Summary
-
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Constructor Summary
Constructors Constructor Description CaretNode(String name, GenericStyledArea<?,?,?> area)CaretNode(String name, GenericStyledArea<?,?,?> area, int startingPosition)CaretNode(String name, GenericStyledArea<?,?,?> area, SuspendableNo dependentBeingUpdated, int startingPosition)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SuspendableNobeingUpdatedProperty()ObjectProperty<Duration>blinkRateProperty()The blink rate of the caret.ObservableValue<Optional<Bounds>>caretBoundsProperty()The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.voidclearTargetOffset()Clears the caret's x offsetObservableValue<Integer>columnPositionProperty()The column position of the caret on its given lineintcompareTo(CaretNode o)voiddispose()Disposes the caret and prevents memory leaksbooleanequals(Object obj)GenericStyledArea<?,?,?>getArea()Gets the area with which this caret is associated.DurationgetBlinkRate()Gets the value of the property blinkRate.Optional<Bounds>getCaretBounds()Gets the value of the property caretBounds.StringgetCaretName()Gets the name of this caret.static List<CssMetaData<? extends Styleable,?>>getClassCssMetaData()intgetColumnPosition()Gets the value of the property columnPosition.List<CssMetaData<? extends Styleable,?>>getCssMetaData()OptionalIntgetLineIndex()Gets the value of the property lineIndex.intgetParagraphIndex()Gets the value of the property paragraphIndex.intgetPosition()Gets the value of the property position.Caret.CaretVisibilitygetShowCaret()Gets the value of the property showCaret.org.fxmisc.richtext.ParagraphBox.CaretOffsetXgetTargetOffset()Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.inthashCode()booleanisBeingUpdated()ObservableValue<OptionalInt>lineIndexProperty()The line index of a multi-line paragraph that contains this caretvoidmoveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret backwards by the number of breaks.voidmoveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret forwards by the number of breaks.voidmoveTo(int position)Moves the caret to the given position in the area.voidmoveTo(int paragraphIndex, int columnPosition)Moves the caret to the given position in the area.voidmoveToAreaEnd()Moves the caret to the end of the area.voidmoveToNextChar()Moves the caret forward one char in the text.voidmoveToParEnd()Moves the caret to the end of the current paragraph.voidmoveToParStart()Moves the caret to the beginning of the current paragraph.voidmoveToPrevChar()Moves the caret backward one char in the text.ObservableValue<Integer>paragraphIndexProperty()The paragraph index that contains this caretObservableValue<Integer>positionProperty()The position of the caret within the textvoidsetBlinkRate(Duration rate)Sets the value of the property blinkRate.voidsetShowCaret(Caret.CaretVisibility value)Sets the value of the property showCaret.Var<Caret.CaretVisibility>showCaretProperty()Whether to display the caret or not.StringtoString()-
Methods inherited from class javafx.scene.shape.Path
fillRuleProperty, getElements, getFillRule, setFillRule
-
Methods inherited from class javafx.scene.shape.Shape
fillProperty, getFill, getStroke, getStrokeDashArray, getStrokeDashOffset, getStrokeLineCap, getStrokeLineJoin, getStrokeMiterLimit, getStrokeType, getStrokeWidth, intersect, isSmooth, setFill, setSmooth, setStroke, setStrokeDashOffset, setStrokeLineCap, setStrokeLineJoin, setStrokeMiterLimit, setStrokeType, setStrokeWidth, smoothProperty, strokeDashOffsetProperty, strokeLineCapProperty, strokeLineJoinProperty, strokeMiterLimitProperty, strokeProperty, strokeTypeProperty, strokeWidthProperty, subtract, union
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBaselineOffset, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, prefHeight, prefWidth, pressedProperty, pseudoClassStateChanged, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.fxmisc.richtext.Caret
isVisible, moveSentenceBreaksBackwards, moveSentenceBreaksForwards, moveToAreaStart, moveWordBreaksBackwards, moveWordBreaksForwards, visibleProperty
-
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
-
-
-
Property Detail
-
blinkRate
public ObjectProperty<Duration> blinkRateProperty
The blink rate of the caret. Can be styled from CSS using the "-rtfx-blink-rate" property.- Specified by:
blinkRatePropertyin interfaceCaret- See Also:
Caret.getBlinkRate(),Caret.setBlinkRate(Duration)
-
position
public final ObservableValue<Integer> positionProperty
- Specified by:
positionPropertyin interfaceCaret- See Also:
getPosition()
-
paragraphIndex
public final ObservableValue<Integer> paragraphIndexProperty
- Specified by:
paragraphIndexPropertyin interfaceCaret- See Also:
getParagraphIndex()
-
lineIndex
public final ObservableValue<OptionalInt> lineIndexProperty
- Specified by:
lineIndexPropertyin interfaceCaret- See Also:
getLineIndex()
-
columnPosition
public final ObservableValue<Integer> columnPositionProperty
- Specified by:
columnPositionPropertyin interfaceCaret- See Also:
getColumnPosition()
-
showCaret
public final Var<Caret.CaretVisibility> showCaretProperty
- Specified by:
showCaretPropertyin interfaceCaret- See Also:
getShowCaret(),setShowCaret(Caret.CaretVisibility)
-
caretBounds
public final ObservableValue<Optional<Bounds>> caretBoundsProperty
- Specified by:
caretBoundsPropertyin interfaceCaret- See Also:
getCaretBounds()
-
beingUpdated
public final SuspendableNo beingUpdatedProperty
- Specified by:
beingUpdatedPropertyin interfaceCaret
-
-
Constructor Detail
-
CaretNode
public CaretNode(String name, GenericStyledArea<?,?,?> area)
-
CaretNode
public CaretNode(String name, GenericStyledArea<?,?,?> area, int startingPosition)
-
CaretNode
public CaretNode(String name, GenericStyledArea<?,?,?> area, SuspendableNo dependentBeingUpdated, int startingPosition)
-
-
Method Detail
-
blinkRateProperty
public ObjectProperty<Duration> blinkRateProperty()
The blink rate of the caret. Can be styled from CSS using the "-rtfx-blink-rate" property.- Specified by:
blinkRatePropertyin interfaceCaret- See Also:
Caret.getBlinkRate(),Caret.setBlinkRate(Duration)
-
getBlinkRate
public Duration getBlinkRate()
Gets the value of the property blinkRate.- Specified by:
getBlinkRatein interfaceCaret- Property description:
- Controls the blink rate of the caret, when one is displayed. Setting the duration to zero disables blinking.
-
setBlinkRate
public void setBlinkRate(Duration rate)
Sets the value of the property blinkRate.- Specified by:
setBlinkRatein interfaceCaret- Property description:
- Controls the blink rate of the caret, when one is displayed. Setting the duration to zero disables blinking.
-
getPosition
public final int getPosition()
Gets the value of the property position.- Specified by:
getPositionin interfaceCaret- Property description:
-
positionProperty
public final ObservableValue<Integer> positionProperty()
Description copied from interface:CaretThe position of the caret within the text- Specified by:
positionPropertyin interfaceCaret- See Also:
getPosition()
-
getParagraphIndex
public final int getParagraphIndex()
Gets the value of the property paragraphIndex.- Specified by:
getParagraphIndexin interfaceCaret- Property description:
-
paragraphIndexProperty
public final ObservableValue<Integer> paragraphIndexProperty()
Description copied from interface:CaretThe paragraph index that contains this caret- Specified by:
paragraphIndexPropertyin interfaceCaret- See Also:
getParagraphIndex()
-
getLineIndex
public final OptionalInt getLineIndex()
Gets the value of the property lineIndex.- Specified by:
getLineIndexin interfaceCaret- Property description:
-
lineIndexProperty
public final ObservableValue<OptionalInt> lineIndexProperty()
Description copied from interface:CaretThe line index of a multi-line paragraph that contains this caret- Specified by:
lineIndexPropertyin interfaceCaret- See Also:
getLineIndex()
-
getColumnPosition
public final int getColumnPosition()
Gets the value of the property columnPosition.- Specified by:
getColumnPositionin interfaceCaret- Property description:
-
columnPositionProperty
public final ObservableValue<Integer> columnPositionProperty()
Description copied from interface:CaretThe column position of the caret on its given line- Specified by:
columnPositionPropertyin interfaceCaret- See Also:
getColumnPosition()
-
getShowCaret
public final Caret.CaretVisibility getShowCaret()
Gets the value of the property showCaret.- Specified by:
getShowCaretin interfaceCaret- Property description:
-
setShowCaret
public final void setShowCaret(Caret.CaretVisibility value)
Sets the value of the property showCaret.- Specified by:
setShowCaretin interfaceCaret- Property description:
-
showCaretProperty
public final Var<Caret.CaretVisibility> showCaretProperty()
Description copied from interface:CaretWhether to display the caret or not. Default value isCaret.CaretVisibility.AUTO.- Specified by:
showCaretPropertyin interfaceCaret- See Also:
getShowCaret(),setShowCaret(Caret.CaretVisibility)
-
getCaretBounds
public final Optional<Bounds> getCaretBounds()
Gets the value of the property caretBounds.- Specified by:
getCaretBoundsin interfaceCaret- Property description:
-
caretBoundsProperty
public final ObservableValue<Optional<Bounds>> caretBoundsProperty()
Description copied from interface:CaretThe selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.- Specified by:
caretBoundsPropertyin interfaceCaret- See Also:
getCaretBounds()
-
clearTargetOffset
public final void clearTargetOffset()
Description copied from interface:CaretClears the caret's x offset- Specified by:
clearTargetOffsetin interfaceCaret
-
getTargetOffset
public final org.fxmisc.richtext.ParagraphBox.CaretOffsetX getTargetOffset()
Description copied from interface:CaretStores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.- Specified by:
getTargetOffsetin interfaceCaret
-
isBeingUpdated
public final boolean isBeingUpdated()
- Specified by:
isBeingUpdatedin interfaceCaret
-
beingUpdatedProperty
public final SuspendableNo beingUpdatedProperty()
- Specified by:
beingUpdatedPropertyin interfaceCaret
-
getArea
public GenericStyledArea<?,?,?> getArea()
Description copied from interface:CaretGets the area with which this caret is associated.
-
getCaretName
public final String getCaretName()
Description copied from interface:CaretGets 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.- Specified by:
getCaretNamein interfaceCaret
-
moveTo
public void moveTo(int paragraphIndex, int columnPosition)Description copied from interface:CaretMoves the caret to the given position in the area. If this caret is bound to aCaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting theCaretSelectionBind.getAnchorPosition()bounded selection's anchor} or theSelection.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.
-
moveTo
public void moveTo(int position)
Description copied from interface:CaretMoves the caret to the given position in the area. If this caret is bound to aCaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting theCaretSelectionBind.getAnchorPosition()bounded selection's anchor} or theSelection.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.
-
moveToParStart
public void moveToParStart()
Description copied from interface:CaretMoves the caret to the beginning of the current paragraph.- Specified by:
moveToParStartin interfaceCaret
-
moveToParEnd
public void moveToParEnd()
Description copied from interface:CaretMoves the caret to the end of the current paragraph.- Specified by:
moveToParEndin interfaceCaret
-
moveToAreaEnd
public void moveToAreaEnd()
Description copied from interface:CaretMoves the caret to the end of the area.- Specified by:
moveToAreaEndin interfaceCaret
-
moveToNextChar
public void moveToNextChar()
Description copied from interface:CaretMoves the caret forward one char in the text.- Specified by:
moveToNextCharin interfaceCaret
-
moveToPrevChar
public void moveToPrevChar()
Description copied from interface:CaretMoves the caret backward one char in the text.- Specified by:
moveToPrevCharin interfaceCaret
-
moveBreaksBackwards
public void moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)Description copied from interface:CaretMoves the caret backwards by the number of breaks.- Specified by:
moveBreaksBackwardsin interfaceCaret
-
moveBreaksForwards
public void moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)Description copied from interface:CaretMoves the caret forwards by the number of breaks.- Specified by:
moveBreaksForwardsin interfaceCaret
-
compareTo
public int compareTo(CaretNode o)
- Specified by:
compareToin interfaceComparable<CaretNode>
-
dispose
public void dispose()
Description copied from interface:CaretDisposes the caret and prevents memory leaks
-
getCssMetaData
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
- Specified by:
getCssMetaDatain interfaceStyleable- Overrides:
getCssMetaDatain classShape
-
getClassCssMetaData
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
-
-