org.odftoolkit.simple.table
Class CellStyleHandler

java.lang.Object
  extended by org.odftoolkit.simple.style.DefaultStyleHandler
      extended by org.odftoolkit.simple.table.CellStyleHandler

public class CellStyleHandler
extends DefaultStyleHandler

This class provides functions to handle the style of a cell.

This class provides functions to handle the border settings, font settings, text alignment settings and so on.

Since:
0.3

Field Summary
 
Fields inherited from class org.odftoolkit.simple.style.DefaultStyleHandler
isUseDefaultStyle, mDocument, mFamilyProperties, mGraphicProperties, mOdfElement, mStyleElement, mWritableGraphicProperties, mWritableStyleElement
 
Method Summary
 Color getBackgroundColor()
          Return the background color.
 Border getBorder(StyleTypeDefinitions.CellBordersType type)
          Return the border setting for a specific border.
 String getCountry(Document.ScriptType type)
          Return the country information for a specific script type
 Font getFont(Document.ScriptType type)
          Return the font definition for a specific script type.
 StyleTypeDefinitions.HorizontalAlignmentType getHorizontalAlignment()
          Return the horizontal alignment.
 String getLanguage(Document.ScriptType type)
          Return the language information for a specific script type
 OdfStyle getStyleElementForWrite()
          Return the style element for this cell, for read and write functions.
 String getUsedStyleName()
          Return the used style name of this cell.
 StyleTypeDefinitions.VerticalAlignmentType getVerticalAlignment()
          Return the vertical alignment.
 boolean isTextWrapped()
          Return the wrap option of this cell.
 void setBackgroundColor(Color color)
          Set the background color of this cell.
 void setBorders(Border border, StyleTypeDefinitions.CellBordersType bordersType)
          Set the border style of this cell.
 void setCountry(String country, Document.ScriptType type)
          Set the country information for a specific script type
 void setFont(Font font)
          Set the font definition.
 void setFont(Font font, Locale language)
          Set the font definition.
 void setHorizontalAlignment(StyleTypeDefinitions.HorizontalAlignmentType alignType)
          Set the horizontal alignment.
 void setLanguage(String language, Document.ScriptType type)
          Set the language information for a specific script type
 void setTextWrapped(boolean isWrapped)
          Set the wrap option of this cell.
 void setVerticalAlignment(StyleTypeDefinitions.VerticalAlignmentType alignType)
          Set the vertical alignment setting of this cell.
 
Methods inherited from class org.odftoolkit.simple.style.DefaultStyleHandler
getGraphicPropertiesForRead, getGraphicPropertiesForWrite, getParagraphPropertiesForRead, getParagraphPropertiesForWrite, getReadableStyleElementByName, getStyleElementForRead, getTableCellPropertiesForRead, getTableCellPropertiesForWrite, getTextPropertiesForRead, getTextPropertiesForWrite, getWritableStyleElementByName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUsedStyleName

public String getUsedStyleName()
Return the used style name of this cell.

If there is no style name defined for cell, the attribute "table:default-cell-style-name" in table row and table column would be returned.

Overrides:
getUsedStyleName in class DefaultStyleHandler
Returns:
- the used style name of this component

getStyleElementForWrite

public OdfStyle getStyleElementForWrite()
Return the style element for this cell, for read and write functions.

An empty style definition will be created if there is no style definition.

Overrides:
getStyleElementForWrite in class DefaultStyleHandler
Returns:
the style element
See Also:
DefaultStyleHandler.getUsedStyleName()

getCountry

public String getCountry(Document.ScriptType type)
Return the country information for a specific script type

The country information in its parent style and default style will be taken into considered.

Null will be returned if there is no country information for this script type.

Parameters:
type - - script type
Returns:
the country information for a specific script type

getFont

public Font getFont(Document.ScriptType type)
Return the font definition for a specific script type.

The font definition in its parent style and default style will be taken into considered.

A default font definition will be returned if there is no font definition for this script type at all.

Parameters:
type - - script type
Returns:
the font definition for a specific script type

getLanguage

public String getLanguage(Document.ScriptType type)
Return the language information for a specific script type

