jdbreport.model
Class CellStyle

java.lang.Object
  extended by jdbreport.model.CellStyle
All Implemented Interfaces:
Cloneable, SwingConstants

public class CellStyle
extends Object
implements Cloneable, SwingConstants

The cell attributes form the definition of a cell to be rendered.

Version:
2.0 15.02.2012
Author:
Andrey Kholmanskih

Field Summary
static int BOLD
          The bold style constant.
static float DEFAULT_LINE_SPACING
           
static Color defaultBackground
          Default background color for Cell
protected static CellStyle defaultStyle
           
static int ITALIC
          The italicized style constant.
static int JUSTIFY
          Orientation constant used to specify the justify text in Cell.
static int PLAIN
          The plain style constant.
static int SS_NONE
          No type offsetting (not super or subscript)
static int SS_SUB
          Subscript
static int SS_SUPER
          Superscript
static int STRIKETHROUGH
          The strikethrough style constant.
static int UNDERLINE
          The underline style constant.
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
protected CellStyle()
           
  CellStyle(String name, int style, int size)
          Creates a new CellStyle from the specified name, style and point size.
  CellStyle(String name, int style, int size, Color color)
          Creates a new CellStyle from the specified name, style, point size and foreground color.
 
Method Summary
static String alignToString(int align)
          Converts the alignment to a string representation
 Object clone()
           
 CellStyle deriveAngle(int angle)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new angle of rotation to it.
 CellStyle deriveAutoHeight(boolean b)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new autoHeight to it.
 CellStyle deriveBackground(Color value)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new background color to it.
 CellStyle deriveBackground(Color bgColor, int bgStyle)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new background color and color style to it.
 CellStyle deriveBorder(byte position, Border border)
           
 CellStyle deriveCarryRows(int count)
           
 CellStyle deriveFont(float size)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new size to it.
 CellStyle deriveFont(int style)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new font's style to it.
 CellStyle deriveFont(String fontName)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new font's family name to it.
 CellStyle deriveFont(String fontName, int style, int size)
          Creates a new CellStyle object by replicating this CellStyle object and applying a new font's name, style and size.
 CellStyle deriveForeground(Color value)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new foreground color to it.
 CellStyle deriveFormat(int decimal)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new decimal position of the numeric value to it.
 CellStyle deriveHAlign(int value)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new horizontal alignment to it.
 CellStyle deriveLineSpacing(float ls)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new line spacing to it.
 CellStyle deriveTypeOffset(int type)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new typeOffset to it.
 CellStyle deriveVAlign(int value)
          Creates a new CellStyle object by replicating the current CellStyle object and applying a new vertical alignment to it.
 CellStyle deriveWrapLine(boolean b)
           
 boolean equals(Object obj)
           
static String fontStyleStr(int style)
           
 int getAlignment()
          Converts to StyleConstants alignment
 int getAngle()
           
 Map<TextAttribute,Serializable> getAttributes()
           
 AttributeSet getAttributeSet()
          Converts CellStyle's attributes to javax.swing.text.AttributeSet
 Color getBackground()
          Returns the background color of this CellStyle
 int getBgStyle()
           
 Border getBorders(int pos)
          Returns Border's object of this CellStyle
 float getBorderWidth(int pos)
           
 int getCarryRows()
          Carry rows
 int getDecimal()
           
static CellStyle getDefaultStyle()
          Returns the default CellStyle
 String getFamily()
          Returns the font's family name of this CellStyle.
 Color getForegroundColor()
          Returns the foreground color of this CellStyle
 int getHorizontalAlignment()
          Returns the horizontal alignment of this CellStyle The horizontal alignment is a constant that may be LEFT, RIGHT, CENTER or JUSTIFY
 Object getId()
          Returns id for this CellStyle
 float getLineSpacing()
           
 int getSize()
          Returns the font's point size of this CellStyle,
 float getSpaceAbove()
           
 int getStyle()
          Returns the font's style of this CellStyle.
 int getTypeOffset()
          Get normal,super or subscript.
 int getVerticalAlignment()
          Returns the verical alignment of this CellStyle The vertical alignment is a constant that may be TOP, BOTTOM or CENTER
 boolean isAutoHeight()
          Determines whether the row's height will be set automatically
 boolean isBold()
          Indicates whether or not font's style is BOLD.
 boolean isItalic()
          Indicates whether or not font's style is ITALIC.
 boolean isStrikethrough()
          Indicates whether or not font's style is STRIKETHROUGH.
 boolean isUnderline()
          Indicates whether or not font's style is UNDERLINE.
 boolean isWrapLine()
           
 void setId(Object id)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAIN

public static final int PLAIN
The plain style constant.

See Also:
Constant Field Values

BOLD

public static final int BOLD
The bold style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.

See Also:
Constant Field Values

ITALIC

public static final int ITALIC
The italicized style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.

See Also:
Constant Field Values

UNDERLINE

public static final int UNDERLINE
The underline style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.

See Also:
Constant Field Values

STRIKETHROUGH

public static final int STRIKETHROUGH
The strikethrough style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.

See Also:
Constant Field Values

JUSTIFY

public static final int JUSTIFY
Orientation constant used to specify the justify text in Cell.

See Also:
Constant Field Values

SS_NONE

public static final int SS_NONE
No type offsetting (not super or subscript)

See Also:
Constant Field Values

SS_SUPER

public static final int SS_SUPER
Superscript

See Also:
Constant Field Values

SS_SUB

public static final int SS_SUB
Subscript

See Also:
Constant Field Values

defaultBackground

public static final Color defaultBackground
Default background color for Cell


DEFAULT_LINE_SPACING

public static final float DEFAULT_LINE_SPACING
See Also:
Constant Field Values

defaultStyle

protected static CellStyle defaultStyle
Constructor Detail

CellStyle

protected CellStyle()

CellStyle

public CellStyle(String name,
                 int style,
                 int size,
                 Color color)
Creates a new CellStyle from the specified name, style, point size and foreground color.

Parameters:
name - the font name
style - the font's style constants for the CellStyle The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD, ITALIC, UNDERLINE, STRIKETHROUGH
size - the font's point size of the CellStyle
color - the foreground color of the CellStyle

CellStyle

public CellStyle(String name,
                 int style,
                 int size)
Creates a new CellStyle from the specified name, style and point size.

Parameters:
name - the font name
style - the font's style constants for the CellStyle The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD, ITALIC, UNDERLINE, STRIKETHROUGH
size - the font's point size of the CellStyle
Method Detail

isBold

public boolean isBold()
Indicates whether or not font's style is BOLD.

Returns:
true if style is BOLD; false otherwise.

isItalic

public boolean isItalic()
Indicates whether or not font's style is ITALIC.

Returns:
true if style is ITALIC; false otherwise.

isUnderline

public boolean isUnderline()
Indicates whether or not font's style is UNDERLINE.

Returns:
true if style is UNDERLINE; false otherwise.

isStrikethrough

public boolean isStrikethrough()
Indicates whether or not font's style is STRIKETHROUGH.

Returns:
true if style is STRIKETHROUGH; false otherwise.

getVerticalAlignment

public int getVerticalAlignment()
Returns the verical alignment of this CellStyle The vertical alignment is a constant that may be TOP, BOTTOM or CENTER

Returns:
the vertical alignment of the CellStyle

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment of this CellStyle The horizontal alignment is a constant that may be LEFT, RIGHT, CENTER or JUSTIFY

Returns:
the horizontal alignment of the CellStyle

getForegroundColor

public Color getForegroundColor()
Returns the foreground color of this CellStyle

Returns:
the foreground color of the CellStyle

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getStyle

public int getStyle()
Returns the font's style of this CellStyle. The style can be PLAIN, BOLD, ITALIC, BOLD+ITALIC, UNDERLINE or STRIKETHROUGH.

Returns:
the font's style of this CellStyle.

getFamily

public String getFamily()
Returns the font's family name of this CellStyle.

Returns:
a String that is the font's family name of this CellStyle.

getSize

public int getSize()
Returns the font's point size of this CellStyle,

Returns:
the font's point size of this CellStyle in 1/72 of an inch units.

fontStyleStr

public static String fontStyleStr(int style)

deriveBorder

public CellStyle deriveBorder(byte position,
                              Border border)

deriveVAlign

public CellStyle deriveVAlign(int value)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new vertical alignment to it. The vertical alignment is a constant that may be TOP, BOTTOM or CENTER

Parameters:
value - the vertical alignment for the new CellStyle
Returns:
a new CellStyle object.

deriveHAlign

public CellStyle deriveHAlign(int value)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new horizontal alignment to it. The horizontal alignment is a constant that may be LEFT, RIGHT, CENTER or JUSTIFY

Parameters:
value - the horizontal alignment for the new CellStyle
Returns:
a new CellStyle object.

deriveBackground

public CellStyle deriveBackground(Color value)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new background color to it.

Parameters:
value - the background color for the new CellStyle
Returns:
a new CellStyle object.

