edu.northwestern.at.wordhoard.tools.cm
Class Style

java.lang.Object
  extended by edu.northwestern.at.wordhoard.tools.cm.Style
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
TextElementRule

public class Style
extends java.lang.Object
implements java.lang.Cloneable

Text formatting style information.

A style object records the following information about line and word text formatting style attributes:

The NO_CHANGE value for these three attributes is used when adding styles. See the description of the add method for details.


Field Summary
static int BOLD
          Bold style mask.
static int CENTER
          Center alignment line style.
static int EXTENDED
          Extended style mask.
static int ITALIC
          Italic style mask.
static int LEFT
          Left alignment line style.
static int MONOSPACED
          Monospaced style mask.
static int NO_CHANGE
          No change in style.
static int OVERLINE
          Overline style mask.
static int PLAIN
          Plain style mask.
static int RIGHT
          Right alignment line style.
static java.lang.String[] STYLE_NAMES
          Array of WordHoard style names, in the order of their style mask bit postions.
static int SUBSCRIPT
          Subscript style mask.
static int SUPERSCRIPT
          Superscript style mask.
static int UNDERLINE
          Underline style mask.
 
Constructor Summary
Style(org.w3c.dom.Element el)
          Creates a style from a parameters XML element.
Style(int lineStyle, int indent, int wordStyles)
          Creates a style.
 
Method Summary
 void add(Style style)
          Adds a style to this style.
 java.lang.Object clone()
          Clones the style.
 int getIndent()
          Gets the indentation.
 int getLineStyle()
          Gets the line style.
 int getWordStyles()
          Gets the word styles.
 void setIndent(int indent)
          Sets the indentation.
 void setLineStyle(int lineStyle)
          Sets the line style.
 void setWordStyles(int wordStyles)
          Sets the word styles.
 boolean styleChange()
          Returns true if the style changes.
 java.lang.String toString()
          Converts the style to a string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_CHANGE

public static final int NO_CHANGE
No change in style.

This constant is used with all kinds of formatting styles - line styles, indentation styles, and word styles.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Left alignment line style.

See Also:
Constant Field Values

CENTER

public static final int CENTER
Center alignment line style.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Right alignment line style.

See Also:
Constant Field Values

BOLD

public static final int BOLD
Bold style mask.

See Also:
Constant Field Values

ITALIC

public static final int ITALIC
Italic style mask.

See Also:
Constant Field Values

EXTENDED

public static final int EXTENDED
Extended style mask.

See Also:
Constant Field Values

UNDERLINE

public static final int UNDERLINE
Underline style mask.

See Also:
Constant Field Values

OVERLINE

public static final int OVERLINE
Overline style mask.

See Also:
Constant Field Values

SUPERSCRIPT

public static final int SUPERSCRIPT
Superscript style mask.

See Also:
Constant Field Values

SUBSCRIPT

public static final int SUBSCRIPT
Subscript style mask.

See Also:
Constant Field Values

MONOSPACED

public static final int MONOSPACED
Monospaced style mask.

See Also:
Constant Field Values

PLAIN

public static final int PLAIN
Plain style mask.

See Also:
Constant Field Values

STYLE_NAMES

public static final java.lang.String[] STYLE_NAMES
Array of WordHoard style names, in the order of their style mask bit postions.

Constructor Detail

Style

public Style(int lineStyle,
             int indent,
             int wordStyles)
Creates a style.

Parameters:
lineStyle - Line style.
indent - Indentation.
wordStyles - Word styles.

Style

public Style(org.w3c.dom.Element el)
Creates a style from a parameters XML element.

Parameters:
el - Element.
Method Detail

getLineStyle

public int getLineStyle()
Gets the line style.

Returns:
The line style.

setLineStyle

public void setLineStyle(int lineStyle)
Sets the line style.

Parameters:
lineStyle - The line style.

getIndent

public int getIndent()
Gets the indentation.

Returns:
Indentation.

setIndent

public void setIndent(int indent)
Sets the indentation.

Parameters:
indent - Indentation.

getWordStyles

public int getWordStyles()
Gets the word styles.

Returns:
Word styles.

setWordStyles

public void setWordStyles(int wordStyles)
Sets the word styles.

Parameters:
wordStyles - Word styles.

add

public void add(Style style)
Adds a style to this style.

If A and B are two styles, A.add(B) is constructed as follows:

If B.lineStyle == NO_CHANGE, the result line style is A.lineStyle, otherwise it is B.lineStyle.

If B.indent == NO_CHANGE, the result indentation is A.indent, otherwise it is A.indent + B.indent. Notice that the indentation is cumulative.

If B.wordStyles == NO_CHANGE, the result word styles is A.wordStyles. If B.wordStyles == PLAIN, the result word styles is PLAIN. Otherwise it is A.wordStyles | B.wordStyles, the logical OR of the two bit masks. Notice that in the last case, word styles, like indentation, are cumulative.

Parameters:
style - The style to add.

styleChange

public boolean styleChange()
Returns true if the style changes.

Returns:
True if the style changes.

clone

public java.lang.Object clone()
Clones the style.

Overrides:
clone in class java.lang.Object
Returns:
Cloned style.

toString

public java.lang.String toString()
Converts the style to a string.

Overrides:
toString in class java.lang.Object
Returns:
Style converted to a string.