The language definition in its parent style and default style will be taken into considered.

Null will be returned if there is no language information for this script type at all.

Parameters:
type - - script type
Returns:
the language information for a specific script type

setCountry

public void setCountry(String country,
                       Document.ScriptType type)
Set the country information for a specific script type

The consistency between country and script type is not verified.

If the parameter country is null, the country information for this script type will be removed.

Parameters:
country - - the country information
type - - script type
See Also:
TextProperties.setCountry(String, Document.ScriptType), Document.ScriptType

setFont

public void setFont(Font font)
Set the font definition. The locale information in font definition will be used to justify the script type.

If the parameter font is null, nothing will be happened.

Parameters:
font - - font definition

setFont

public void setFont(Font font,
                    Locale language)
Set the font definition. The locale information in font definition will be used to justify the script type.

If the parameter font is null, nothing will be happened.

Parameters:
font - - font definition

setLanguage

public void setLanguage(String language,
                        Document.ScriptType type)
Set the language information for a specific script type

If the parameter language is null, the language information for this script type will be removed.

Parameters:
language - - the language information
type - - script type

getBackgroundColor

public Color getBackgroundColor()
Return the background color.

The background color in its parent style and default style will be taken into considered.

Color WHITE will be returned if there is no the background color definition or the background color definition is not valid.

Returns:
the background color

getBorder

public Border getBorder(StyleTypeDefinitions.CellBordersType type)
Return the border setting for a specific border.

The accepted parameter can be TOP,BOTTOM,LEFT,RIGHT,DIAGONALBLTR and DIAGONALTLBR.

The border type with a collection of borders, e.g. ALL_FOUR, LEFT_RIGHT, are not legal arguments

The border definition in its parent style and default style will be taken into considered.

Border.NONE will be returned if there is no the border definition for a specific border.

Parameters:
type - - the border type which describes a single border
Returns:
the border setting

getVerticalAlignment

public StyleTypeDefinitions.VerticalAlignmentType getVerticalAlignment()
Return the vertical alignment.

If there is no vertical alignment definition, DEFAULT will be returned.

The vertical alignment definition in its parent style and default style will be taken into considered.

Returns:
the vertical alignment

isTextWrapped

public boolean isTextWrapped()
Return the wrap option of this cell.

The wrap option definition in its parent style and default style will be taken into considered.

Returns:
true if the cell content can be wrapped;

false if the cell content cannot be wrapped.


setBackgroundColor

public void setBackgroundColor(Color color)
Set the background color of this cell.

Parameters:
color - - the background color that need to set. If color is null, background color setting will be removed.

setBorders

public void setBorders(Border border,
                       StyleTypeDefinitions.CellBordersType bordersType)
Set the border style of this cell. You can set the border style for a single border or a border collection.

The second parameter bordersType describes which borders you want to apply the style to, e.g. up border, bottom border, left border, right border, diagonal lines or four borders.

Parameters:
border - - the border style description
bordersType - - the type of the borders

setVerticalAlignment

public void setVerticalAlignment(StyleTypeDefinitions.VerticalAlignmentType alignType)
Set the vertical alignment setting of this cell.

If the alignment is set as Default or null, the explicit vertical alignment setting is removed.

Parameters:
alignType - - the vertical alignment setting.

setTextWrapped

public void setTextWrapped(boolean isWrapped)
Set the wrap option of this cell.

Parameters:
isWrapped - - whether the cell content can be wrapped or not

setHorizontalAlignment

public void setHorizontalAlignment(StyleTypeDefinitions.HorizontalAlignmentType alignType)
Set the horizontal alignment.

If the parameter alignType is null, the horizontal alignment setting will be removed.

Parameters:
alignType - - the horizontal alignment

getHorizontalAlignment

public StyleTypeDefinitions.HorizontalAlignmentType getHorizontalAlignment()
Return the horizontal alignment.

The horizontal alignment in its parent style and default style will be taken into considered.

DEFAULT will be returned if there is no horizontal alignment setting.

Returns:
- the horizontal alignment; null if there is no horizontal alignment setting.


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.