deriveBackground

public CellStyle deriveBackground(Color bgColor,
                                  int bgStyle)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new background color and color style to it.

Parameters:
bgColor - the background color for the new CellStyle
bgStyle - the color's style for the new CellStyle
Returns:
a new CellStyle object.

getBgStyle

public int getBgStyle()

deriveForeground

public CellStyle deriveForeground(Color value)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new foreground color to it.

Parameters:
value - the foreground color for the new CellStyle
Returns:
a new CellStyle object.

deriveFont

public CellStyle deriveFont(String fontName,
                            int style,
                            int size)
Creates a new CellStyle object by replicating this CellStyle object and applying a new font's name, style and size.

Parameters:
fontName - - the font's name for the new CellStyle
style - the font's style for the new CellStyle
size - the font's size for the new CellStyle.
Returns:
a new CellStyle object.

deriveFont

public CellStyle deriveFont(float size)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new size to it.

Parameters:
size - the font's size for the new CellStyle.
Returns:
a new CellStyle object.

deriveFont

public CellStyle deriveFont(int style)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new font's style to it.

Parameters:
style - the font's style for the new CellStyle
Returns:
a new CellStyle object.

deriveFont

public CellStyle deriveFont(String fontName)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new font's family name to it.

Parameters:
fontName - the font's family name for the new CellStyle.
Returns:
a new CellStyle object.

getBackground

public Color getBackground()
Returns the background color of this CellStyle

Returns:
the background color of the CellStyle

getBorders

public Border getBorders(int pos)
Returns Border's object of this CellStyle

Parameters:
pos - position of border (Border.LINE_LEFT, Border.LINE_RIGHT, Border.LINE_TOP, Border.LINE_BOTTOM)
Returns:
Border's object of this CellStyle

getBorderWidth

public float getBorderWidth(int pos)

clone

public Object clone()
Overrides:
clone in class Object

deriveAngle

public CellStyle deriveAngle(int angle)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new angle of rotation to it.

Parameters:
angle - the angle of rotation for the new CellStyle.
Returns:
a new CellStyle object.

deriveFormat

public CellStyle deriveFormat(int decimal)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new decimal position of the numeric value to it.

Parameters:
decimal - the decimal position of the numeric value.
Returns:
a new CellStyle object.

getAlignment

public int getAlignment()
Converts to StyleConstants alignment

Returns:
StyleConstants alignment

alignToString

public static String alignToString(int align)
Converts the alignment to a string representation

Parameters:
align - constant of the alignment
Returns:
the string representation of alignment

getAngle

public int getAngle()
Returns:
the angle of rotation.

getDecimal

public int getDecimal()
Returns:
the decimal position of the numeric value for this CellStyle.

getId

public Object getId()
Returns id for this CellStyle

Returns:
id for this CellStyle

setId

public void setId(Object id)

getAttributeSet

public AttributeSet getAttributeSet()
Converts CellStyle's attributes to javax.swing.text.AttributeSet

Returns:
the AttributeSet object

getAttributes

public Map<TextAttribute,Serializable> getAttributes()

getSpaceAbove

public float getSpaceAbove()

getLineSpacing

public float getLineSpacing()

getDefaultStyle

public static CellStyle getDefaultStyle()
Returns the default CellStyle

Returns:
the default CellStyle

isAutoHeight

public boolean isAutoHeight()
Determines whether the row's height will be set automatically

Returns:
the autoHeight of the CellStyle

deriveAutoHeight

public CellStyle deriveAutoHeight(boolean b)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new autoHeight to it.

Parameters:
b - the autoHeight attribute for the new CellStyle.
Returns:
a new CellStyle object.

isWrapLine

public boolean isWrapLine()

deriveWrapLine

public CellStyle deriveWrapLine(boolean b)

deriveLineSpacing

public CellStyle deriveLineSpacing(float ls)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new line spacing to it.

Parameters:
ls - the line spacing for the new CellStyle
Returns:
a new CellStyle object.

getCarryRows

public int getCarryRows()
Carry rows

Returns:
count rows

deriveCarryRows

public CellStyle deriveCarryRows(int count)

getTypeOffset

public int getTypeOffset()
Get normal,super or subscript.

Returns:
offset type to use (none,super,sub)
Since:
1.3

deriveTypeOffset

public CellStyle deriveTypeOffset(int type)
Creates a new CellStyle object by replicating the current CellStyle object and applying a new typeOffset to it.

Parameters:
type - normal,super or subscript
Returns:
new style
Since:
1.3