com.rolemodelsoft.drawlet.util
Interface StringRenderer

All Known Implementing Classes:
BasicStringRenderer

public interface StringRenderer

This interface defines a generic interface for objects that can measure and display strings. It is expected that implementers will determine what to do with special characters, wrapping, etc. This should be used when wanting a bit more intelligence than FontMetrics.stringWidth() and Graphics.drawString() offer. In addition to some basic protocols, a variety of flags are offered which may somehow be associated with special characters to give implementers help in determining what to do when those characters are discovered and offer implementers the opportunity to avoid hard coding based on particular characters in a "standard" way.


Field Summary
static int BREAK
          Encourage new lines if later non-special characters would otherwise end up past some maximum x coordinate.
static int BREAK_AFTER
          Encourage new lines after these characters if later non-special characters would otherwise end up past some maximum x coordinate.
static int BREAK_BEFORE
          Encourage new lines before these characters if later non-special characters would otherwise end up past some maximum x coordinate.
static int END_ABSORB
          Ignore (with respect to wrapping) these characters at the end of lines and avoid using them at the beginning of a line unless preceded by a NEW_LINE.
static int END_DELAY
          These characters force some vertical movement.
static int NEW_LINE
          These characters force the character which immediately follows them to appear on a new line.
static int NO_FONT
          These characters are not displayed based on what the font says, but rather some sort of special handling.
static int VERTICAL
          These characters force some vertical movement.
static int VERTICAL_MOVE
          These characters force some manual vertical movement more complicated than a simple NEW_LINE.
 
Method Summary
 java.awt.Font getFont()
          Answer the font the receiver is using.
 java.lang.String[] getRawStringLines()
          Answers an array of the substrings, one for each line.
 java.lang.String getString()
          Answer the String the receiver is associated with.
 int getStringHeight()
          Answer the height of the composed string.
 java.lang.String[] getStringLines()
          Answers an array of the substrings, one for each line.
 int getStringWidth()
          Answer the width of the composed string.
 void paint(java.awt.Graphics g)
          Paints the string.
 void paint(java.awt.Graphics g, int x, int y)
          Paints the string starting at the top left specified.
 void setFont(java.awt.Font font)
          Set the receiver up to compose and display based on the given font.
 void setString(java.lang.String newString)
          Set the receiver up to display the string.
 

Field Detail

BREAK_AFTER

public static final int BREAK_AFTER
Encourage new lines after these characters if later non-special characters would otherwise end up past some maximum x coordinate.

BREAK_BEFORE

public static final int BREAK_BEFORE
Encourage new lines before these characters if later non-special characters would otherwise end up past some maximum x coordinate.

BREAK

public static final int BREAK
Encourage new lines if later non-special characters would otherwise end up past some maximum x coordinate.

END_ABSORB

public static final int END_ABSORB
Ignore (with respect to wrapping) these characters at the end of lines and avoid using them at the beginning of a line unless preceded by a NEW_LINE.

NO_FONT

public static final int NO_FONT
These characters are not displayed based on what the font says, but rather some sort of special handling.

NEW_LINE

public static final int NEW_LINE
These characters force the character which immediately follows them to appear on a new line.

VERTICAL_MOVE

public static final int VERTICAL_MOVE
These characters force some manual vertical movement more complicated than a simple NEW_LINE.

VERTICAL

public static final int VERTICAL
These characters force some vertical movement.

END_DELAY

public static final int END_DELAY
These characters force some vertical movement.
Method Detail

getFont

public java.awt.Font getFont()
Answer the font the receiver is using.
Returns:
the Font the receiver is using.

getRawStringLines

public java.lang.String[] getRawStringLines()
Answers an array of the substrings, one for each line. Don't strip off any ending white space. NOTE: This will probably be changed to return an Enumeration or Iterator.

getString

public java.lang.String getString()
Answer the String the receiver is associated with.

getStringHeight

public int getStringHeight()
Answer the height of the composed string.

getStringLines

public java.lang.String[] getStringLines()
Answers an array of the substrings, one for each line. NOTE: This will probably be changed to return an Enumeration or Iterator.

getStringWidth

public int getStringWidth()
Answer the width of the composed string.

paint

public void paint(java.awt.Graphics g)
Paints the string.
Parameters:
g - the specified Graphics window.

paint

public void paint(java.awt.Graphics g,
                  int x,
                  int y)
Paints the string starting at the top left specified.
Parameters:
g - the specified Graphics window.
x - the x coordinate to display the leftmost point.
y - the y coordinate to display the topmost point.

setFont

public void setFont(java.awt.Font font)
Set the receiver up to compose and display based on the given font.
Parameters:
font - the font to use as a base.

setString

public void setString(java.lang.String newString)
Set the receiver up to display the string.
Parameters:
string - the string to use as a base.