|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.toolbox.rebop.AbstractDrawable
com.arsdigita.toolbox.rebop.StyledText
Represents text that contains multiple fonts and colors. A simple word processor could use a single StyledText object for managing its contents.
Field Summary | |
static String |
versionId
|
Constructor Summary | |
StyledText()
|
Method Summary | |
void |
addRun(FormattedText run)
Adds a run of text that uses the same font and color. |
void |
draw(Graphics g,
int x,
int y,
int width,
int height)
GenericDrawable implementation. |
static void |
drawWrappedText(Graphics g,
Font baseFont,
Vector runs,
Dimension size,
int leftMargin,
boolean measureOnly,
Point startPoint,
Dimension preferredDimension,
Vector wrappedRuns)
Draws and/or measures runs of styled text |
FormattedText |
getFormattedTextAt(int index)
|
Dimension |
getPreferredSize(Graphics g,
int width,
int height)
|
Vector |
getWrappedRuns()
|
void |
setBaseFont(Font font)
Sets the default font for all runs that don't specify a font |
void |
setFormattedTextAt(int index,
FormattedText ft)
Replaces an existing run with a new one |
void |
setRunColor(int runIndex,
Color color)
Changes the color of a specific run. |
void |
setWrappedRuns(Vector runs)
if a caller is caching runs after they have been wrapped once, the pre-wrapped runs can be added here. |
String |
toString()
|
Methods inherited from class com.arsdigita.toolbox.rebop.AbstractDrawable |
getXOffset, getYOffset, setXOffset, setYOffset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.arsdigita.toolbox.rebop.GenericDrawable |
getXOffset, getYOffset, setXOffset, setYOffset |
Field Detail |
public static final String versionId
Constructor Detail |
public StyledText()
Method Detail |
public void addRun(FormattedText run)
run
- Font, Color and String specificationpublic void setWrappedRuns(Vector runs)
runs
- Vector of WrappedRun objectspublic Vector getWrappedRuns()
public void draw(Graphics g, int x, int y, int width, int height)
draw
in interface GenericDrawable
g
- Graphics to draw onx
- horizontal location to begin drawingy
- vertical location to begin drawingwidth
- width of area to draw inheight
- height of area to draw inpublic void setBaseFont(Font font)
font
- Font to draw inpublic FormattedText getFormattedTextAt(int index)
index
- index of a specific run to retrieve
public void setFormattedTextAt(int index, FormattedText ft)
index
- index of an existing runft
- FormattedText to add at indexpublic void setRunColor(int runIndex, Color color)
color
- new color for the runpublic String toString()
public Dimension getPreferredSize(Graphics g, int width, int height)
g
- Graphics from which to calculate dimensionswidth
- width within which to calculate wrapped textheight
- height of area for wrapped text
public static void drawWrappedText(Graphics g, Font baseFont, Vector runs, Dimension size, int leftMargin, boolean measureOnly, Point startPoint, Dimension preferredDimension, Vector wrappedRuns)
g
- Graphics context to draw the wrapped text upon.baseFont
- Font to use if none is specified in the runruns
- FormattedText runs to drawsize
- text will be wrapped within the width of this Dimension.
Text will not be drawn below the bottom of this size, but if the
measureOnly flag is set, the max height WILL be calculated.leftMargin
- new lines after the first line will begin at this
horizontal offset in the current coordinate system.startPoint
- The location in the current coordinate system to
begin drawing the first line of textpreferredDimension
- @out if all the text were to be drawn, this
dimension would be required to hold it. Only valid if measureOnly is set.measureOnly
- if true, calculate preferredDimension but do not draw.wrappedRuns
- if non-null but empty, WrappedRuns as used to draw
the StyledText will be returned in this parameter. If non-null AND
non-empty, wrapped runs will be drawn and no further word wrapping or
calculations will be performed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |