dsto.dfc.swing.styles
Class StyleSheet

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by dsto.dfc.swing.styles.StyleSheet
All Implemented Interfaces:
Serializable, Cloneable, Map

public class StyleSheet
extends HashMap

A sheet of styles and their values. Clients will generally create a subclass of this class in which they declare a set of static final style instances (possibly based on AbstractStyle). See test.ui.style_sheet.TestStyleSheetView for an example.

Version:
$Revision$
Author:
Matthew Phillips
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  Style[] styles
           
 
Constructor Summary
StyleSheet()
          Creates an empty style sheet with no styles.
StyleSheet(Style[] styles)
          Create an empty style sheet with a given set of acceptable styles.
StyleSheet(StyleSheet sheet)
          Create a style sheet that is a copy of another.
 
Method Summary
 Color getColor(Style key)
          Shortcut to get a color value from the sheet.
 Font getFont(Style key)
          Shortcut to get a font value from the sheet.
 int getInt(Style key, int defaultValue)
          Shortcut to get an int value from the sheet.
 Style[] getStyles()
          Get the accepted styles for this sheet.
 String getSummary()
          Get a text summary of the styles that have values (eg "Fill Colour, Font").
 boolean hasValue(Style style)
           
 void merge(StyleSheet sheet)
          Merge another sheet with this sheet, copying all non-null values from sheet into this sheet.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

styles

protected Style[] styles
Constructor Detail

StyleSheet

public StyleSheet()
Creates an empty style sheet with no styles.


StyleSheet

public StyleSheet(Style[] styles)
Create an empty style sheet with a given set of acceptable styles.

Parameters:
styles - The acceptable styles.

StyleSheet

public StyleSheet(StyleSheet sheet)
Create a style sheet that is a copy of another.

Method Detail

getStyles

public Style[] getStyles()
Get the accepted styles for this sheet.


hasValue

public boolean hasValue(Style style)

merge

public void merge(StyleSheet sheet)
Merge another sheet with this sheet, copying all non-null values from sheet into this sheet.


getColor

public Color getColor(Style key)
Shortcut to get a color value from the sheet.


getFont

public Font getFont(Style key)
Shortcut to get a font value from the sheet.


getInt

public int getInt(Style key,
                  int defaultValue)
Shortcut to get an int value from the sheet.

Parameters:
key - The key for the value.
defaultValue - The value returned when there is no value for key.
Returns:
The int value of the style, or defaultValue when there is no value for the style.

getSummary

public String getSummary()
Get a text summary of the styles that have values (eg "Fill Colour, Font").



Copyright © 2008 Commonwealth of Australia