de.enough.polish.ui
Class Style

java.lang.Object
  extended by de.enough.polish.ui.Style
All Implemented Interfaces:
Externalizable, Serializable

public class Style
extends java.lang.Object
implements Externalizable

Style defines the design of any widget.

This class is used by the widgets. If you only use the predefined widgets you do not need to work with this class.

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

Field Summary
 Background background
           
 Border border
           
 java.lang.String dynamicName
           
static java.lang.Boolean FALSE
           
 javax.microedition.lcdui.Font font
           
 int fontColor
          Deprecated. Please use getFontColor() instead
 Color fontColorObj
           
 int layout
           
 int marginBottom
           
 int marginLeft
           
 int marginRight
           
 int marginTop
           
 java.lang.String name
          The name of this style.
 int paddingBottom
           
 int paddingHorizontal
           
 int paddingLeft
           
 int paddingRight
           
 int paddingTop
           
 int paddingVertical
           
static java.lang.Boolean TRUE
           
 
Constructor Summary
Style()
          Creates a new style with default settings
Style(int marginLeft, int marginRight, int marginTop, int marginBottom, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom, int paddingVertical, int paddingHorizontal, int layout, int fontColor, Color fontColorObj, javax.microedition.lcdui.Font font, Background background, Border border, short[] attributeKeys, java.lang.Object[] attributeValues)
          Creates a new Style.
Style(int marginLeft, int marginRight, int marginTop, int marginBottom, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom, int paddingVertical, int paddingHorizontal, int layout, int fontColor, javax.microedition.lcdui.Font font, Background background, Border border, short[] attributeKeys, java.lang.Object[] attributeValues)
          Creates a new Style.
 
Method Summary
 void addAttribute(int key, java.lang.Object value)
           
 java.lang.Boolean getBooleanProperty(java.lang.String propName)
          Retrieves a non-standard boolean property of this style.
 Color getColorProperty(java.lang.String propName)
          Retrieves a non-standard color property of this style.
 int getFontColor()
          Retrieves the font color that should be used.
 java.lang.Integer getIntProperty(java.lang.String propName)
          Retrieves a non-standard integer property of this style.
 java.lang.Object getObjectProperty(java.lang.String propName)
          Retrieves a non-standard property of this style.
 java.lang.String getProperty(java.lang.String propName)
          Retrieves a non-standard property of this style.
 void read(java.io.DataInputStream in)
          Restores the internal instance fields from the given input stream.
 void releaseResources()
          Releases all (memory intensive) resources such as images or RGB arrays of this style.
 void removeAttribute(int key)
           
 void write(java.io.DataOutputStream out)
          Stores the internal instance fields to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static final java.lang.Boolean TRUE

FALSE

public static final java.lang.Boolean FALSE

name

public transient java.lang.String name
The name of this style.


dynamicName

public transient java.lang.String dynamicName

background

public Background background

border

public Border border

font

public javax.microedition.lcdui.Font font

fontColor

public int fontColor
Deprecated. Please use getFontColor() instead
See Also:
getFontColor()

fontColorObj

public Color fontColorObj

paddingLeft

public int paddingLeft

paddingTop

public int paddingTop

paddingRight

public int paddingRight

paddingBottom

public int paddingBottom

paddingVertical

public int paddingVertical

paddingHorizontal

public int paddingHorizontal

marginLeft

public int marginLeft

marginTop

public int marginTop

marginRight

public int marginRight

marginBottom

public int marginBottom

layout

public int layout
Constructor Detail

Style

public Style()
Creates a new style with default settings


Style

public Style(int marginLeft,
             int marginRight,
             int marginTop,
             int marginBottom,
             int paddingLeft,
             int paddingRight,
             int paddingTop,
             int paddingBottom,
             int paddingVertical,
             int paddingHorizontal,
             int layout,
             int fontColor,
             javax.microedition.lcdui.Font font,
             Background background,
             Border border,
             short[] attributeKeys,
             java.lang.Object[] attributeValues)
Creates a new Style.

