org.jfree.workbook
Class Style

java.lang.Object
  |
  +--org.jfree.workbook.Style
All Implemented Interfaces:
StyleConstants

public class Style
extends java.lang.Object
implements StyleConstants

Represents a style that (when incorporated within a StyleRegion object) applies to a range of cells in a worksheet.

This class should be immutable so we can use it in multiple places without risking it being changed.


Field Summary
protected  Color backgroundColor
          The background color.
protected  Border border
          The border details.
protected  int cellIndent
          The indentation for the cells.
protected  FontStyle font
          The font details.
protected  Color foregroundColor
          The foreground color.
protected  java.lang.String format
          The format.
protected  int horizontalAlignment
          The horizontal alignment.
protected  int orientation
          The orientation.
protected  Color patternColor
          The pattern color.
protected  int shade
          The shade.
protected  int verticalAlignment
          The vertical alignment.
protected  boolean wrapText
          Wrap text (true/false).
 
Fields inherited from interface org.jfree.workbook.StyleConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_CENTER_ACROSS_SELECTION, ALIGN_FILL, ALIGN_GENERAL, ALIGN_JUSTIFY_HORIZONTAL, ALIGN_JUSTIFY_VERTICAL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP
 
Constructor Summary
Style()
          Constructs a new Style object with default values.
Style(FontStyle font, Border border, int horizontalAlignment, int verticalAlignment, boolean wrapText, int orientation, int shade, int cellIndent, Color foregroundColor, Color backgroundColor, Color patternColor, java.lang.String format)
          Full constructor.
Style(FontStyle font, int horizontalAlignment, int verticalAlignment)
          Constructs a style with a specific font and alignment.
 
Method Summary
static Style applyBackgroundColor(Style style, Color backgroundColor)
          Creates a new style based on the provided style, but replacing the background color as specified.
static Style applyBorder(Style base, Border border)
          Creates a new style based on the provided style, but replacing the border as specified.
static Style applyFont(Style style, FontStyle font)
          Creates a new style based on the provided style, but replacing the font as specified.
static Style applyForegroundColor(Style style, Color foregroundColor)
          Creates a new style based on the provided style, but replacing the foreground color as specified.
static Style applyPatternColor(Style style, Color patternColor)
          Creates a new style based on the provided style, but replacing the pattern color as specified.
 Color getBackgroundColor()
          Returns the background color.
 Border getBorder()
          Returns the border for this style.
 int getCellIndent()
          Returns the indentation.
 FontStyle getFont()
          Returns the font for this style.
 Color getForegroundColor()
          Returns the foreground color.
 java.lang.String getFormat()
          Returns the format string for the cell.
 int getHorizontalAlignment()
          Returns the horizontal alignment for this style.
 int getOrientation()
          Returns the text orientation.
 Color getPatternColor()
          Returns the pattern color.
 int getShade()
          Returns the shade.
 int getVerticalAlignment()
          Returns the vertical alignment for this style.
 boolean isWrapText()
          Returns a flag indicating whether or not the text is wrapped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

font

protected FontStyle font
The font details.


border

protected Border border
The border details.


horizontalAlignment

protected int horizontalAlignment
The horizontal alignment.


verticalAlignment

protected int verticalAlignment
The vertical alignment.


wrapText

protected boolean wrapText
Wrap text (true/false).


orientation

protected int orientation
The orientation.


shade

protected int shade
The shade. Not all that sure about this yet. It might in fact be a boolean in the Gnumeric file format. It needs to be "1" if the cell has a background color.


cellIndent

protected int cellIndent
The indentation for the cells.


foregroundColor

protected Color foregroundColor
The foreground color.


backgroundColor

protected Color backgroundColor
The background color.


patternColor

protected Color patternColor
The pattern color.


format

protected java.lang.String format
The format.

Constructor Detail

Style

public Style()
Constructs a new Style object with default values.


Style

public Style(FontStyle font,
             int horizontalAlignment,
             int verticalAlignment)
Constructs a style with a specific font and alignment.

Parameters:
font - the font.
horizontalAlignment - the horizontal alignment.
verticalAlignment - the vertical alignment.

Style

public Style(FontStyle font,
             Border border,
             int horizontalAlignment,
             int verticalAlignment,
             boolean wrapText,
             int orientation,
             int shade,
             int cellIndent,
             Color foregroundColor,
             Color backgroundColor,
             Color patternColor,
             java.lang.String format)
Full constructor.

Parameters:
font - the font.
border - the border.
horizontalAlignment - the horizontal alignment.
verticalAlignment - the vertical alignment.
wrapText - wrap text (true/false).
orientation - the text orientation.
shade - ??
cellIndent - cell indentation.
foregroundColor - the foreground color.
backgroundColor - the bacground color.
patternColor - the pattern color.
format - the format string for the cell.
Method Detail

getFont

public FontStyle getFont()
Returns the font for this style.

Returns:
The font for this style.

getBorder

public Border getBorder()
Returns the border for this style.

Returns:
The border for this style.

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment for this style.

Returns:
The horizontal alignment for this style.

getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment for this style.

Returns:
The vertical alignment for this style.

isWrapText

public boolean isWrapText()
Returns a flag indicating whether or not the text is wrapped.

Returns:
A flag indicating whether or not the text is wrapped.

getOrientation

public int getOrientation()
Returns the text orientation.

Returns:
The text orientation.

getShade

public int getShade()
Returns the shade.

Returns:
The shade.

getCellIndent

public int getCellIndent()
Returns the indentation.

Returns:
The indentation.

getForegroundColor

public Color getForegroundColor()
Returns the foreground color.

Returns:
The foreground color.

getBackgroundColor

public Color getBackgroundColor()
Returns the background color.

Returns:
The background color.

getPatternColor

public Color getPatternColor()
Returns the pattern color.

Returns:
The pattern color.

getFormat

public java.lang.String getFormat()
Returns the format string for the cell.

Returns:
The format string for the cell.

applyFont

public static Style applyFont(Style style,
                              FontStyle font)
Creates a new style based on the provided style, but replacing the font as specified.

Parameters:
style - the base style.
font - the new font.
Returns:
The style.

applyBorder

public static Style applyBorder(Style base,
                                Border border)
Creates a new style based on the provided style, but replacing the border as specified.

Parameters:
base - the base style.
border - the new border.
Returns:
The style.

applyForegroundColor

public static Style applyForegroundColor(Style style,
                                         Color foregroundColor)
Creates a new style based on the provided style, but replacing the foreground color as specified.

Parameters:
style - the base style.
foregroundColor - the new foreground color.
Returns:
The style.

applyBackgroundColor

public static Style applyBackgroundColor(Style style,
                                         Color backgroundColor)
Creates a new style based on the provided style, but replacing the background color as specified.

We set the shade value to 1, since it looks as though this is required by the Gnumeric file format...will try to find out more about this.

Parameters:
style - the base style.
backgroundColor - the new background color.
Returns:
The style.

applyPatternColor

public static Style applyPatternColor(Style style,
                                      Color patternColor)
Creates a new style based on the provided style, but replacing the pattern color as specified.

Parameters:
style - t base style.
patternColor - the pattern color.
Returns:
The style.