Class 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 Detail

      • insertionAt

        public static CharacterHit insertionAt​(int insertionIndex)
        Returns a 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)
      • leadingHalfOf

        public static CharacterHit leadingHalfOf​(int charIdx)
        Returns a 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.
      • trailingHalfOf

        public static CharacterHit trailingHalfOf​(int charIdx)
        Returns a 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.
      • getCharacterIndex

        public 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.
      • getInsertionIndex

        public 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. 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).
      • offset

        public CharacterHit offset​(int offsetAmount)
        Offsets the values stored in this CharacterHit by the given amount