public final class StyledString extends Object implements Serializable
| Constructor and Description |
|---|
StyledString(Graphics2D g2d,
String startText)
This is assumed to be a single line of text (i.e.
|
StyledString(Graphics2D g2d,
String startText,
int lineWidth)
Supports multiple lines of text wrapped on word boundaries.
|
StyledString(String startText)
This is assumed to be a single line of text (i.e.
|
StyledString(String startText,
int wrapWidth)
Supports multiple lines of text wrapped on word boundaries.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(AttributedCharacterIterator.Attribute type,
Object value)
Add an attribute that affects the whole length of the string.
|
void |
addAttribute(AttributedCharacterIterator.Attribute type,
Object value,
int charStart,
int charEnd)
Set charStart and charEnd to <0 if full length.
|
guicomponents.StyledString.TextLayoutHitInfo |
calculateFromXY(Graphics2D g2d,
float px,
float py) |
void |
clearAllAttributes() |
boolean |
deleteCharacters(int fromPos,
int nbrToRemove)
Remove a number of characters from the string
|
LinkedList<guicomponents.StyledString.TextLayoutInfo> |
getLines(Graphics2D g2d)
Get the text layouts for display if the string has changed since last call
to this method regenerate them.
|
float |
getMaxLineHeight()
Get the height of the tallest line
|
float |
getMaxLineLength()
Return the length of the longest line.
|
int |
getNbrLines()
Return the number of lines in the layout
|
String |
getPlainText()
Get the plain text as a STring.
|
float |
getTextAreaHeight()
Return the height of the text line(s)
|
guicomponents.StyledString.TextLayoutInfo |
getTLIforLineNo(int ln)
Get a layout based on line number
|
float |
getWrapWidth()
Get the break width used to create the lines.
|
boolean |
insertCharacters(int insertPos,
String chars) |
int |
length()
Get the number of characters in this styled string
|
static StyledString |
load(PApplet papp,
String fname) |
static void |
save(PApplet papp,
StyledString ss,
String fname)
Save the named StyleString in the named file.
|
void |
setFont(Font a_font) |
void |
setJustify(boolean justify)
Text can be either left or fully justified.
|
void |
setJustifyRatio(float jRatio)
Justify only if the line has sufficient text to do so.
|
public StyledString(String startText)
startText - public StyledString(Graphics2D g2d, String startText)
g2d - startText - public StyledString(String startText, int wrapWidth)
startText - wrapWidth - the maximum size after which the text ispublic StyledString(Graphics2D g2d, String startText, int lineWidth)
g2d - startText - lineWidth - public String getPlainText()
public int length()
public void setJustify(boolean justify)
justify - true for full justificationpublic void setJustifyRatio(float jRatio)
jRatio - ratio of text length to visibleWidthpublic void addAttribute(AttributedCharacterIterator.Attribute type, Object value, int charStart, int charEnd)
type - value - charStart - charEnd - public void addAttribute(AttributedCharacterIterator.Attribute type, Object value)
type - attribute typevalue - attribute valuepublic boolean insertCharacters(int insertPos,
String chars)
chars - insertPos - the position in the textpublic void clearAllAttributes()
public boolean deleteCharacters(int fromPos,
int nbrToRemove)
nbrToRemove - number of characters to removefromPos - start location for removalpublic void setFont(Font a_font)
public LinkedList<guicomponents.StyledString.TextLayoutInfo> getLines(Graphics2D g2d)
g2d - Graphics2D display contextpublic int getNbrLines()
public float getTextAreaHeight()
public float getMaxLineLength()
public float getMaxLineHeight()
public float getWrapWidth()
public guicomponents.StyledString.TextLayoutHitInfo calculateFromXY(Graphics2D g2d, float px, float py)
public guicomponents.StyledString.TextLayoutInfo getTLIforLineNo(int ln)
ln - public static void save(PApplet papp, StyledString ss, String fname)
papp - ss - the styled stringfname - public static StyledString load(PApplet papp, String fname)
Processing library guicomponents by Peter Lager. (C) 2012