formatter
Class FontState

java.lang.Object
  extended by formatter.FontState

public class FontState
extends java.lang.Object

This class is meant to keep track of what the HTML tags of an HTML document have altered the state of the text into. In other words, this class makes it trivial to keep track of what the HTML tags have commanded the browser to do. This is useful in this program because it allows for an easy way of keeping track of what to put in new message parts.


Field Summary
static int MAX_DEPTH
          Maximum number of consecutive calls to set methods this object can keep track of before overflowing.
 
Constructor Summary
FontState()
          Creates a new FontState with all the default values in place.
FontState(int defaultSize, java.lang.String defaultTypeface, java.awt.Color defaultColor)
          Creates a new FontState with the passed two default values.
 
Method Summary
 java.awt.Color getBGColor()
          Get the current background color.
 java.awt.Color getFontColor()
          Get the current font color.
 java.lang.String getFontFace()
          Get the current font face.
 int getFontSize()
          Get the current font size.
 boolean isBold()
          Determines if text has been set to bold.
 boolean isItalicized()
          Determines if text has been set to italized.
 boolean isUnderlined()
          Determines if text has been set to underlined.
 void popBGColor()
          Removes the top-most background color from the stack.
 void popFont()
          Removes the top-most font from the stack.
 void pushBGColor(java.awt.Color c)
          Puts another background color on the stack.
 void pushFont(int s, java.lang.String f, java.awt.Color c)
          Puts another font on the stack of fonts.
 void setBold()
          Register that another <b> or <em> tag has been seen.
 void setItalicized()
          Register that another <i> tag has been seen.
 void setNotBold()
          Register that another </b> or </em>tag has been seen.
 void setNotItalicized()
          Register that another </i> tag has been seen.
 void setNotUnderlined()
          Register that another </u> tag has been seen.
 void setUnderlined()
          Register that another <u> tag has been seen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DEPTH

public static int MAX_DEPTH
Maximum number of consecutive calls to set methods this object can keep track of before overflowing. Currently 10.

Constructor Detail

FontState

public FontState()
Creates a new FontState with all the default values in place.


FontState

public FontState(int defaultSize,
                 java.lang.String defaultTypeface,
                 java.awt.Color defaultColor)
Creates a new FontState with the passed two default values.

Parameters:
defaultSize - The default (starting) size.
defaultTypeface - The default (starting) typeface.
defaultColor - The default (starting) color.
Method Detail

setBold

public void setBold()
Register that another <b> or <em> tag has been seen.


setNotBold

public void setNotBold()
Register that another </b> or </em>tag has been seen.


isBold

public boolean isBold()
Determines if text has been set to bold.


setItalicized

public void setItalicized()
Register that another <i> tag has been seen.


setNotItalicized

public void setNotItalicized()
Register that another </i> tag has been seen.


isItalicized

public boolean isItalicized()
Determines if text has been set to italized.


setUnderlined

public void setUnderlined()
Register that another <u> tag has been seen.


setNotUnderlined

public void setNotUnderlined()
Register that another </u> tag has been seen.


isUnderlined

public boolean isUnderlined()
Determines if text has been set to underlined.


pushFont

public void pushFont(int s,
                     java.lang.String f,
                     java.awt.Color c)
Puts another font on the stack of fonts.

Parameters:
s - The new font size. -1 means "use last"
f - The new font face. null means "use last"
c - The new font color. null means "use last"
Throws:
java.lang.RuntimeException - if too man different font changes have been pushed.

popFont

public void popFont()
Removes the top-most font from the stack.

Throws:
java.lang.RuntimeException - if the stack is empty (there are no font sizes to pop).

pushBGColor

public void pushBGColor(java.awt.Color c)
Puts another background color on the stack.

Parameters:
c - The color to add to the stack.
Throws:
java.lang.RuntimeException - if the stack gets full.

popBGColor

public void popBGColor()
Removes the top-most background color from the stack.

Throws:
java.lang.RuntimeException - if the stack is empty.

getFontSize

public int getFontSize()
Get the current font size.

Returns:
The current font size.

getFontFace

public java.lang.String getFontFace()
Get the current font face.

Returns:
The name of the current font face.

getFontColor

public java.awt.Color getFontColor()
Get the current font color.

Returns:
The current font color.

getBGColor

public java.awt.Color getBGColor()
Get the current background color.

Returns:
the current background color.