Class CaretNode

  • All Implemented Interfaces:
    java.lang.Comparable<CaretNode>, javafx.css.Styleable, javafx.event.EventTarget, Caret

    public class CaretNode
    extends javafx.scene.shape.Path
    implements Caret, java.lang.Comparable<CaretNode>
    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. Node.boundsInLocalProperty(), Node.parentProperty(), etc.). Also, caretBoundsProperty() is distinguishable from Node.boundsInLocalProperty().

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

    • Property Summary

      Properties 
      Type Property Description
      SuspendableNo beingUpdated  
      javafx.beans.property.ObjectProperty<javafx.util.Duration> blinkRate
      The blink rate of the caret.
      javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBounds
      The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
      javafx.beans.value.ObservableValue<java.lang.Integer> columnPosition
      The column position of the caret on its given line
      javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndex
      The line index of a multi-line paragraph that contains this caret
      javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndex
      The paragraph index that contains this caret
      javafx.beans.value.ObservableValue<java.lang.Integer> position
      The position of the caret within the text
      Var<Caret.CaretVisibility> showCaret
      Whether to display the caret or not.
      • Properties inherited from class javafx.scene.shape.Path

        fillRule
      • 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, 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
      • Properties inherited from interface org.fxmisc.richtext.Caret

        visible
    • Field Summary

      • Fields inherited from class javafx.scene.Node

        BASELINE_OFFSET_SAME_AS_HEIGHT
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SuspendableNo beingUpdatedProperty()  
      javafx.beans.property.ObjectProperty<javafx.util.Duration> blinkRateProperty()
      The blink rate of the caret.
      javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty()
      The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
      void clearTargetOffset()
      Clears the caret's x offset
      javafx.beans.value.ObservableValue<java.lang.Integer> columnPositionProperty()
      The column position of the caret on its given line
      int compareTo​(CaretNode o)  
      void dispose()
      Disposes the caret and prevents memory leaks
      boolean equals​(java.lang.Object obj)  
      GenericStyledArea<?,​?,​?> getArea()
      Gets the area with which this caret is associated.
      javafx.util.Duration getBlinkRate()
      Gets the value of the property blinkRate.
      java.util.Optional<javafx.geometry.Bounds> getCaretBounds()
      Gets the value of the property caretBounds.
      java.lang.String getCaretName()
      Gets the name of this caret.
      static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getClassCssMetaData()  
      int getColumnPosition()
      Gets the value of the property columnPosition.
      java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaData()  
      java.util.OptionalInt getLineIndex()
      Gets the value of the property lineIndex.
      int getParagraphIndex()
      Gets the value of the property paragraphIndex.
      int getPosition()
      Gets the value of the property position.
      Caret.CaretVisibility getShowCaret()
      Gets the value of the property showCaret.
      org.fxmisc.richtext.ParagraphBox.CaretOffsetX 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.
      int hashCode()  
      boolean isBeingUpdated()  
      javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndexProperty()
      The line index of a multi-line paragraph that contains this caret
      void moveBreaksBackwards​(int numOfBreaks, java.text.BreakIterator breakIterator)
      Moves the caret backwards by the number of breaks.
      void moveBreaksForwards​(int numOfBreaks, java.text.BreakIterator breakIterator)
      Moves the caret forwards by the number of breaks.
      void moveTo​(int position)
      Moves the caret to the given position in the area.
      void moveTo​(int paragraphIndex, int columnPosition)
      Moves the caret to the given position in the area.
      void moveToAreaEnd()
      Moves the caret to the end of the area.
      void moveToNextChar()
      Moves the caret forward one char in the text.
      void moveToParEnd()
      Moves the caret to the end of the current paragraph.
      void moveToParStart()
      Moves the caret to the beginning of the current paragraph.
      void moveToPrevChar()
      Moves the caret backward one char in the text.
      javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndexProperty()
      The paragraph index that contains this caret
      javafx.beans.value.ObservableValue<java.lang.Integer> positionProperty()
      The position of the caret within the text
      void setBlinkRate​(javafx.util.Duration rate)
      Sets the value of the property blinkRate.
      void setShowCaret​(Caret.CaretVisibility value)
      Sets the value of the property showCaret.
      Var<Caret.CaretVisibility> showCaretProperty()
      Whether to display the caret or not.
      java.lang.String toString()  
      • 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, 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, 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 javafx.css.Styleable

        getStyleableNode
    • Constructor Detail

      • CaretNode

        public CaretNode​(java.lang.String name,
                         GenericStyledArea<?,​?,​?> area)
      • CaretNode

        public CaretNode​(java.lang.String name,
                         GenericStyledArea<?,​?,​?> area,
                         int startingPosition)
      • CaretNode

        public CaretNode​(java.lang.String name,
                         GenericStyledArea<?,​?,​?> area,
                         SuspendableNo dependentBeingUpdated,
                         int startingPosition)
    • Method Detail

      • getBlinkRate

        public javafx.util.Duration getBlinkRate()
        Gets the value of the property blinkRate.
        Specified by:
        getBlinkRate in interface Caret
        Property description:
        Controls the blink rate of the caret, when one is displayed. Setting the duration to zero disables blinking.
      • setBlinkRate

        public void setBlinkRate​(javafx.util.Duration rate)
        Sets the value of the property blinkRate.
        Specified by:
        setBlinkRate in interface Caret
        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:
        getPosition in interface Caret
        Property description:
      • positionProperty

        public final javafx.beans.value.ObservableValue<java.lang.Integer> positionProperty()
        Description copied from interface: Caret
        The position of the caret within the text
        Specified by:
        positionProperty in interface Caret
        See Also:
        getPosition()
      • getParagraphIndex

        public final int getParagraphIndex()
        Gets the value of the property paragraphIndex.
        Specified by:
        getParagraphIndex in interface Caret
        Property description:
      • paragraphIndexProperty

        public final javafx.beans.value.ObservableValue<java.lang.Integer> paragraphIndexProperty()
        Description copied from interface: Caret
        The paragraph index that contains this caret
        Specified by:
        paragraphIndexProperty in interface Caret
        See Also:
        getParagraphIndex()
      • getLineIndex

        public final java.util.OptionalInt getLineIndex()
        Gets the value of the property lineIndex.
        Specified by:
        getLineIndex in interface Caret
        Property description:
      • lineIndexProperty

        public final javafx.beans.value.ObservableValue<java.util.OptionalInt> lineIndexProperty()
        Description copied from interface: Caret
        The line index of a multi-line paragraph that contains this caret
        Specified by:
        lineIndexProperty in interface Caret
        See Also:
        getLineIndex()
      • getColumnPosition

        public final int getColumnPosition()
        Gets the value of the property columnPosition.
        Specified by:
        getColumnPosition in interface Caret
        Property description:
      • columnPositionProperty

        public final javafx.beans.value.ObservableValue<java.lang.Integer> columnPositionProperty()
        Description copied from interface: Caret
        The column position of the caret on its given line
        Specified by:
        columnPositionProperty in interface Caret
        See Also:
        getColumnPosition()
      • setShowCaret

        public final void setShowCaret​(Caret.CaretVisibility value)
        Sets the value of the property showCaret.
        Specified by:
        setShowCaret in interface Caret
        Property description:
      • getCaretBounds

        public final java.util.Optional<javafx.geometry.Bounds> getCaretBounds()
        Gets the value of the property caretBounds.
        Specified by:
        getCaretBounds in interface Caret
        Property description:
      • caretBoundsProperty

        public final javafx.beans.value.ObservableValue<java.util.Optional<javafx.geometry.Bounds>> caretBoundsProperty()
        Description copied from interface: Caret
        The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional.empty() if caret is not visible in the viewport.
        Specified by:
        caretBoundsProperty in interface Caret
        See Also:
        getCaretBounds()
      • clearTargetOffset

        public final void clearTargetOffset()
        Description copied from interface: Caret
        Clears the caret's x offset
        Specified by:
        clearTargetOffset in interface Caret
      • getTargetOffset

        public final org.fxmisc.richtext.ParagraphBox.CaretOffsetX getTargetOffset()
        Description copied from interface: Caret
        Stores 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:
        getTargetOffset in interface Caret
      • isBeingUpdated

        public final boolean isBeingUpdated()
        Specified by:
        isBeingUpdated in interface Caret
      • getArea

        public GenericStyledArea<?,​?,​?> getArea()
        Description copied from interface: Caret
        Gets the area with which this caret is associated.
        Specified by:
        getArea in interface Caret
      • getCaretName

        public final java.lang.String getCaretName()
        Description copied from interface: Caret
        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.
        Specified by:
        getCaretName in interface Caret
      • moveTo

        public void moveTo​(int paragraphIndex,
                           int columnPosition)
        Description copied from interface: Caret
        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 Selection.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.

        Specified by:
        moveTo in interface Caret
      • moveTo

        public void moveTo​(int position)
        Description copied from interface: Caret
        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 Selection.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.
        Specified by:
        moveTo in interface Caret
      • moveToParStart

        public void moveToParStart()
        Description copied from interface: Caret
        Moves the caret to the beginning of the current paragraph.
        Specified by:
        moveToParStart in interface Caret
      • moveToParEnd

        public void moveToParEnd()
        Description copied from interface: Caret
        Moves the caret to the end of the current paragraph.
        Specified by:
        moveToParEnd in interface Caret
      • moveToAreaEnd

        public void moveToAreaEnd()
        Description copied from interface: Caret
        Moves the caret to the end of the area.
        Specified by:
        moveToAreaEnd in interface Caret
      • moveToNextChar

        public void moveToNextChar()
        Description copied from interface: Caret
        Moves the caret forward one char in the text.
        Specified by:
        moveToNextChar in interface Caret
      • moveToPrevChar

        public void moveToPrevChar()
        Description copied from interface: Caret
        Moves the caret backward one char in the text.
        Specified by:
        moveToPrevChar in interface Caret
      • moveBreaksBackwards

        public void moveBreaksBackwards​(int numOfBreaks,
                                        java.text.BreakIterator breakIterator)
        Description copied from interface: Caret
        Moves the caret backwards by the number of breaks.
        Specified by:
        moveBreaksBackwards in interface Caret
      • moveBreaksForwards

        public void moveBreaksForwards​(int numOfBreaks,
                                       java.text.BreakIterator breakIterator)
        Description copied from interface: Caret
        Moves the caret forwards by the number of breaks.
        Specified by:
        moveBreaksForwards in interface Caret
      • compareTo

        public int compareTo​(CaretNode o)
        Specified by:
        compareTo in interface java.lang.Comparable<CaretNode>
      • dispose

        public void dispose()
        Description copied from interface: Caret
        Disposes the caret and prevents memory leaks
        Specified by:
        dispose in interface Caret
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class javafx.scene.shape.Path
      • getCssMetaData

        public java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaData()
        Specified by:
        getCssMetaData in interface javafx.css.Styleable
        Overrides:
        getCssMetaData in class javafx.scene.shape.Shape
      • getClassCssMetaData

        public static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getClassCssMetaData()