Class TextPos
java.lang.Object
jfx.incubator.scene.control.richtext.TextPos
- All Implemented Interfaces:
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTextPos
(int index, int offset, int charIndex, boolean leading) Creates a new text position. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the character index.int
int
index()
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
offset()
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.
-
Field Details
-
ZERO
A text position at the start of the document.
-
-
Constructor Details
-
TextPos
public TextPos(int index, int offset, int charIndex, boolean leading) Creates a new text position.- Parameters:
index
- the paragraph indexoffset
- the offset in the text which corresponds to the insertion positioncharIndex
- the character indexleading
- indicates whether the position is at the leading edge of the character atcharIndex
-
-
Method Details
-
ofLeading
Creates a new text position at the leading edge of the character at the specified text offset.- Parameters:
index
- the paragraph indexoffset
- the text offset- Returns:
- the instance of
TextPos
-
index
public int index()Returns the paragraph index.- Returns:
- the paragraph index
-
offset
public int offset()Returns the offset into the plain text string (insertion index).- Returns:
- the offset
-
charIndex
public int charIndex()Returns the character index.- Returns:
- the character index
-
isLeading
public boolean isLeading()Determines whether the text position is leading or trailing.- Returns:
- true if leading text position
-
compareTo
- Specified by:
compareTo
in interfaceComparable<TextPos>
-
isSameInsertionIndex
Returns true if the specified insertion point is the same.- Parameters:
p
- text position- Returns:
- true if same insertion index
-