|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.rolemodelsoft.drawlet.util.BasicStringRenderer
|
+--com.rolemodelsoft.drawlet.util.BasicStringComposer
This provides basic default functionality for StringRenderers that provide wrapping. The first version doesn't handle all possibilities, but works for most purposes. NOTE: it is possible that individual line widths could be greater than the maxWidth as widths include calculation of ending whitespace in case someone wants to do something with them. However, no non-END_ABSORB characters should show up past the maxWidth.
| Field Summary | |
protected int |
goodWidth
This keeps track of the last known x coordinate that we know to to be good (i.e. |
protected int |
maxHeight
The maximum height to compose. |
protected int |
maxWidth
The maximum width to allow non-END_ABSORBing (whitespace) characters before wrapping. |
| Fields inherited from class com.rolemodelsoft.drawlet.util.BasicStringRenderer |
ALL_VERTICAL,
begin,
begins,
end,
ends,
height,
last,
manuals,
metrics,
next,
NO_INDEX,
specials,
startX,
startY,
string,
width,
widths |
| Constructor Summary | |
BasicStringComposer(java.lang.String string)
Answer an instance prepared to render a String. |
|
BasicStringComposer(java.lang.String string,
java.awt.Font font)
Answer an instance prepared to render a string using a particular font |
|
BasicStringComposer(java.lang.String string,
java.awt.Font font,
int maxWidth)
Answer an instance prepared to render a string using a particular font, wrapping after a given width. |
|
BasicStringComposer(java.lang.String string,
java.awt.Font font,
int maxWidth,
int maxHeight)
Answer an instance prepared to render a string using a particular font, wrapping after a given width, and ignoring text past a given height. |
|
BasicStringComposer(java.lang.String string,
int maxWidth)
Answer an instance prepared to render a string, wrapping after a given width. |
|
BasicStringComposer(java.lang.String string,
int maxWidth,
int maxHeight)
Answer an instance prepared to render a string, wrapping after a given width, and ignoring text past a given height. |
|
| Method Summary | |
protected void |
addLine()
Record the current settings as the end of a line. |
protected void |
beginNextLine()
Set up to compose the next line. |
protected void |
closeLastLine()
Make the last/pending line into a "real one". |
protected void |
compose()
Compose the text in such a way as to produce all lines necessary to display text properly. |
protected void |
compose(int yBegin,
int yEnd)
Compose the text in such a way as to produce the lines necessary to display text between the given vertical coordinates. |
protected void |
composeVerticalArea(int yBegin,
int yEnd)
Compose the text in such a way as to produce the lines necessary to display text between the given vertical coordinates. |
protected int |
defaultMaxHeight()
Answer the default/initial value for maxHeight. |
protected int |
defaultMaxWidth()
Answer the default/initial value for maxWidth. |
protected int[] |
defaultSpecials()
Answer the default/initial value for the array where characters can be marked as special. |
protected boolean |
handleSpecial(java.lang.String string,
int index)
Handles the special character at index during composition. |
protected boolean |
isFullyComposed()
Answer whether the string has been fully composed. |
void |
paint(java.awt.Graphics g)
Paints the string. |
java.lang.String |
toString()
Returns the String representation of the receiver's values. |
| Methods inherited from class com.rolemodelsoft.drawlet.util.BasicStringRenderer |
absorbEnd,
adjustWidthForSpecial,
areAllAbsorbed,
compose,
composeAll,
composeIfNecessary,
defaultFont,
defaultMetrics,
defaultStartX,
defaultStartY,
getBaseline,
getFont,
getLineHeight,
getMetrics,
getRawStringLines,
getSpecialFlags,
getSpecialFlags,
getString,
getStringHeight,
getStringLines,
getStringWidth,
handleManually,
indexOfSpecial,
newLine,
nextTabStop,
paint,
paintSpecial,
paintTextBetween,
reset,
scanToSpecial,
setFont,
setString,
verifyMetrics |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
protected int maxWidth
protected int maxHeight
protected int goodWidth
| Constructor Detail |
public BasicStringComposer(java.lang.String string)
string - the string to render
public BasicStringComposer(java.lang.String string,
int maxWidth)
string - the string to rendermaxWidth - the width at which to wrap text to a new line
public BasicStringComposer(java.lang.String string,
int maxWidth,
int maxHeight)
string - the string to rendermaxWidth - the width at which to wrap text to a new linemaxHeight - the height at which to ignore other text
public BasicStringComposer(java.lang.String string,
java.awt.Font font)
string - the string to renderfont - the font to use when rendering
public BasicStringComposer(java.lang.String string,
java.awt.Font font,
int maxWidth)
string - the string to renderfont - the font to use when renderingmaxWidth - the width at which to wrap text to a new line
public BasicStringComposer(java.lang.String string,
java.awt.Font font,
int maxWidth,
int maxHeight)
string - the string to renderfont - the font to use when renderingmaxWidth - the width at which to wrap text to a new linemaxHeight - the height at which to ignore other text| Method Detail |
protected void addLine()
beginNextLineprotected void beginNextLine()
addLine()protected void closeLastLine()
protected void compose()
protected void compose(int yBegin,
int yEnd)
yBegin - the vertical point at which we need to begin composing.yEnd - the vertical point at which we'll stop composing.
protected void composeVerticalArea(int yBegin,
int yEnd)
yBegin - the vertical point at which we need to begin composing.yEnd - the vertical point at which we'll stop composing.protected int defaultMaxHeight()
protected int defaultMaxWidth()
protected int[] defaultSpecials()
protected boolean handleSpecial(java.lang.String string,
int index)
string - the string in which to find the special characterindex - index of special characterprotected boolean isFullyComposed()
public void paint(java.awt.Graphics g)
g - the specified Graphics window.public java.lang.String toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||