org.odftoolkit.simple.style
Class TextProperties

java.lang.Object
  extended by org.odftoolkit.simple.style.TextProperties

public class TextProperties
extends Object

This class represents text style settings.

In Open Document Format, there can be different font settings for different script types.

This class provides methods to access font style, font size, font name and etc for different script types.

Further functions will be provided, such as underline, shadow, background color and etc.

This class is a corresponded high level class for element "style:text-properties". It provides methods to access the attributes and children of "style:text-properties".

Since:
0.3

Constructor Summary
protected TextProperties()
          Create an instance of TextProperties
protected TextProperties(StyleTextPropertiesElement textProperties)
          Create an instance of TextProperties from an element
 
Method Summary
 String getBackgroundColorAttribute()
          Gets backgroundColor represented by the OpenDocument format used data type See W3C CSS specification for further details.
 String getCountry()
          Return the country information for western characters.
 String getCountry(Document.ScriptType type)
          Return the country information for a specific script type
 Font getFont()
          Return the font definition for western characters.
 Font getFont(Document.ScriptType type)
          Return the font definition for a specific script type
 Color getFontColor()
          Return the font color.
 String getFontFamilyName(Document.ScriptType type)
          Return the font family name for a specific script type
 String getFontName()
          Return the font name for western characters.
 String getFontName(Document.ScriptType type)
          Return the font name for a specific script type
 double getFontSizeInPoint()
          Return the font size definition in measurement point(PT) for western characters.
 double getFontSizeInPoint(Document.ScriptType type)
          Return the font size definition in measurement point(PT) for a specific script type.
 StyleTypeDefinitions.FontStyle getFontStyle()
          Return the font style for western characters
 StyleTypeDefinitions.FontStyle getFontStyle(Document.ScriptType type)
          Return the font style for a specific script type
 String getLanguage()
          Return the language information for western characters.
 String getLanguage(Document.ScriptType type)
          Return the language information for a specific script type
static TextProperties getOrCreateTextProperties(OdfStyleBase style)
          Return an instance of TextProperties
 Integer getSubscripted()
           
 Integer getSuperscripted()
           
 StyleTypeDefinitions.TextLinePosition getTextLineStyle()
          Return the font text line style
static TextProperties getTextProperties(OdfStyleBase style)
          Return an instance of TextProperties
 void setBackgroundColorAttribute(Color bkColor)
          Sets backgroundColor represented by the OpenDocument format used data type See W3C CSS specification for further details.
 void setCountry(String country)
          Set the country information for western character.
 void setCountry(String country, Document.ScriptType type)
          Set the country information for a specific script type.
 void setFont(Font font)
          Set the font definition for western character.
 void setFont(Font font, Locale language)
          Set the font definition.
 void setFontColor(Color fontColor)
          Set the font color.
 void setFontName(String fontName)
          Set the font name for western characters.
 void setFontName(String fontName, Document.ScriptType type)
          Set the font name for a specific script type
 void setFontSizeInPoint(double size)
          Set the font size in measurement point(PT) for western characters.
 void setFontSizeInPoint(double size, Document.ScriptType type)
          Set the font size in measurement point(PT) for a specific script type.
 void setFontStyle(StyleTypeDefinitions.FontStyle style)
          Set the font style for western characters
 void setFontStyle(StyleTypeDefinitions.FontStyle style, Document.ScriptType type)
          Set the font style for a specific script type
 void setLanguage(String language)
          Set the language information for western characters.
 void setLanguage(String language, Document.ScriptType type)
          Set the language information for a specific script type
 void setSubscripted(Integer fontsizePercent)
          Sets the text style subscripted
 void setSuperscripted(Integer fontsizePercent)
          Sets the text style superscripted
 void setTextLineStyle(StyleTypeDefinitions.TextLinePosition style)
          Set the font text line style for characters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextProperties

protected TextProperties()
Create an instance of TextProperties


TextProperties

protected TextProperties(StyleTextPropertiesElement textProperties)
Create an instance of TextProperties from an element

Parameters:
textProperties - - the element of style:text-properties
Method Detail

getFontStyle

public StyleTypeDefinitions.FontStyle getFontStyle()
Return the font style for western characters

Null will be returned if there is no font style setting for western characters

Returns:
the font style

getTextLineStyle

public StyleTypeDefinitions.TextLinePosition getTextLineStyle()
Return the font text line style

TextLineStyle.REGULAR will be returned if there is no text line style setting

Returns:
the font style

getFontStyle

public StyleTypeDefinitions.FontStyle getFontStyle(Document.ScriptType type)
Return the font style for a specific script type

REGULAR will be returned if there is no font style setting for this script type.

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

setFontStyle

public void setFontStyle(StyleTypeDefinitions.FontStyle style)
Set the font style for western characters

If the parameter style is REGULAR, the font style setting for western characters will be removed.

Parameters:
style - - the font style

setTextLineStyle

public void setTextLineStyle(StyleTypeDefinitions.TextLinePosition style)
Set the font text line style for characters

If the parameter style is REGULAR, the font text line style setting for characters will be removed.

Parameters:
style - - the font text line style

setFontStyle

public void setFontStyle(StyleTypeDefinitions.FontStyle style,
                         Document.ScriptType type)
Set the font style for a specific script type

