public class CharacterHit
extends java.lang.Object
Modifier and Type | Method | Description |
---|---|---|
java.util.OptionalInt |
getCharacterIndex() |
Returns an
OptionalInt whose value is present when the hit occurs within the visible
entity and is the index of the closest character to the give position on the screen. |
int |
getInsertionIndex() |
When
getCharacterIndex() is present, returns either the same value as getCharacterIndex() when
the character index is leading and getCharacterIndex() + 1 when the index is trailing. |
static CharacterHit |
insertionAt(int insertionIndex) |
Returns a
CharacterHit for cases where the insertion occurs outside the bounds of some visible entity
(e.g. |
static CharacterHit |
leadingHalfOf(int charIdx) |
Returns a
CharacterHit for cases where the hit occurs inside the bounds of some visible entity
(e.g. |
CharacterHit |
offset(int offsetAmount) |
Offsets the values stored in this
CharacterHit by the given amount |
static CharacterHit |
trailingHalfOf(int charIdx) |
Returns a
CharacterHit for cases where the hit occurs inside the bounds of some visible entity
(e.g. |
public static CharacterHit insertionAt(int insertionIndex)
CharacterHit
for cases where the insertion occurs outside the bounds of some visible entity
(e.g. the area, the paragraph in an area, the line in a paragraph)public static CharacterHit leadingHalfOf(int charIdx)
CharacterHit
for cases where the hit occurs inside the bounds of some visible entity
(e.g. the area, the paragraph in an area, the line in a paragraph) and the character is leading.public static CharacterHit trailingHalfOf(int charIdx)
CharacterHit
for cases where the hit occurs inside the bounds of some visible entity
(e.g. the area, the paragraph in an area, the line in a paragraph) and the character is trailing.public java.util.OptionalInt getCharacterIndex()
OptionalInt
whose value is present when the hit occurs within the visible
entity and is the index of the closest character to the give position on the screen.public int getInsertionIndex()
getCharacterIndex()
is present, returns either the same value as getCharacterIndex()
when
the character index is leading and getCharacterIndex() + 1
when the index is trailing.
When getCharacterIndex()
is absent, returns the bounds of that visible entity (either 0
or
the length of the area, the length of a paragraph, or the character count of a line).public CharacterHit offset(int offsetAmount)
CharacterHit
by the given amount