Class RMTextLayout

All Implemented Interfaces:
RMTypes, RMTextTypes, Shape, Serializable, CharSequence, Cloneable
Direct Known Subclasses:
RMTextLayoutInPath

public class RMTextLayout extends Rectangle2D.Double implements CharSequence, RMTextTypes
A class to layout text.
See Also:
  • Constructor Details

    • RMTextLayout

      public RMTextLayout()
  • Method Details

    • getXString

      public RMXString getXString()
      Returns the RMXString.
    • setXString

      public void setXString(RMXString anXString)
      Sets the RMXString.
    • getStart

      public int getStart()
      Returns the start char index of the layout in XString.
    • setStart

      public void setStart(int aStart)
      Sets the start char index of the layout in XString.
    • getEnd

      public int getEnd()
      Returns the end char index of the layout in XString.
    • getNeedsLayout

      public boolean getNeedsLayout()
      Returns whether text needs to perform layout.
    • setNeedsLayout

      public void setNeedsLayout(boolean aValue)
      Sets whether text needs to perform layout.
    • layout

      public void layout()
      Performs text layout if needed.
    • layoutText

      protected void layoutText()
      Performs text layout.
    • addChars

      public int addChars(RMXStringRun aRun, int aStart, int anEnd)
      Adds chars to text layout.
    • addChar

      protected void addChar(char aChar)
      Adds a char to the layout.
    • deleteChars

      public void deleteChars(int anIndex)
      Deletes chars from index.
    • length

      public int length()
      Returns the length of this text layout.
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int anIndex)
      Returns the char value at the specified index.
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int aStart, int anEnd)
      Returns a new char sequence that is a sub-sequence of this sequence.
      Specified by:
      subSequence in interface CharSequence
    • getFontScale

      public double getFontScale()
      Returns the font scale of the text layout.
    • setFontScale

      public void setFontScale(double aValue)
      Sets the font scale of the text layout.
    • getUseFractionalMetrics

      public boolean getUseFractionalMetrics()
      Returns whether to use fractional character metrics.
    • setUseFractionalMetrics

      public void setUseFractionalMetrics(boolean aFlag)
      Sets whether to use fractional character metrics.
    • getAlignmentY

      public RMTypes.AlignY getAlignmentY()
      Returns the vertical alignment of this layout.
    • setAlignmentY

      public void setAlignmentY(RMTypes.AlignY anAlignment)
      Sets the vertical alignment of this layout.
    • getWidthToFit

      public double getWidthToFit()
      Returns the width to fit.
    • getHeightToFit

      public double getHeightToFit()
      Returns the height to fit.
    • getLine

      public RMTextLine getLine()
      Returns the head line of line linked list.
    • getLineCount

      public int getLineCount()
      Returns the number of lines.
    • getLine

      public RMTextLine getLine(int anIndex)
      Returns the individual line at given index.
    • getLineLast

      public RMTextLine getLineLast()
      Returns the last line.
    • createLine

      protected RMTextLine createLine()
      Creates a new text line.
    • addLine

      public RMTextLine addLine(RMXStringRun aRun)
      Adds a new line and returns it.
    • removeLine

      public void removeLine()
      Removes a line.
    • getRun

      public RMTextRun getRun()
      Returns the head run in linked list of runs for the layout.
    • getRunCount

      public int getRunCount()
      Returns the number of runs in this line.
    • getRun

      public RMTextRun getRun(int anIndex)
      Returns the text run at the given index.
    • getRunLast

      @Nullable public RMTextRun getRunLast()
      Returns the last run.
    • createRun

      public RMTextRun createRun()
      Creates a new run.
    • addRun

      public RMTextRun addRun(RMXStringRun aRun, @Nonnull RMTextLine aLine)
      Adds a new run.
    • getCharIndex

      public int getCharIndex(Point2D aPoint)
      Returns the character index for the given x/y point.
    • getCharIndex

      public int getCharIndex(double anX, double aY)
      Returns the character index for the given x/y point.
    • getPointForChar

      public Point2D getPointForChar(int anIndex)
      Returns the text origin for the given character index.
    • getLineForChar

      public RMTextLine getLineForChar(int anIndex)
      Returns the line for the given character index.
    • getLineForPointY

      public RMTextLine getLineForPointY(double aY)
      Returns the line for the given y value.
    • getRunForPoint

      public RMTextRun getRunForPoint(double anX, double aY)
      Returns the run for given x/y.
    • getNextLineStartPoint

      public Point2D getNextLineStartPoint(RMXStringRun aRun)
      Returns what this line thinks is the next line's x. Override if not infinity.
    • getIndent

      public double getIndent(RMXStringRun aRun)
      Returns the indent for this line.
    • getWrapped

      public boolean getWrapped()
      Returns whether layout had to wrap a line.
    • getLongWordFound

      public boolean getLongWordFound()
      Returns whether a word was found that over-ran a whole line by itself.
    • getRanOutOfRoom

      public boolean getRanOutOfRoom()
      Returns whether layout ran out of room trying to render chars.
    • getPathForChars

      public GeneralPath getPathForChars(int aStart, int anEnd)
      Returns a path for two char indexes - it will be a a simple box with extensions for first/last lines.
    • pathmoveTo

      protected void pathmoveTo(GeneralPath path, double x, double y)
    • pathlineTo

      protected void pathlineTo(GeneralPath path, double x, double y)
    • isLocked

      public boolean isLocked()
      Returns whether text layout is full.
    • setLocked

      public void setLocked(boolean aFlag)
      Sets whether text layout can add more characters.
    • performAlignmentY

      protected void performAlignmentY()
      Perform vertical alignment - this needs to move to RMTextShape!
    • setAlignHeight

      public void setAlignHeight(double aValue)
      Bogus!
    • layoutToFit

      public void layoutToFit()
      Scales font sizes of all text in an RMText shape to fit in bounds. Caches font scale factor in xstring.
    • toString

      public String toString()
      Standard toString implementation.
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Rectangle2D.Double