Class ComposedLine

java.lang.Object
com.mta.tehreer.layout.ComposedLine

public class ComposedLine extends Object
Represents a line of text consisting of an array of GlyphRun objects in visual order.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    float
    computeCharDistance(int charIndex)
    Determines the distance of specified character from the start of the line assumed at zero.
    int
    computeNearestCharIndex(float distance)
    Returns the index of character nearest to the specified distance.
    float[]
    computeVisualEdges(int charStart, int charEnd)
    Returns an array of visual edges corresponding to the specified character range.
    void
    draw(Renderer renderer, Canvas canvas, float x, float y)
    Draws this line onto the given canvas using the given renderer.
    float
    Returns the ascent of this line which is the maximum ascent from the baseline of all runs.
    int
    Returns the index after the last character of this line in source text.
    int
    Returns the index to the first character of this line in source text.
    float
    Returns the descent of this line which is the maximum descent from the baseline of all runs.
    float
     
    float
    getFlushPenOffset(float flushFactor, float flushExtent)
    Returns the pen offset required to draw flush text.
    float
    Returns the typographic height of this line.
    float
    Returns the leading of this line which is the maximum leading of all runs.
    float
    Returns the x- origin of this line in parent frame.
    float
    Returns the y- origin of this line in parent frame.
    byte
    Returns the paragraph level of this line.
    Returns an unmodifiable list that contains all the runs of this line.
    float
    Returns the advance sum of glyphs corresponding to the trailing whitespace characters in this line.
    float
    Returns the typographic width of this line.
    void
    setFlushFactor(float flushFactor)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getCharStart

      public int getCharStart()
      Returns the index to the first character of this line in source text.
      Returns:
      The index to the first character of this line in source text.
    • getCharEnd

      public int getCharEnd()
      Returns the index after the last character of this line in source text.
      Returns:
      The index after the last character of this line in source text.
    • getFlushFactor

      public float getFlushFactor()
    • setFlushFactor

      public void setFlushFactor(float flushFactor)
    • getParagraphLevel

      public byte getParagraphLevel()
      Returns the paragraph level of this line.
      Returns:
      The paragraph level of this line.
    • getOriginX

      public float getOriginX()
      Returns the x- origin of this line in parent frame.
      Returns:
      The x- origin of this line in parent frame.
    • getOriginY

      public float getOriginY()
      Returns the y- origin of this line in parent frame.
      Returns:
      The y- origin of this line in parent frame.
    • getAscent

      public float getAscent()
      Returns the ascent of this line which is the maximum ascent from the baseline of all runs.
      Returns:
      The ascent of this line.
    • getDescent

      public float getDescent()
      Returns the descent of this line which is the maximum descent from the baseline of all runs.
      Returns:
      The descent of this line.
    • getLeading

      public float getLeading()
      Returns the leading of this line which is the maximum leading of all runs.
      Returns:
      The leading of this line.
    • getWidth

      public float getWidth()
      Returns the typographic width of this line.
      Returns:
      The typographic width of this line.
    • getHeight

      public float getHeight()
      Returns the typographic height of this line.
      Returns:
      The typographic height of this line.
    • getTrailingWhitespaceExtent

      public float getTrailingWhitespaceExtent()
      Returns the advance sum of glyphs corresponding to the trailing whitespace characters in this line.
      Returns:
      The typographic extent for the glyphs corresponding to the trailing whitespace characters in this line.
    • getRuns

      @NonNull public List<GlyphRun> getRuns()
      Returns an unmodifiable list that contains all the runs of this line.
      Returns:
      An unmodifiable list that contains all the runs of this line.
    • computeCharDistance

      public float computeCharDistance(int charIndex)
      Determines the distance of specified character from the start of the line assumed at zero.
      Parameters:
      charIndex - The index of character in source text.
      Returns:
      The distance of specified character from the start of the line assumed at zero.
      Throws:
      IllegalArgumentException - if charIndex is less than line start or greater than line end.
    • computeVisualEdges

      @NonNull @Size(multiple=2L) public float[] computeVisualEdges(int charStart, int charEnd)
      Returns an array of visual edges corresponding to the specified character range.

      The resulting array will contain pairs of leading and trailing edges sorted from left to right. There will be a separate pair for each glyph run occurred in the specified character range. Each edge will be positioned relative to the start of the line assumed at zero.

      Parameters:
      charStart - The index to the first logical character in source text.
      charEnd - The index after the last logical character in source text.
      Returns:
      An array of visual edges corresponding to the specified character range.
      Throws:
      IllegalArgumentException - if charStart is less than line start, or charEnd is greater than line end, or charStart is greater than charEnd.
    • computeNearestCharIndex

      public int computeNearestCharIndex(float distance)
      Returns the index of character nearest to the specified distance.
      Parameters:
      distance - The distance for which to determine the character index. It should be offset from zero origin.
      Returns:
      The index of character nearest to the specified distance. It will be an absolute index in source string.
    • computeBoundingBox

      @NonNull public RectF computeBoundingBox(@NonNull Renderer renderer)
    • getFlushPenOffset

      public float getFlushPenOffset(float flushFactor, float flushExtent)
      Returns the pen offset required to draw flush text.
      Parameters:
      flushFactor - Specifies the kind of flushness. A flush factor of 0 or less indicates left flush. A flushFactor of 1.0 or more indicates right flush. Flush factors between 0 and 1.0 indicate varying degrees of center flush, with a value of 0.5 being totally center flush.
      flushExtent - Specifies the extent that the flushness operation should apply to.
      Returns:
      A value which can be used to offset the current pen position for the flush operation.
    • draw

      public void draw(@NonNull Renderer renderer, @NonNull Canvas canvas, float x, float y)
      Draws this line onto the given canvas using the given renderer.
      Parameters:
      renderer - The renderer to use for drawing this line.
      canvas - The canvas onto which to draw this line.
      x - The x- position at which to draw this line.
      y - The y- position at which to draw this line.
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object