public class Text extends TextRect implements TextTypes, java.lang.CharSequence, java.lang.Cloneable
TextTypes.TabType
RMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
TEXT_CHAR_SPACING, TEXT_COLOR, TEXT_FONT, TEXT_FORMAT, TEXT_LINK, TEXT_OUTLINE, TEXT_SCRIPTING, TEXT_UNDERLINE
Constructor and Description |
---|
Text()
Creates a new text.
|
Text(java.lang.CharSequence theChars)
Creates a Text initialized with the given String and no attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addChars(java.lang.CharSequence theChars,
TextStyle theStyle,
int anIndex)
Adds characters with attributes to this text at given index.
|
protected TextLine |
addLine(int anIndex)
Adds a line at given index.
|
void |
addLine(TextLine aLine,
int anIndex)
Adds a line at given index.
|
char |
charAt(int anIndex)
Returns the char value at the specified index.
|
Text |
clone()
Standard clone implementation.
|
protected double |
computePrefHeight()
Returns the preferred height.
|
protected double |
computePrefWidth()
Compute the preferred width.
|
protected TextLine |
createLine()
Creates a new line for use in this text.
|
int |
getCharIndex(double anX,
double aY)
Returns the character index for the given x/y point.
|
SnapColor |
getColor()
Returns the color for this line.
|
java.lang.Object |
getDefaultAttribute(java.lang.Object aKey)
Returns the default for a given key.
|
SnapColor |
getDefaultColor()
Returns the default color for this string.
|
SnapFont |
getDefaultFont()
Returns the default font for this string.
|
SnapFont |
getFont()
Returns the font for this line.
|
double |
getFontScale()
Returns the font scale of the text layout.
|
TextLine |
getLine(int anIndex)
Returns the individual text line in this text.
|
TextLine |
getLineAt(int anIndex)
Returns the TextLine at the given char index.
|
int |
getLineCount()
Returns the number of lines in this text.
|
TextLine |
getLineFor(int anIndex)
Returns the TextLine at the given char index or the last line if at end.
|
TextLine |
getLineForY(double aY)
Returns the line for the given y value.
|
TextLine |
getLineLast()
Returns the last line.
|
TextLine |
getLineLongest()
Returns the longest line.
|
java.util.List<TextLine> |
getLines()
Returns the list of lines.
|
double |
getPrefHeight()
Returns the preferred height.
|
double |
getPrefWidth()
Returns the preferred width.
|
TextRun |
getRunAt(int anIndex)
Returns the TextRun that contains the given index.
|
TextRun |
getRunFor(int anIndex)
Returns the TextRun that contains the given index or the last line last run if at end.
|
WebFile |
getSourceFile()
Returns the source file.
|
WebURL |
getSourceURL()
Returns the source URL.
|
java.lang.String |
getString()
Returns the string for the text.
|
TextStyle |
getStyleAt(int anIndex)
Returns the TextStyle for the run at the given character index.
|
TextToken |
getTokenAt(int anIndex)
Returns the token at given index.
|
boolean |
getUseFractionalMetrics()
Returns whether to use fractional character metrics.
|
void |
invalidate()
Invalidates text.
|
boolean |
isMonofont()
Whether this text only allows a single font, color, etc.
|
boolean |
isPropertyChangeEnabled()
Returns whether property change is enabled.
|
int |
length()
Returns the number of characters in the text.
|
void |
removeChars(int aStart,
int anEnd)
Removes characters in given range.
|
TextLine |
removeLine(int anIndex)
Removes the line at given index.
|
int |
removeLine(TextLine aLine)
Removes the given line.
|
void |
replaceChars(java.lang.CharSequence theChars,
TextStyle theStyle,
int aStart,
int anEnd)
Replaces chars in given range, with given String, using the given attributes.
|
protected void |
sendPropertyChange(java.beans.PropertyChangeEvent anEvent)
Implement so package can use protected method.
|
void |
setAttribute(java.lang.String aKey,
java.lang.Object aValue,
int aStart,
int anEnd)
Sets a given attribute to a given value for a given range.
|
void |
setColor(SnapColor aColor)
Sets the color for this line.
|
void |
setFont(SnapFont aFont)
Sets the font for this line.
|
void |
setFontScale(double aValue)
Sets the font scale of the text layout.
|
void |
setMonofont(boolean aValue)
Sets whether this text only allows a single font, color, etc.
|
void |
setPropertyChangeEnabled(boolean aValue)
Sets whether property change is enabled.
|
void |
setSource(java.lang.Object aSource)
Loads the text from the given source.
|
void |
setSourceURL(WebURL aURL)
Sets the source URL.
|
void |
setString(java.lang.String aString)
Sets the text to the given string.
|
void |
setUseFractionalMetrics(boolean aFlag)
Sets whether to use fractional character metrics.
|
java.lang.CharSequence |
subSequence(int aStart,
int anEnd)
Returns a new char sequence that is a subsequence of this sequence.
|
java.lang.String |
toString()
Standard toString implementation.
|
protected void |
updateLines(int anIndex)
Updates lines from index.
|
getHeight, getMaxX, getMaxY, getWidth, getX, getY, setHeight, setRect, setSize, setWidth, setX, setY
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener
addListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
public Text()
public Text(java.lang.CharSequence theChars)
public void setSource(java.lang.Object aSource)
public WebURL getSourceURL()
public void setSourceURL(WebURL aURL)
public WebFile getSourceFile()
public int length()
length
in interface java.lang.CharSequence
public char charAt(int anIndex)
charAt
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int aStart, int anEnd)
subSequence
in interface java.lang.CharSequence
public java.lang.String getString()
public void setString(java.lang.String aString)
public SnapFont getFont()
public void setFont(SnapFont aFont)
public SnapFont getDefaultFont()
public double getFontScale()
public void setFontScale(double aValue)
public boolean getUseFractionalMetrics()
public void setUseFractionalMetrics(boolean aFlag)
public SnapColor getColor()
public void setColor(SnapColor aColor)
public SnapColor getDefaultColor()
public java.lang.Object getDefaultAttribute(java.lang.Object aKey)
public boolean isMonofont()
public void setMonofont(boolean aValue)
public void addChars(java.lang.CharSequence theChars, TextStyle theStyle, int anIndex)
public void removeChars(int aStart, int anEnd)
public void replaceChars(java.lang.CharSequence theChars, TextStyle theStyle, int aStart, int anEnd)
public void setAttribute(java.lang.String aKey, java.lang.Object aValue, int aStart, int anEnd)
public int getLineCount()
public TextLine getLine(int anIndex)
public java.util.List<TextLine> getLines()
protected TextLine createLine()
protected TextLine addLine(int anIndex)
public void addLine(TextLine aLine, int anIndex)
public TextLine removeLine(int anIndex)
public int removeLine(TextLine aLine)
protected void updateLines(int anIndex)
public TextLine getLineAt(int anIndex)
public TextLine getLineFor(int anIndex)
public TextLine getLineLast()
public TextLine getLineLongest()
public TextToken getTokenAt(int anIndex)
public TextRun getRunAt(int anIndex)
public TextRun getRunFor(int anIndex)
public TextStyle getStyleAt(int anIndex)
public TextLine getLineForY(double aY)
public int getCharIndex(double anX, double aY)
public void invalidate()
public double getPrefWidth()
public double getPrefHeight()
protected double computePrefWidth()
protected double computePrefHeight()
public boolean isPropertyChangeEnabled()
public void setPropertyChangeEnabled(boolean aValue)
protected void sendPropertyChange(java.beans.PropertyChangeEvent anEvent)
sendPropertyChange
in class RMObject
public Text clone()
clone
in class RMListenerList