Package snap.text

Class TextBoxLine

java.lang.Object
snap.text.TextBoxLine
All Implemented Interfaces:
CharSequence, CharSequenceX

public class TextBoxLine extends Object implements CharSequenceX
A class to represent a line of text in a TextBox.
  • Field Details

    • _textBox

      protected TextBox _textBox
    • _startStyle

      protected TextStyle _startStyle
    • _index

      protected int _index
    • _startCharIndex

      protected int _startCharIndex
    • _length

      protected int _length
    • _textLine

      protected TextLine _textLine
    • _textLineStart

      protected int _textLineStart
    • _yloc

      protected double _yloc
    • _width

      protected double _width
    • _height

      protected double _height
    • _widthAll

      protected double _widthAll
    • _alignX

      protected double _alignX
    • _tokens

      protected List<TextBoxToken> _tokens
    • _ascent

      protected double _ascent
    • _descent

      protected double _descent
    • _leading

      protected double _leading
    • _lineAdvance

      protected double _lineAdvance
    • _runs

      protected List<TextBoxRun> _runs
  • Constructor Details

    • TextBoxLine

      public TextBoxLine(TextBox aBox, TextStyle aStartStyle, TextLine aTextLine, int theRTLStart)
      Creates a new TextBoxLine.
  • Method Details

    • getBox

      public TextBox getBox()
      Returns the TextBox.
    • getStartStyle

      public TextStyle getStartStyle()
      Returns the TextStyle at start of line.
    • getIndex

      public int getIndex()
      Returns the index of this line in text.
    • getStartCharIndex

      public int getStartCharIndex()
      Returns the start char index of this line in text.
    • getEndCharIndex

      public int getEndCharIndex()
      Returns the end char index of this line in text.
    • length

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

      public String getString()
      Returns the string for the line.
    • 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 subsequence of this sequence.
      Specified by:
      subSequence in interface CharSequence
    • getTextLine

      public TextLine getTextLine()
      Returns the TextLine.
    • getTextLineStart

      public int getTextLineStart()
      Returns the start of this line in TextLine.
    • getLineStyle

      public TextLineStyle getLineStyle()
      Returns the line style.
    • getX

      public double getX()
      Returns the line x.
    • getY

      public double getY()
      Returns the line y.
    • getYLocal

      public double getYLocal()
      Returns the line y.
    • getBaseline

      public double getBaseline()
      Returns the y position for this line (in same coords as the layout frame).
    • getWidth

      public double getWidth()
      Returns the width.
    • getHeight

      public double getHeight()
      Returns the height.
    • getMaxX

      public double getMaxX()
      Returns the max X.
    • getMaxY

      public double getMaxY()
      Returns the max Y.
    • getWidthAll

      public double getWidthAll()
      Returns the width including trailing whitespace.
    • getMaxXAll

      public double getMaxXAll()
      Returns the max x including trailing whitespace.
    • getWidthNoWhiteSpace

      public double getWidthNoWhiteSpace()
      Returns the width without whitespace.
    • resetSizes

      public void resetSizes()
      Validates this line.
    • getTokenCount

      public int getTokenCount()
      Returns the number of tokens.
    • getToken

      public TextBoxToken getToken(int anIndex)
      Returns the individual token at given index.
    • getTokens

      public List<TextBoxToken> getTokens()
      Returns the tokens for this line.
    • addToken

      public void addToken(TextBoxToken aToken)
      Adds a token to line.
    • getTokenLast

      public TextBoxToken getTokenLast()
      Returns the last token for this line.
    • getAscent

      public double getAscent()
      Returns the max ascent of the chars in this line.
    • getDescent

      public double getDescent()
      Returns the max descent of the chars in this line.
    • getLeading

      public double getLeading()
      Returns the leading of the chars in this line.
    • getLineAdvance

      public double getLineAdvance()
      Returns the vertical distance for any line below this line.
    • getTokenForCharIndex

      public TextBoxToken getTokenForCharIndex(int anIndex)
      Returns the token at character index.
    • getTokenForX

      public TextBoxToken getTokenForX(double anX)
      Returns the token at index.
    • getCharIndexForX

      public int getCharIndexForX(double anX)
      Returns the character index for the given x/y point.
    • getXForCharIndex

      public double getXForCharIndex(int anIndex)
      Returns the X coord for given char index.
    • getNext

      public TextBoxLine getNext()
      Returns the next line, if available.
    • getPrevious

      public TextBoxLine getPrevious()
      Returns the previous line if available.
    • getUnderlineStroke

      public double getUnderlineStroke()
      Returns the max stroke width of any underlined chars in this line.
    • getUnderlineY

      public double getUnderlineY()
      Returns the Y position of any underlined chars in this line.
    • getRuns

      public List<TextBoxRun> getRuns()
      Returns an array of runs for the line.
    • createRun

      protected TextBoxRun createRun(int aStart)
      Creates the TextBoxRun at given char index in line.
    • getRun

      public TextBoxRun getRun()
      Returns the first TextBox run for the line.
    • getRunLast

      public TextBoxRun getRunLast()
      Returns the last TextBox run for the line.
    • isHyphenated

      public boolean isHyphenated()
      Returns whether line ends with hyphen.
    • toString

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