org.formaria.aria.style
Class StyleManager

java.lang.Object
  extended by org.formaria.aria.style.StyleManager
Direct Known Subclasses:
EditorStyleManager

public class StyleManager
extends java.lang.Object

Class for managing Styles. Styles are created externally and added to the hashtable. Also handles the retrieval of styles.

Copyright (c) Formaria Ltd.,
$Revision: 2.7 $


Field Summary
protected static Style baseStyle
          The base style from which all others will be inherited
protected  Project currentProject
          The Project for which this instance of the StyleManager is working
protected  java.util.Hashtable fontCache
          Fonts found when creating styles
protected  java.util.Hashtable fontMap
          Mapping of font attributes
protected  java.util.Hashtable mergedStyles
          Used to merge child styles with their parents
protected  java.util.Hashtable styles
          Hashtable of project styles
protected  java.util.Properties uiManagerAttributes
          A map for UIManager styles
 
Constructor Summary
StyleManager(Project project)
          Construct a new style manager.
StyleManager(Project project, int styleCount)
          Construct a new style manager with an initial size.
 
Method Summary
 void addStyle(java.lang.String name, Style newStyle)
          Add a new Style to the hashtable with a unique name
 java.awt.Font getFont(java.lang.String style)
          Get the font for a given style.
 java.awt.Font getFont(Style style)
          Get the font for a given style.
 Style getStyle(java.lang.String name)
          Retrieve a named Style from the hashtable.
 Style getStyle(java.lang.String name, boolean create)
          Retrieve a named Style from the hashtable.
 Style getStyleParent(java.lang.String name)
          Get the parent of the named style
 java.util.Hashtable getStyles()
          Get the table of styles
 boolean hasStyle(java.lang.String styleName)
          Check if a style is available, either already processed, or named somewhere in the raw styles file.
 void load(java.lang.String file)
          Load the styles from the specified file
 void loadStyle(XmlElement element, java.lang.String path)
          Load a style from the XML element and save it to the specified path in the style hierarchy
protected  java.lang.String mapUiMgrAttribute(java.lang.String className, java.lang.String name)
          Convert a style attribute to a UIManager style
 void reset()
          reset the styles in case a new stylesheet is to be loaded.
 void setFontMap(java.util.Hashtable fontMaps)
          Setup the font mapping for
protected  void setUiMgrAttribute(java.lang.String className, java.lang.String name, java.lang.Object value)
          Set a UIManager style/attribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

styles

protected java.util.Hashtable styles
Hashtable of project styles


mergedStyles

protected java.util.Hashtable mergedStyles
Used to merge child styles with their parents


fontCache

protected java.util.Hashtable fontCache
Fonts found when creating styles


baseStyle

protected static Style baseStyle
The base style from which all others will be inherited


currentProject

protected Project currentProject
The Project for which this instance of the StyleManager is working


fontMap

protected java.util.Hashtable fontMap
Mapping of font attributes


uiManagerAttributes

protected java.util.Properties uiManagerAttributes
A map for UIManager styles

Constructor Detail

StyleManager

public StyleManager(Project project)
Construct a new style manager.

Parameters:
project - the owner project

StyleManager

public StyleManager(Project project,
                    int styleCount)
Construct a new style manager with an initial size.

Parameters:
styleCount - The number of initial styles in the styles Hashtable
Method Detail

addStyle

public void addStyle(java.lang.String name,
                     Style newStyle)
Add a new Style to the hashtable with a unique name

Parameters:
name - The name of the style
newStyle - The Style to be associated with the passed name

getStyle

public Style getStyle(java.lang.String name,
                      boolean create)
Retrieve a named Style from the hashtable. loop thru the "/" character and merge each one found with a new Style.

Parameters:
name - The name of the style.
create - booean to indicate whether the style should be created.
Returns:
The referenced Style

hasStyle

public boolean hasStyle(java.lang.String styleName)
Check if a style is available, either already processed, or named somewhere in the raw styles file. The method checks only basic style names

Parameters:
styleName - the name of the style
Returns:
true if the style is found

getStyle

public Style getStyle(java.lang.String name)
Retrieve a named Style from the hashtable. loop thru the "/" character and merge each one found with a new Style.

Parameters:
name - The name of the style.
Returns:
The referenced Style

getFont

public java.awt.Font getFont(java.lang.String style)
Get the font for a given style. Use the bold and italic attributes and do a bitwise or using the Font values to set the style.

Parameters:
style - the name of the style
Returns:
The constructed Font Object for the named Style

getFont

public java.awt.Font getFont(Style style)
Get the font for a given style. Use the bold and italic attributes and do a bitwise or using the Font values to set the style.

Parameters:
style - the style
Returns:
The constructed Font Object for the passed Style

setFontMap

public void setFontMap(java.util.Hashtable fontMaps)
Setup the font mapping for

Parameters:
fontMaps - the font mappings (face and size or just face to face)

load

public void load(java.lang.String file)
Load the styles from the specified file

Parameters:
file - the file name of the file to load

loadStyle

public void loadStyle(XmlElement element,
                      java.lang.String path)
Load a style from the XML element and save it to the specified path in the style hierarchy

Parameters:
element - the source element
path - the save path

getStyles

public java.util.Hashtable getStyles()
Get the table of styles

Returns:
the stytle table

getStyleParent

public Style getStyleParent(java.lang.String name)
Get the parent of the named style

Parameters:
name - the style name
Returns:
the parent style

reset

public void reset()
reset the styles in case a new stylesheet is to be loaded.


mapUiMgrAttribute

protected java.lang.String mapUiMgrAttribute(java.lang.String className,
                                             java.lang.String name)
Convert a style attribute to a UIManager style

Parameters:
className - the style class
name - the style attribute
Returns:
the UIManager attribute

setUiMgrAttribute

protected void setUiMgrAttribute(java.lang.String className,
                                 java.lang.String name,
                                 java.lang.Object value)
Set a UIManager style/attribute

Parameters:
className - the component class
name - the attribute name
value - the arribute value