Class ComposedFrame

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

public class ComposedFrame extends Object
Represents a frame containing multiple lines of text. The frame object is the output resulting from text-framing process performed by a typesetter object.
  • Method Details

    • getCharStart

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

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

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

      public float getOriginY()
      Returns the y- origin of this frame.
      Returns:
      The y- origin of this frame.
    • getWidth

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

      public float getHeight()
      Returns the height of this frame.
      Returns:
      The height of this frame.
    • getLines

      @NonNull public List<ComposedLine> getLines()
      Returns an unmodifiable list that contains all the lines of this frame.
      Returns:
      An unmodifiable list that contains all the lines of this frame.
    • getLineIndexForChar

      public int getLineIndexForChar(int charIndex)
      Returns the index of line containing the specified character.
      Parameters:
      charIndex - The index of character for which to return the line index.
      Returns:
      The index of line containing the specified character.
      Throws:
      IllegalArgumentException - if charIndex is less than frame start or greater than frame end.
    • getLineIndexForPosition

      public int getLineIndexForPosition(float x, float y)
      Returns the index of a suitable line representing the specified position.
      Parameters:
      x - The x- coordinate of position.
      y - The y- coordinate of position.
      Returns:
      The index of a suitable line representing the specified position.
    • generateSelectionPath

      @NonNull public Path generateSelectionPath(int charStart, int charEnd)
      Generates a path that contains a set of rectangles covering the specified selection range.
      Parameters:
      charStart - The index to the first character of selection in source text.
      charEnd - The index after the first character of selection in source text.
      Returns:
      A path that contains a set of rectangles covering the specified selection range.
      Throws:
      IllegalArgumentException - if charStart is less than frame start, or charEnd is greater than frame end, or charStart is greater than charEnd.
    • draw

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

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