If the parameter style is REGULAR, the font style setting for this script type will be removed.

Parameters:
style - - font style
type - - script type

getFontSizeInPoint

public double getFontSizeInPoint()
Return the font size definition in measurement point(PT) for western characters.

Zero will be returned if there is no font size definition for western characters.

Zero will be returned if the line measurement is not point(PT).

Returns:
the font size in measurement point(PT)

getFontSizeInPoint

public double getFontSizeInPoint(Document.ScriptType type)
Return the font size definition in measurement point(PT) for a specific script type.

Zero will be returned if there is no font size definition for this script type.

Zero will be returned if the line measurement is not point(PT).

Parameters:
type - - script type
Returns:
the font size in measurement point(PT)

setFontSizeInPoint

public void setFontSizeInPoint(double size)
Set the font size in measurement point(PT) for western characters.

If the font size is less than zero, the font size definition for western characters will be removed.

Parameters:
size - - font size

setFontSizeInPoint

public void setFontSizeInPoint(double size,
                               Document.ScriptType type)
Set the font size in measurement point(PT) for a specific script type.

If the font size is less than zero, the font size definition for this script type will be removed.

Parameters:
size - - font size
type - - script type

getLanguage

public String getLanguage()
Return the language information for western characters.

Null will be returned if there is no language information for western characters.

Returns:
the language information for western characters.

getLanguage

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

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

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

setLanguage

public void setLanguage(String language)
Set the language information for western characters.

If the parameter language is null, the language information for western characters will be removed.

Parameters:
language - - the language information

setLanguage

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

The consistency between country and script type is not verified.

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

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

getCountry

public String getCountry()
Return the country information for western characters.

Null will be returned if there is no country information for western characters.

Returns:
the country information for western characters.

getCountry

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

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

setCountry

public void setCountry(String country)
Set the country information for western character.

If the parameter country is null, the country information for western character will be removed.

Parameters:
country - - the country information

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

getFontColor

public Color getFontColor()
Return the font color.

Null will be returned if there is no font color setting.

Returns:
the font color

setFontColor

public void setFontColor(Color fontColor)
Set the font color.

If the parameter fontColor is null, the font color definition will be removed.

Parameters:
fontColor - - the font color

getFontName

public String getFontName()
Return the font name for western characters.

Null will be returned if there is no font name setting for western characters.

Returns:
the font style for western characters

getFontName

public String getFontName(Document.ScriptType type)
Return the font name for a specific script type

Null will be returned if there is no font name setting for this script type.

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

setFontName

public void setFontName(String fontName)
Set the font name for western characters.

If the parameter fontName is null, the font name for western characters will be removed.

Parameters:
fontName - - font name

setFontName

public void setFontName(String fontName,
                        Document.ScriptType type)
Set the font name for a specific script type

If the parameter fontName is null, the font name for this script type will be removed.

Parameters:
fontName - - font name
type - - script type

getFont

public Font getFont()
Return the font definition for western characters.

Null will be returned if there is no font definition for western characters.

Returns:
the font definition for western characters

getFont

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

Null will be returned if there is no font definition for this script type.

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

setFont

public void setFont(Font font)
Set the font definition for western character.

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.

This method can be used to set font for different script type, such as western characters, CJK characters, and CTL characters. The second parameter will be used to determine the script type.

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

Parameters:
font - - font definition
language - - the language
See Also:
Document.ScriptType

getFontFamilyName

public String getFontFamilyName(Document.ScriptType type)
Return the font family name for a specific script type

Null will be returned if there is no font family name definition for this script type.

Parameters:
type - - script type
Returns:
the font family name for a specific script type

getOrCreateTextProperties

public static TextProperties getOrCreateTextProperties(OdfStyleBase style)
Return an instance of TextProperties

to represent the "style:text-properties" in a style element.

If there is no "style:text-properties" defined in the style element, a new "style:text-properties" element will be created.

Parameters:
style - - a style element
Returns:
an instance of TextProperties


getTextProperties

public static TextProperties getTextProperties(OdfStyleBase style)
Return an instance of TextProperties

to represent the "style:text-properties" in a style element.

If there is no "style:text-properties" defined in the style element, null will be returned.

Parameters:
style - - a style element
Returns:
an instance of TextProperties

;Null if there is no "style:text-properties" defined

setSubscripted

public void setSubscripted(Integer fontsizePercent)
Sets the text style subscripted

Parameters:
fontsizePercent - font size in per cent for subscripted text. If null default is 58 %

setSuperscripted

public void setSuperscripted(Integer fontsizePercent)
Sets the text style superscripted

Parameters:
fontsizePercent - font size in per cent for superscripted text. If null default is 58 %

getSubscripted

public Integer getSubscripted()
Returns:
the percentage value of subscription or null

getSuperscripted

public Integer getSuperscripted()
Returns:
the percentage value of superscription or null

setBackgroundColorAttribute

public void setBackgroundColorAttribute(Color bkColor)
Sets backgroundColor represented by the OpenDocument format used data type See W3C CSS specification for further details.

Parameters:
bkColor -

getBackgroundColorAttribute

public String getBackgroundColorAttribute()
Gets backgroundColor represented by the OpenDocument format used data type See W3C CSS specification for further details.

Returns:
bkColor as String (see above)


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