edu.princeton.swing.text
Class HighlightStyle

java.lang.Object
  extended by edu.princeton.swing.text.HighlightStyle

public class HighlightStyle
extends Object

HighlightStyle encapsulates the stylistic variations which different highlights in a THighlightedTextArea may take. This class is immutable.


Field Summary
static HighlightStyle DEFAULT_STYLE
          The plain black style.
static char[] HEX_DIGITS
          An array to convert an integer between 0 and 16 to a hexidecimal digit.
 
Constructor Summary
HighlightStyle(Color color, boolean bold, boolean italic)
          Instantiates a new HighlightStyle.
 
Method Summary
 boolean equals(Object obj)
          Returns true if two HighlightStyles are identical.
 Color getColor()
          Returns the color which the highlighted text should take.
 int getStyleMask()
          Returns the style mask which can be sent straight to the constructor of Font.
static int hexDigitToInt(char c)
          Returns the hexidecimal value of a character.
 boolean isBold()
          Returns wheter or not the highlighted text should be bold.
static boolean isHexDigit(char c)
          Returns whether or not a character is a hexidecimal digit.
 boolean isItalic()
          Returns wheter or not the highlighted text should be italicized.
static HighlightStyle parseStyle(String string)
          Decodes the string produced by toString() back into a HighlightStyle.
 String toString()
          Encodes the HighlightStyle in a format that can be read by parseStyle().
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEX_DIGITS

public static final char[] HEX_DIGITS
An array to convert an integer between 0 and 16 to a hexidecimal digit.


DEFAULT_STYLE

public static final HighlightStyle DEFAULT_STYLE
The plain black style.

Constructor Detail

HighlightStyle

public HighlightStyle(Color color,
                      boolean bold,
                      boolean italic)
Instantiates a new HighlightStyle.

Method Detail

getColor

public Color getColor()
Returns the color which the highlighted text should take.

Returns:
The color which the highlighted text should take.

isBold

public boolean isBold()
Returns wheter or not the highlighted text should be bold.

Returns:
True iff the highlighted text should be bold.

isItalic

public boolean isItalic()
Returns wheter or not the highlighted text should be italicized.

Returns:
True iff the highlighted text should be italicized.

getStyleMask

public int getStyleMask()
Returns the style mask which can be sent straight to the constructor of Font.

Returns:
The style mask which can be used in the constructor of Font.

equals

public boolean equals(Object obj)
Returns true if two HighlightStyles are identical.

Overrides:
equals in class Object
Parameters:
obj - The object to compare this HighlightStyle with.
Returns:
True iff obj is a HighlightStyle and if the fields are equal.

toString

public String toString()
Encodes the HighlightStyle in a format that can be read by parseStyle().

Overrides:
toString in class Object
Returns:
A string which can be read by parseStyle().

parseStyle

public static HighlightStyle parseStyle(String string)
Decodes the string produced by toString() back into a HighlightStyle. If the string could not be parsed, null is returned.

Parameters:
string - The string to parse. A null value will result in a NullPointerException.
Returns:
The parsed HighlightStyle. Null is returned if the string was unparseable.

isHexDigit

public static boolean isHexDigit(char c)
Returns whether or not a character is a hexidecimal digit. This test is case-insensitive.

Parameters:
c - The character to test.
Returns:
True iff the c is a hexidecimal digit.

hexDigitToInt

public static int hexDigitToInt(char c)
Returns the hexidecimal value of a character. This function is case-insensitive.

Parameters:
c - The character to convert. If this character is not a hex digit, an IllegalArgumentException will be thrown.
Returns:
The value c interpreted as a hexidecimal digit.