Class TextPos

java.lang.Object
jfx.incubator.scene.control.richtext.TextPos
All Implemented Interfaces:
Comparable<TextPos>

public final class TextPos extends Object implements Comparable<TextPos>
An immutable position within the text.

Because it is immutable, it cannot track locations in the document which is being edited. For that, use Marker.

Since:
24
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    static final TextPos
    A text position at the start of the document.
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    TextPos(int index, int offset, int charIndex, boolean leading)
    Creates a new text position.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    int
    Returns the character index.
    int
     
    int
    Returns the paragraph index.
    boolean
    Determines whether the text position is leading or trailing.
    boolean
    Returns true if the specified insertion point is the same.
    int
    Returns the offset into the plain text string (insertion index).
    static TextPos
    ofLeading(int index, int offset)
    Creates a new text position at the leading edge of the character at the specified text offset.

    Methods declared in class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details Link icon

    • ZERO Link icon

      public static final TextPos ZERO
      A text position at the start of the document.
  • Constructor Details Link icon

    • TextPos Link icon

      public TextPos(int index, int offset, int charIndex, boolean leading)
      Creates a new text position.
      Parameters:
      index - the paragraph index
      offset - the offset in the text which corresponds to the insertion position
      charIndex - the character index
      leading - indicates whether the position is at the leading edge of the character at charIndex
  • Method Details Link icon

    • ofLeading Link icon

      public static TextPos ofLeading(int index, int offset)
      Creates a new text position at the leading edge of the character at the specified text offset.
      Parameters:
      index - the paragraph index
      offset - the text offset
      Returns:
      the instance of TextPos
    • index Link icon

      public int index()
      Returns the paragraph index.
      Returns:
      the paragraph index
    • offset Link icon

      public int offset()
      Returns the offset into the plain text string (insertion index).
      Returns:
      the offset
    • charIndex Link icon

      public int charIndex()
      Returns the character index.
      Returns:
      the character index
    • isLeading Link icon

      public boolean isLeading()
      Determines whether the text position is leading or trailing.
      Returns:
      true if leading text position
    • compareTo Link icon

      public int compareTo(TextPos p)
      Specified by:
      compareTo in interface Comparable<TextPos>
    • isSameInsertionIndex Link icon

      public boolean isSameInsertionIndex(TextPos p)
      Returns true if the specified insertion point is the same.
      Parameters:
      p - text position
      Returns:
      true if same insertion index