Parameters:
marginLeft - the margin in pixels to the next element on the left
marginRight - the margin in pixels to the next element on the right
marginTop - the margin in pixels to the next element on the top
marginBottom - the margin in pixels to the next element on the bottom
paddingLeft - the padding between the left border and content in pixels
paddingRight - the padding between the right border and content in pixels
paddingTop - the padding between the top border and content in pixels
paddingBottom - the padding between the bottom border and content in pixels
paddingVertical - the vertical padding between internal elements of an item
paddingHorizontal - the horizontal padding between internal elements of an item
layout - the layout for this style, e.g. Item.LAYOUT_CENTER
fontColor - the color of the font
font - the content-font for this style
background - the background for this style
border - the border for this style
attributeKeys - the integer-IDs of any additional attributes. Can be null.
attributeValues - the values of any additional attributes. Can be null.

Style

public Style(int marginLeft,
             int marginRight,
             int marginTop,
             int marginBottom,
             int paddingLeft,
             int paddingRight,
             int paddingTop,
             int paddingBottom,
             int paddingVertical,
             int paddingHorizontal,
             int layout,
             int fontColor,
             Color fontColorObj,
             javax.microedition.lcdui.Font font,
             Background background,
             Border border,
             short[] attributeKeys,
             java.lang.Object[] attributeValues)
Creates a new Style.

Parameters:
marginLeft - the margin in pixels to the next element on the left
marginRight - the margin in pixels to the next element on the right
marginTop - the margin in pixels to the next element on the top
marginBottom - the margin in pixels to the next element on the bottom
paddingLeft - the padding between the left border and content in pixels
paddingRight - the padding between the right border and content in pixels
paddingTop - the padding between the top border and content in pixels
paddingBottom - the padding between the bottom border and content in pixels
paddingVertical - the vertical padding between internal elements of an item
paddingHorizontal - the horizontal padding between internal elements of an item
layout - the layout for this style, e.g. Item.LAYOUT_CENTER
fontColor - the color of the font
fontColorObj - the color of the font, might be a dynamic color like COLOR_FOREGROUND
font - the content-font for this style
background - the background for this style
border - the border for this style
attributeKeys - the integer-IDs of any additional attributes. Can be null.
attributeValues - the values of any additional attributes. Can be null.
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String propName)
Retrieves a non-standard property of this style.

Parameters:
propName - the name of the property
Returns:
the value of this property as a String. If none has been defined, null will be returned.

getObjectProperty

public java.lang.Object getObjectProperty(java.lang.String propName)
Retrieves a non-standard property of this style.

Parameters:
propName - the name of the property
Returns:
the value of this property. If none has been defined, null will be returned.

getIntProperty

public java.lang.Integer getIntProperty(java.lang.String propName)
Retrieves a non-standard integer property of this style.

Parameters:
propName - the name of the property
Returns:
the value of this property as an Integer object. If none has been defined, null will be returned.

getColorProperty

public Color getColorProperty(java.lang.String propName)
Retrieves a non-standard color property of this style.

Parameters:
propName - the name of the property
Returns:
the value of this property as an Color object. If none has been defined, null will be returned.

getBooleanProperty

public java.lang.Boolean getBooleanProperty(java.lang.String propName)
Retrieves a non-standard boolean property of this style.

Parameters:
propName - the name of the property
Returns:
the value of this property as an Boolean object. If none has been defined, null will be returned.

releaseResources

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


getFontColor

public int getFontColor()
Retrieves the font color that should be used. The color can be dynamic like Display.COLOR_FOREGROUND and should always be retrieved using this method instead of using the public field fontColor.

Returns:
the color for the font.

removeAttribute

public void removeAttribute(int key)
Parameters:
key - the integer key of the attribute

addAttribute

public void addAttribute(int key,
                         java.lang.Object value)
Parameters:
key - the integer key of the attribute
value - the value of the attribute

read

public void read(java.io.DataInputStream in)
          throws java.io.IOException
Description copied from interface: Externalizable
Restores the internal instance fields from the given input stream.

Specified by:
read in interface Externalizable
Parameters:
in - the input stream from which the data is loaded
Throws:
java.io.IOException - when reading fails

write

public void write(java.io.DataOutputStream out)
           throws java.io.IOException
Description copied from interface: Externalizable
Stores the internal instance fields to the output stream.

Specified by:
write in interface Externalizable
Parameters:
out - the output stream to which instance fields should be written
Throws:
java.io.IOException - when writing fails