Package org.fxmisc.richtext
Class CharacterHit
- java.lang.Object
-
- org.fxmisc.richtext.CharacterHit
-
public class CharacterHit extends java.lang.Object
Object that stores information relating to the position in an area's content that corresponds to a given position in some visible entity (e.g. the area, a paragraph in the area, a line on a paragraph).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.OptionalInt
getCharacterIndex()
Returns anOptionalInt
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()
WhengetCharacterIndex()
is present, returns either the same value asgetCharacterIndex()
when the character index is leading andgetCharacterIndex() + 1
when the index is trailing.static CharacterHit
insertionAt(int insertionIndex)
Returns aCharacterHit
for cases where the insertion occurs outside the bounds of some visible entity (e.g.static CharacterHit
leadingHalfOf(int charIdx)
Returns aCharacterHit
for cases where the hit occurs inside the bounds of some visible entity (e.g.CharacterHit
offset(int offsetAmount)
Offsets the values stored in thisCharacterHit
by the given amountstatic CharacterHit
trailingHalfOf(int charIdx)
Returns aCharacterHit
for cases where the hit occurs inside the bounds of some visible entity (e.g.
-
-
-
Method Detail
-
insertionAt
public static CharacterHit insertionAt(int insertionIndex)
Returns aCharacterHit
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)
-
leadingHalfOf
public static CharacterHit leadingHalfOf(int charIdx)
Returns aCharacterHit
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.
-
trailingHalfOf
public static CharacterHit trailingHalfOf(int charIdx)
Returns aCharacterHit
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.
-
getCharacterIndex
public java.util.OptionalInt getCharacterIndex()
Returns anOptionalInt
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.
-
getInsertionIndex
public int getInsertionIndex()
WhengetCharacterIndex()
is present, returns either the same value asgetCharacterIndex()
when the character index is leading andgetCharacterIndex() + 1
when the index is trailing. WhengetCharacterIndex()
is absent, returns the bounds of that visible entity (either0
or the length of the area, the length of a paragraph, or the character count of a line).
-
offset
public CharacterHit offset(int offsetAmount)
Offsets the values stored in thisCharacterHit
by the given amount
-
-