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
| Modifier and Type | Field | Description |
|---|---|---|
static final TextPos |
ZERO |
A text position at the start of the document. |
Constructor Summary
| Constructor | Description |
|---|---|
TextPos |
Creates a new text position. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
int |
charIndex() |
Returns the character index. |
int |
compareTo |
|
int |
index() |
Returns the paragraph index. |
boolean |
isLeading() |
Determines whether the text position is leading or trailing. |
boolean |
isSameInsertionIndex |
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 |
Creates a new text position at the leading edge of the character at the specified text offset. |
Field Details
ZERO
public static final TextPos 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 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 atcharIndex
Method Details
ofLeading
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
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
public int compareTo(TextPos p)
- Specified by:
-
compareToin interfaceComparable<TextPos>
isSameInsertionIndex
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
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.