com.townleyenterprises.swing
Class ThemeLoader

java.lang.Object
  extended bycom.townleyenterprises.swing.ThemeLoader

public class ThemeLoader
extends java.lang.Object

This class is similar to the ResourceLoader, but it isn't dealing with the same sort of information. For themes, arbitrary properties files (with a '.theme' suffix) are used rather than properties. These are also not localized, so the locale concept doesn't apply in this case.

Version:
$Id: ThemeLoader.java,v 1.5 2004/07/29 18:35:01 atownley Exp $
Author:
Andrew S. Townley

Constructor Summary
ThemeLoader(java.lang.Class cls, java.lang.String name)
          This constructor takes a class to use as the basis for finding the theme and the name.
ThemeLoader(java.io.InputStream stream)
          This constructor is used to load themes directly from the specified input stream.
ThemeLoader(java.lang.Object obj, java.lang.String theme)
          The constructor takes an object to use as the basis for finding the theme and the name.
ThemeLoader(ThemeLoader parent, java.lang.Class cls, java.lang.String name)
          This constructor is used to support inheritance of themes.
ThemeLoader(ThemeLoader parent, java.io.InputStream stream)
          This constructor is used to support inheritance from arbitrary input streams.
 
Method Summary
 java.awt.Color getColor(java.lang.String key)
          This method is used to return theme colors.
protected  javax.swing.plaf.ColorUIResource getColorUIResource(java.lang.String key)
          This is a utility method for loading color UI resources.
 java.awt.Font getFont(java.lang.String key)
          This method is used to load a specific font from the theme.
protected  javax.swing.plaf.FontUIResource getFontUIResource(java.lang.String key)
          This is a utility method for loading font UI resources.
 javax.swing.plaf.metal.MetalTheme getMetalTheme()
          This method is used to return the appropriately initialized Metal look and feel theme based on the theme properties.
 java.lang.String getName()
          Accessor for the theme name.
 java.lang.String getSetting(java.lang.String key)
          This method is used to find a given theme setting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThemeLoader

public ThemeLoader(java.lang.Object obj,
                   java.lang.String theme)
The constructor takes an object to use as the basis for finding the theme and the name.

Parameters:
obj - the object to provide the base resource location
theme - the name of the theme to load

ThemeLoader

public ThemeLoader(java.lang.Class cls,
                   java.lang.String name)
This constructor takes a class to use as the basis for finding the theme and the name.

Parameters:
cls - the class providing the base resource location

ThemeLoader

public ThemeLoader(ThemeLoader parent,
                   java.lang.Class cls,
                   java.lang.String name)
This constructor is used to support inheritance of themes. This is mainly useful if only the default look & feel colors should be changed, but other themeable things should remain the same.

Parameters:
parent - the parent theme loader
cls - the class providing the context for the theme
name - the name of the theme to load

ThemeLoader

public ThemeLoader(java.io.InputStream stream)
This constructor is used to load themes directly from the specified input stream.

Parameters:
stream - the InputStream

ThemeLoader

public ThemeLoader(ThemeLoader parent,
                   java.io.InputStream stream)
This constructor is used to support inheritance from arbitrary input streams.

Parameters:
parent - the parent theme
stream - the input stream
Method Detail

getColor

public java.awt.Color getColor(java.lang.String key)
This method is used to return theme colors.

Parameters:
key - the resource key
Returns:
the color

getFont

public java.awt.Font getFont(java.lang.String key)
This method is used to load a specific font from the theme.

Returns:
an initialized font object

getMetalTheme

public javax.swing.plaf.metal.MetalTheme getMetalTheme()
This method is used to return the appropriately initialized Metal look and feel theme based on the theme properties.

Returns:
the theme suitable for use in the Metal L&F

getName

public java.lang.String getName()
Accessor for the theme name.

Returns:
the name of this theme

getSetting

public java.lang.String getSetting(java.lang.String key)
This method is used to find a given theme setting.

Parameters:
key - the resource string key
Returns:
the string for the key

getColorUIResource

protected javax.swing.plaf.ColorUIResource getColorUIResource(java.lang.String key)
This is a utility method for loading color UI resources.

Parameters:
key - the name
Returns:
the UIResource for the key

getFontUIResource

protected javax.swing.plaf.FontUIResource getFontUIResource(java.lang.String key)
This is a utility method for loading font UI resources.

Parameters:
key - the name
Returns:
the UIResource for the key


Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.