Package limn.graphics

Record Class ShapedText.Position

java.lang.Object
java.lang.Record
limn.graphics.ShapedText.Position
Record Components:
charIndex - char index into the line's text, in logical order
affinity - which side of it the caret is on
Enclosing class:
ShapedText

public static record ShapedText.Position(int charIndex, ShapedText.Affinity affinity) extends Record
A caret position: where text is inserted, plus which side of that index the caret is on.

The index alone is the insertion point, and is what the edit model, the clipboard and the IME need. The pair is what the line needs: on a direction boundary one index is two points, so ShapedText.hitTest(float) hands back a pair and ShapedText.caretLeft(limn.graphics.ShapedText.Position) moves between pairs. Off a boundary the side changes nothing.

  • Constructor Details

    • Position

      public Position(int charIndex, ShapedText.Affinity affinity)
      Creates an instance of a Position record class.
      Parameters:
      charIndex - the value for the charIndex record component
      affinity - the value for the affinity record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • charIndex

      public int charIndex()
      Returns the value of the charIndex record component.
      Returns:
      the value of the charIndex record component
    • affinity

      public ShapedText.Affinity affinity()
      Returns the value of the affinity record component.
      Returns:
      the value of the affinity record component