ca.cgjennings.ui
Class Theme

java.lang.Object
  extended by ca.cgjennings.ui.Theme

public abstract class Theme
extends java.lang.Object

A Theme encapsulates a UI design theme. Themes are applied before installing a look and feel and are expected to modify the design parameters of a look and feel (typically by changing values in UIDefaults).

Since:
2.00RC1

Nested Class Summary
static class Theme.BufferedConsolePainter
          This painter wraps another painter, buffering the wrapped painter so that it only needs to be called when the console window's size changes.
static interface Theme.ConsolePainter
          Interface for objects that can paint the background of the scripting console.
 
Field Summary
static boolean INVERT_PANEL_ICONS_HINT
          A hint that the theme uses dark colours so that dark icons on the panel should be inverted or substituted.
 
Constructor Summary
Theme()
           
 
Method Summary
abstract  void applyTheme(javax.swing.UIDefaults defaults)
          This method is called after the look and feel has been installed and allows you to set defaults in the look and feel's UI defaults.
static java.lang.String findAvailableFontFamily(java.lang.String families)
          Returns the first font family in a list of comma-separated font families that is available on this system.
static java.lang.String findAvailableFontFamily(java.lang.String[] families)
          Given an array of font family names, returns the first font family that is available on this system.
 void finish(javax.swing.LookAndFeel laf)
          Called after the look and feel instance has been installed.
 java.lang.String getClassName()
          Returns the look and feel class name.
abstract  java.lang.String getThemeName()
          Returns the name of this theme, as it should be presented to the user.
abstract  void initializeUIDefaults(javax.swing.UIDefaults defaults)
          This method is called prior to installing the look and feel and allows you to set defaults in the user UI defaults.
 void setConsoleStyle(java.awt.Color background, java.awt.Color text, java.awt.Color errorText, java.awt.Color selection, java.awt.Color selectionText)
          Changes the style for the script console.
 void setConsoleStyle(java.awt.Color background, java.awt.Color text, java.awt.Color errorText, java.awt.Color selection, java.awt.Color selectionText, Theme.ConsolePainter backdrop)
          Changes the style for the script console.
 void start(javax.swing.LookAndFeel laf)
          Called after instantiating the look and feel but before installing it.
 java.lang.String toString()
          Returns the name of the theme, as given by getThemeName().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INVERT_PANEL_ICONS_HINT

public static boolean INVERT_PANEL_ICONS_HINT
A hint that the theme uses dark colours so that dark icons on the panel should be inverted or substituted.

Constructor Detail

Theme

public Theme()
Method Detail

getThemeName

public abstract java.lang.String getThemeName()
Returns the name of this theme, as it should be presented to the user. Theme names are typically short, one word names and are often named for mythos elements.

Returns:
the human-friendly name of this theme

initializeUIDefaults

public abstract void initializeUIDefaults(javax.swing.UIDefaults defaults)
This method is called prior to installing the look and feel and allows you to set defaults in the user UI defaults.

Parameters:
defaults - the user UI defaults object

applyTheme

public abstract void applyTheme(javax.swing.UIDefaults defaults)
This method is called after the look and feel has been installed and allows you to set defaults in the look and feel's UI defaults.

Parameters:
defaults - the Look and Feel UI defaults

setConsoleStyle

public final void setConsoleStyle(java.awt.Color background,
                                  java.awt.Color text,
                                  java.awt.Color errorText,
                                  java.awt.Color selection,
                                  java.awt.Color selectionText)
Changes the style for the script console. Theme implementations may use this to customize the console appearance. This version paints the console background as a solid colour.

Parameters:
background - the background colour for the console
text - the primary text colour
errorText - the text colour for error messages
selection - the background colour for selected text
selectionText - the foreground colour for selected text

setConsoleStyle

public final void setConsoleStyle(java.awt.Color background,
                                  java.awt.Color text,
                                  java.awt.Color errorText,
                                  java.awt.Color selection,
                                  java.awt.Color selectionText,
                                  Theme.ConsolePainter backdrop)
Changes the style for the script console. Theme implementations may use this to customize the console appearance. This version paints the console background using a Theme.ConsolePainter.

Parameters:
background - the background colour for the console
text - the primary text colour
errorText - the text colour for error messages
selection - the background colour for selected text
selectionText - the foreground colour for selected text

toString

public java.lang.String toString()
Returns the name of the theme, as given by getThemeName().

Overrides:
toString in class java.lang.Object
Returns:
the name of this theme

findAvailableFontFamily

public static java.lang.String findAvailableFontFamily(java.lang.String families)
Returns the first font family in a list of comma-separated font families that is available on this system. If none of the families is avaiable, a standard sans-serif family is returned.

Parameters:
families - a list of comma-separated font family names
Returns:
the first available entry in the list, or the standard sans-serif family name

findAvailableFontFamily

public static java.lang.String findAvailableFontFamily(java.lang.String[] families)
Given an array of font family names, returns the first font family that is available on this system. If none of the font families in the array are available, this method returns Font.SANS_SERIF.

Parameters:
families - an array of candidate family names
Returns:
the available candidate with the lowest index in families, or the standard sans-serif family name

getClassName

public java.lang.String getClassName()
Returns the look and feel class name.

Returns:
the name of a LookAndFeel subclass

start

public void start(javax.swing.LookAndFeel laf)
Called after instantiating the look and feel but before installing it.

Parameters:
laf - the look and feel instance being installed

finish

public void finish(javax.swing.LookAndFeel laf)
Called after the look and feel instance has been installed.

Parameters:
laf - the look and feel instance that was installed