org.apache.pivot.wtk
Class Theme

java.lang.Object
  extended by org.apache.pivot.wtk.Theme
Direct Known Subclasses:
TerraTheme

public abstract class Theme
extends Object

Base class for Pivot themes. A theme defines a complete "look and feel" for a Pivot application.

Note that concrete Theme implementations should be declared as final. If multiple third-party libraries attempted to extend a theme, it would cause a conflict, as only one could be used in any given application.

IMPORTANT All skin mappings must be added to the map, even non-static inner classes. Otherwise, the component's base class will attempt to install its own skin, which will result in the addition of duplicate listeners.


Field Summary
static String BOLD_KEY
           
protected  HashMap<Class<? extends Component>,Class<? extends Skin>> componentSkinMap
           
static String ITALIC_KEY
           
static String NAME_KEY
           
static String PROVIDER_NAME
          The service provider name (see Service.getProvider(String)).
static String SIZE_KEY
           
 
Constructor Summary
Theme()
           
 
Method Summary
static Font deriveFont(Dictionary<String,?> dictionary)
          Produce a font by describing it relative to the current theme's font
 Class<? extends Skin> get(Class<? extends Component> componentClass)
          Returns the skin class responsible for skinning the specified component class.
abstract  Font getFont()
           
 Class<? extends Skin> getSkinClass(Class<? extends Component> componentClass)
           
static Theme getTheme()
          Gets the current theme, as determined by the theme provider.
 void set(Class<? extends Component> componentClass, Class<? extends Skin> skinClass)
          Sets the skin class responsible for skinning the specified component class.
abstract  void setFont(Font font)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

componentSkinMap

protected HashMap<Class<? extends Component>,Class<? extends Skin>> componentSkinMap

NAME_KEY

public static final String NAME_KEY
See Also:
Constant Field Values

SIZE_KEY

public static final String SIZE_KEY
See Also:
Constant Field Values

BOLD_KEY

public static final String BOLD_KEY
See Also:
Constant Field Values

ITALIC_KEY

public static final String ITALIC_KEY
See Also:
Constant Field Values

PROVIDER_NAME

public static final String PROVIDER_NAME
The service provider name (see Service.getProvider(String)).

See Also:
Constant Field Values
Constructor Detail

Theme

public Theme()
Method Detail

getSkinClass

public final Class<? extends Skin> getSkinClass(Class<? extends Component> componentClass)

getFont

public abstract Font getFont()

setFont

public abstract void setFont(Font font)

get

public Class<? extends Skin> get(Class<? extends Component> componentClass)
Returns the skin class responsible for skinning the specified component class.

Parameters:
componentClass - The component class.
Returns:
The skin class, or null if no skin mapping exists for the component class.

set

public void set(Class<? extends Component> componentClass,
                Class<? extends Skin> skinClass)
Sets the skin class responsible for skinning the specified component class.

Parameters:
componentClass - The component class.
skinClass - The skin class.

getTheme

public static Theme getTheme()
Gets the current theme, as determined by the theme provider.

Throws:
IllegalStateException - If a theme has not been installed.

deriveFont

public static Font deriveFont(Dictionary<String,?> dictionary)
Produce a font by describing it relative to the current theme's font

Parameters:
dictionary - A dictionary with any of the following keys:
  • "name" - the family name of the font
  • "size" - the font size as an integer, or a string "x%" for a relative size
  • "bold" - true/false
  • "italic" - true/false
Omitted values are taken from the theme's font.