de.enough.polish.ui
Class StyleSheet

java.lang.Object
  extended by de.enough.polish.ui.StyleSheet

public final class StyleSheet
extends java.lang.Object

Manages all defined styles of a specific project.

This class is actually pre-processed to get the styles specific for the project and the device.

Author:
Robert Virkus, robert@enough.de
 history
        05-Jan-2004 - rob creation
 

Field Summary
static AnimationThread animationThread
          Access to the AnimationThread responsible for animating all user interface components
static javax.microedition.lcdui.Command CANCEL_CMD
          default CANCEL command
static Screen currentScreen
          Access to the currently shown J2ME Polish screen, if any
static Style defaultStyle
          default style
static javax.microedition.lcdui.Display display
          Access to the application's Display
static boolean enableScreenChangeAnimations
          Allows you to disable or enable screen change animations.
static Style focusedStyle
          default style for focused/hovered items
protected static java.util.Hashtable imagesByName
           
static Style labelStyle
          default style for labels
static Style menuStyle
          default style for the commands menu
static javax.microedition.midlet.MIDlet midlet
          Access to the currently running MIDlet
static javax.microedition.lcdui.Command OK_CMD
          default OK command
 
Constructor Summary
StyleSheet()
           
 
Method Summary
static Style[] getDynamicStyles()
           
static javax.microedition.lcdui.Image getImage(java.lang.String url, java.lang.Object parent, boolean cache)
          Retrieves the image with the given name.
static Style getStyle(Item item)
          Retrieves the style for the given item.
static Style getStyle(Screen screen)
          Retrieves a dynamic style for the given screen.
static Style getStyle(java.lang.String name)
          Gets the style with the specified name.
static java.util.Hashtable getStyles()
          Retrieves all registered styles in a Hashtable.
static void notifyImageConsumers(java.lang.String name, javax.microedition.lcdui.Image image)
          Notifies the GUI items which requested images about the successful loading of thoses images.
static void releaseResources()
          Releases all (memory intensive) resources such as images or RGB arrays of this style sheet.
static void setCurrent(javax.microedition.lcdui.Display display, javax.microedition.lcdui.Displayable nextDisplayable)
          Includes an animation while changing the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imagesByName

protected static java.util.Hashtable imagesByName

defaultStyle

public static Style defaultStyle
default style


focusedStyle

public static Style focusedStyle
default style for focused/hovered items


labelStyle

public static Style labelStyle
default style for labels


menuStyle

public static Style menuStyle
default style for the commands menu


currentScreen

public static Screen currentScreen
Access to the currently shown J2ME Polish screen, if any


display

public static javax.microedition.lcdui.Display display
Access to the application's Display


midlet

public static javax.microedition.midlet.MIDlet midlet
Access to the currently running MIDlet


animationThread

public static AnimationThread animationThread
Access to the AnimationThread responsible for animating all user interface components


OK_CMD

public static javax.microedition.lcdui.Command OK_CMD
default OK command


CANCEL_CMD

public static javax.microedition.lcdui.Command CANCEL_CMD
default CANCEL command


enableScreenChangeAnimations

public static boolean enableScreenChangeAnimations
Allows you to disable or enable screen change animations. This can only be used when you have set the preprocessing variable polish.ScreenChangeAnimation.allowConfiguration to true.

Constructor Detail

StyleSheet

public StyleSheet()
Method Detail

getImage

public static javax.microedition.lcdui.Image getImage(java.lang.String url,
                                                      java.lang.Object parent,
                                                      boolean cache)
                                               throws java.io.IOException
Retrieves the image with the given name. When the image has been cached before, it will be returned immediately. When it has not been cached before, it either will be loaded directly or in a background thread. This behaviour is set in the polish.xml file.

Parameters:
url - the URL of the Image, e.g. "/background.png"
parent - the object which needs the image, when the image should be loaded in the background, the parent need to implement the ImageConsumer interface when it wants to be notified when the picture has been loaded.
cache - true when the image should be cached for later retrieval. This costs RAM obviously, so you should decide carefully if large images should be cached.
Returns:
the image when it either was cached or is loaded directly. When the should be loaded in the background, it will be later set via the ImageConsumer.setImage()-method.
Throws:
java.io.IOException - when the image could not be loaded directly
See Also:
ImageConsumer.setImage(String, Image)

notifyImageConsumers

public static void notifyImageConsumers(java.lang.String name,
                                        javax.microedition.lcdui.Image image)
Notifies the GUI items which requested images about the successful loading of thoses images.

Parameters:
name - the URL of the image
image - the image

getStyle

public static Style getStyle(java.lang.String name)
Gets the style with the specified name.

Parameters:
name - the name of the style
Returns:
the specified style or null when no style with the given name has been defined.

getStyles

public static java.util.Hashtable getStyles()
Retrieves all registered styles in a Hashtable.

Returns:
all registered styles in a Hashtable.

getStyle

public static Style getStyle(Item item)
Retrieves the style for the given item. This function is only available when the <buildSetting>-attribute [useDynamicStyles] is enabled. This function allows to set styles without actually using the preprocessing- directive //#style. Beware that this dynamic style retrieval is not as performant as the direct-style-setting with the //#style preprocessing directive.

Parameters:
item - the item for which the style should be retrieved
Returns:
the appropriate style. When no specific style is found, the default style is returned.

getStyle

public static Style getStyle(Screen screen)
Retrieves a dynamic style for the given screen.

Parameters:
screen - the screen for which a style should be retrieved
Returns:
the style for the given screen.

setCurrent

public static void setCurrent(javax.microedition.lcdui.Display display,
                              javax.microedition.lcdui.Displayable nextDisplayable)
Includes an animation while changing the screen.

Parameters:
display - the display
nextDisplayable - the new screen, animations are only included for de.enough.polish.ui.Screen classes

releaseResources

public static void releaseResources()
Releases all (memory intensive) resources such as images or RGB arrays of this style sheet.


getDynamicStyles

public static Style[] getDynamicStyles()