Package snap.text
Class TextBoxLine
java.lang.Object
snap.text.TextBoxLine
- All Implemented Interfaces:
CharSequence
,CharSequenceX
A class to represent a line of text in a TextBox.
-
Field Summary
Modifier and TypeFieldDescriptionprotected double
protected double
protected double
protected double
protected int
protected double
protected int
protected double
protected List<TextBoxRun>
protected int
protected TextStyle
protected TextBox
protected TextLine
protected int
protected List<TextBoxToken>
protected double
protected double
protected double
-
Constructor Summary
ConstructorDescriptionTextBoxLine
(TextBox aBox, TextStyle aStartStyle, TextLine aTextLine, int theRTLStart) Creates a new TextBoxLine. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToken
(TextBoxToken aToken) Adds a token to line.char
charAt
(int anIndex) Returns the char value at the specified index.protected TextBoxRun
createRun
(int aStart) Creates the TextBoxRun at given char index in line.double
Returns the max ascent of the chars in this line.double
Returns the y position for this line (in same coords as the layout frame).getBox()
Returns the TextBox.int
getCharIndexForX
(double anX) Returns the character index for the given x/y point.double
Returns the max descent of the chars in this line.int
Returns the end char index of this line in text.double
Returns the height.int
getIndex()
Returns the index of this line in text.double
Returns the leading of the chars in this line.double
Returns the vertical distance for any line below this line.Returns the line style.double
getMaxX()
Returns the max X.double
Returns the max x including trailing whitespace.double
getMaxY()
Returns the max Y.getNext()
Returns the next line, if available.Returns the previous line if available.getRun()
Returns the first TextBox run for the line.Returns the last TextBox run for the line.getRuns()
Returns an array of runs for the line.int
Returns the start char index of this line in text.Returns the TextStyle at start of line.Returns the string for the line.Returns the TextLine.int
Returns the start of this line in TextLine.getToken
(int anIndex) Returns the individual token at given index.int
Returns the number of tokens.getTokenForCharIndex
(int anIndex) Returns the token at character index.getTokenForX
(double anX) Returns the token at index.Returns the last token for this line.Returns the tokens for this line.double
Returns the max stroke width of any underlined chars in this line.double
Returns the Y position of any underlined chars in this line.double
getWidth()
Returns the width.double
Returns the width including trailing whitespace.double
Returns the width without whitespace.double
getX()
Returns the line x.double
getXForCharIndex
(int anIndex) Returns the X coord for given char index.double
getY()
Returns the line y.double
Returns the line y.boolean
Returns whether line ends with hyphen.int
length()
Returns the length of this text line.void
Validates this line.subSequence
(int aStart, int anEnd) Returns a new char sequence that is a subsequence of this sequence.toString()
Standard toString implementation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
Methods inherited from interface snap.util.CharSequenceX
getIndentLength, getIndentString, getLastChar, indexAfterNewline, indexOfNewline, isAfterLineEnd, isLastCharNewline, isLineEnd, isLineEndChar, isWhiteSpace, lastIndexAfterNewline, lastIndexOfNewline, startsWith
-
Field Details
-
_textBox
-
_startStyle
-
_index
protected int _index -
_startCharIndex
protected int _startCharIndex -
_length
protected int _length -
_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
-
_ascent
protected double _ascent -
_descent
protected double _descent -
_leading
protected double _leading -
_lineAdvance
protected double _lineAdvance -
_runs
-
-
Constructor Details
-
TextBoxLine
Creates a new TextBoxLine.
-
-
Method Details
-
getBox
Returns the TextBox. -
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 interfaceCharSequence
-
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 interfaceCharSequence
-
subSequence
Returns a new char sequence that is a subsequence of this sequence.- Specified by:
subSequence
in interfaceCharSequence
-
getTextLine
Returns the TextLine. -
getTextLineStart
public int getTextLineStart()Returns the start of this line in TextLine. -
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
Returns the individual token at given index. -
getTokens
Returns the tokens for this line. -
addToken
Adds a token to line. -
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
Returns the token at character index. -
getTokenForX
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
Returns the next line, if available. -
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
Returns an array of runs for the line. -
createRun
Creates the TextBoxRun at given char index in line. -
getRun
Returns the first TextBox run for the line. -
getRunLast
Returns the last TextBox run for the line. -
isHyphenated
public boolean isHyphenated()Returns whether line ends with hyphen. -
toString
Standard toString implementation.- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-