Package limn.graphics

Record Class ShapedText.Caret

java.lang.Object
java.lang.Record
limn.graphics.ShapedText.Caret
Record Components:
upstreamX - x of the trailing edge of the character before the index; at index 0 there is none, and this is the paragraph's own start edge in the base direction
downstreamX - x of the leading edge of the character at the index; at the end of the text there is none, and this is the paragraph's own end edge in the base direction
downstreamIsStrong - whether downstreamX is the strong side: the one whose bidi level has the base direction's parity, and the lower level of the two when both do
Enclosing class:
ShapedText

public static record ShapedText.Caret(float upstreamX, float downstreamX, boolean downstreamIsStrong) extends Record
The two places a caret may sit for one char index, for a caller that stores no side.

Both are true, and that is the point. At the end of Latin text followed by Hebrew, a left-to-right keystroke appears where the Latin run ends and a right-to-left keystroke appears where the Hebrew run ends; those are different points on the line, and a caret drawn at one of them alone tells the user the wrong thing about where the next character will land. Drawing strongX() full height and weakX() as a smaller mark is the usual answer; drawing only the strong one is a decision to lie in the mixed case.

Off a boundary the two are the same point, and they are the same float, copied from one caret stop — so split() is an exact comparison rather than a float equality test standing in for one, and a boolean field that could contradict the two positions does not exist.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Caret(float upstreamX, float downstreamX, boolean downstreamIsStrong)
    Creates an instance of a Caret record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the downstreamIsStrong record component.
    float
    Returns the value of the downstreamX record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Whether the two positions differ, and a second mark therefore has to be drawn.
    float
    Where a keystroke in the base direction lands: the caret to draw at full height.
    final String
    Returns a string representation of this record class.
    float
    Returns the value of the upstreamX record component.
    float
    Where a keystroke in the other direction lands; equal to strongX() off a boundary.
    float
    The one position a caller with a stored side means.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Caret

      public Caret(float upstreamX, float downstreamX, boolean downstreamIsStrong)
      Creates an instance of a Caret record class.
      Parameters:
      upstreamX - the value for the upstreamX record component
      downstreamX - the value for the downstreamX record component
      downstreamIsStrong - the value for the downstreamIsStrong record component
  • Method Details

    • split

      public boolean split()
      Whether the two positions differ, and a second mark therefore has to be drawn.
    • strongX

      public float strongX()
      Where a keystroke in the base direction lands: the caret to draw at full height.
    • weakX

      public float weakX()
      Where a keystroke in the other direction lands; equal to strongX() off a boundary.
    • x

      public float x(ShapedText.Affinity affinity)
      The one position a caller with a stored side means.
      Parameters:
      affinity - which side of the index the caret is on
    • 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. All components in this record class 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.
    • upstreamX

      public float upstreamX()
      Returns the value of the upstreamX record component.
      Returns:
      the value of the upstreamX record component
    • downstreamX

      public float downstreamX()
      Returns the value of the downstreamX record component.
      Returns:
      the value of the downstreamX record component
    • downstreamIsStrong

      public boolean downstreamIsStrong()
      Returns the value of the downstreamIsStrong record component.
      Returns:
      the value of the downstreamIsStrong record component