csheets.ext.style
Class StylableCell

java.lang.Object
  extended by csheets.ext.CellExtension
      extended by csheets.ext.style.StylableCell
All Implemented Interfaces:
Cell, CellListener, Extensible<Cell>, Serializable, Comparable<Cell>, EventListener

public class StylableCell
extends CellExtension

An extension of a cell in a spreadsheet, with support for style, i.e. font, format, alignment, color and border.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
static Color BACKGROUND
          The default background color
static Border BORDER
          The default empty border
static DateFormat DATE_FORMAT
          The default date format
static Font FONT
          The default font
static Color FOREGROUND
          The default foreground color
static NumberFormat NUMBER_FORMAT
          The default number format
static int VERTICAL_ALIGNMENT
          The default vertical alignment
 
Constructor Summary
StylableCell(Cell cell)
          Creates a stylable cell extension for the given cell.
 
Method Summary
 void cellCleared(Cell cell)
          Removes the style from the cell.
 void cellCopied(Cell cell, Cell source)
          Copies the style from the source cell to this one.
 Color getBackgroundColor()
          Returns the background color of the cell.
 Border getBorder()
          Returns the border of the cell.
 Font getFont()
          Returns the font used when rendering the cell's content.
 Color getForegroundColor()
          Returns the color used when rendering the cell's content.
 Format getFormat()
          Returns the format applied to the cell's value before rendering.
 int getHorizontalAlignment()
          Returns the horizontal alignment of the cell's content.
 int getVerticalAlignment()
          Returns the vertical alignment of the cell's content.
 boolean isFormattable()
          Returns whether a format can be applied to the cell's value.
 void resetStyle()
          Restes the style of the cell.
 void setBackgroundColor(Color bgColor)
          Sets the background color of the cell.
 void setBorder(Border border)
          Sets the border of the cell.
 void setFont(Font font)
          Sets the font used when rendering the cell's content.
 void setForegroundColor(Color fgColor)
          Sets the color used when rendering the cell's content.
 void setFormat(Format format)
          Sets the format applied to the cell's value before rendering.
 void setHorizontalAlignment(int hAlignment)
          Sets the horizontal alignment of the cell's content.
 void setVerticalAlignment(int vAlignment)
          Sets the vertical alignment of the cell's content.
 
Methods inherited from class csheets.ext.CellExtension
addCellListener, clear, compareTo, contentChanged, copyFrom, dependentsChanged, getAddress, getCellListeners, getContent, getDelegate, getDependents, getExtension, getFormula, getName, getPrecedents, getSpreadsheet, getValue, moveFrom, removeCellListener, setContent, toString, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUMBER_FORMAT

public static final NumberFormat NUMBER_FORMAT
The default number format


DATE_FORMAT

public static final DateFormat DATE_FORMAT
The default date format


FONT

public static final Font FONT
The default font


VERTICAL_ALIGNMENT

public static final int VERTICAL_ALIGNMENT
The default vertical alignment

See Also:
Constant Field Values

FOREGROUND

public static final Color FOREGROUND
The default foreground color


BACKGROUND

public static final Color BACKGROUND
The default background color


BORDER

public static final Border BORDER
The default empty border

Constructor Detail

StylableCell

StylableCell(Cell cell)
Creates a stylable cell extension for the given cell.

Parameters:
cell - the cell to extend
Method Detail

isFormattable

public boolean isFormattable()
Returns whether a format can be applied to the cell's value.

Returns:
whether a format can be applied to the cell's value

getFormat

public Format getFormat()
Returns the format applied to the cell's value before rendering.

Returns:
the format applied to the cell's value before rendering

getFont

public Font getFont()
Returns the font used when rendering the cell's content.

Returns:
the font used when rendering the cell's content

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment of the cell's content.

Returns:
the horizontal alignment of the cell's content

getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment of the cell's content.

Returns:
the vertical alignment of the cell's content

getForegroundColor

public Color getForegroundColor()
Returns the color used when rendering the cell's content.

Returns:
the color used when rendering the cell's content

getBackgroundColor

public Color getBackgroundColor()
Returns the background color of the cell.

Returns:
the background color of the cell

getBorder

public Border getBorder()
Returns the border of the cell.

Returns:
the border of the cell

setFormat

public void setFormat(Format format)
Sets the format applied to the cell's value before rendering.

Parameters:
format - the format applied to the cell's value before rendering

setFont

public void setFont(Font font)
Sets the font used when rendering the cell's content.

Parameters:
font - the font used when rendering the cell's content

setHorizontalAlignment

public void setHorizontalAlignment(int hAlignment)
Sets the horizontal alignment of the cell's content.

Parameters:
hAlignment - the horizontal alignment of the cell's content

setVerticalAlignment

public void setVerticalAlignment(int vAlignment)
Sets the vertical alignment of the cell's content.

Parameters:
vAlignment - the vertical alignment of the cell's content

setForegroundColor

public void setForegroundColor(Color fgColor)
Sets the color used when rendering the cell's content.

Parameters:
fgColor - the color used when rendering the cell's content

setBackgroundColor

public void setBackgroundColor(Color bgColor)
Sets the background color of the cell.

Parameters:
bgColor - the background color of the cell

setBorder

public void setBorder(Border border)
Sets the border of the cell.

Parameters:
border - the border of the cell

resetStyle

public void resetStyle()
Restes the style of the cell.


cellCleared

public void cellCleared(Cell cell)
Removes the style from the cell.

Specified by:
cellCleared in interface CellListener
Overrides:
cellCleared in class CellExtension
Parameters:
cell - the cell that was modified

cellCopied

public void cellCopied(Cell cell,
                       Cell source)
Copies the style from the source cell to this one.

Specified by:
cellCopied in interface CellListener
Overrides:
cellCopied in class CellExtension
Parameters:
cell - the cell that was modified
source - the cell from which data was copied