com.sun.lwuit.plaf
Class Style

java.lang.Object
  extended by com.sun.lwuit.plaf.Style

public class Style
extends java.lang.Object

Represents the look of a given component: colors, fonts, transparency, margin and padding & images.

Each Component contains a Style Object and allows Style modification in Runtime by Using cmp.getStyle() The style is also used in Themeing, when a Theme is Changed the Styles Objects are been updated automatically.

When changing a theme the elements changed manually in a style will not be updated by the theme change by default. There are two ways to change that behavior:

  1. Use the set method that accepts a second boolean argument and set it to true.
  2. Create a new style object and pass all the options in the constructor (without invoking setters manually).

The Margin and Padding is inspired by W3 Box Model


       **************************
       *         Margin         *
       *  ********************  *
       *  *      Padding     *  *
       *  *    ***********   *  *
       *  *    * Content *   *  *
       *  *    ***********   *  *
       *  *      Padding     *  *
       *  ********************  *
       *         Margin         *
       **************************


Field Summary
static java.lang.String ALIGNMENT
          Alignment attribute for the style event
static java.lang.String BACKGROUND_ALIGNMENT
          Background attribute name for the theme hashtable
static java.lang.String BACKGROUND_GRADIENT
          Background attribute name for the theme hashtable
static byte BACKGROUND_GRADIENT_LINEAR_HORIZONTAL
          Indicates the background for the style would use a linear gradient
static byte BACKGROUND_GRADIENT_LINEAR_VERTICAL
          Indicates the background for the style would use a linear gradient
static byte BACKGROUND_GRADIENT_RADIAL
          Indicates the background for the style would use a radial gradient
static byte BACKGROUND_IMAGE_ALIGN_BOTTOM
          Indicates the background alignment for use in tiling or aligned images
static byte BACKGROUND_IMAGE_ALIGN_CENTER
          Indicates the background alignment for use in tiling or aligned images
static byte BACKGROUND_IMAGE_ALIGN_LEFT
          Indicates the background alignment for use in tiling or aligned images
static byte BACKGROUND_IMAGE_ALIGN_RIGHT
          Indicates the background alignment for use in tiling or aligned images
static byte BACKGROUND_IMAGE_ALIGN_TOP
          Indicates the background alignment for use in tiling or aligned images
static byte BACKGROUND_IMAGE_ALIGNED
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_BOTTOM
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_CENTER
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_LEFT
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_RIGHT
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_TOP
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_TOP_LEFT
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT
          Indicates the background for the style would use an unscaled image with an alignment
static byte BACKGROUND_IMAGE_SCALED
          Indicates the background for the style would use a scaled image
static byte BACKGROUND_IMAGE_TILE_BOTH
          Indicates the background for the style would use a tiled image on both axis
static byte BACKGROUND_IMAGE_TILE_HORIZONTAL
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_IMAGE_TILE_VERTICAL
          Indicates the background for the style would use a vertical tiled image
static byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT
          Indicates the background for the style would use a horizontal tiled image
static byte BACKGROUND_NONE
          Indicates the background for the style would use a scaled image
static java.lang.String BACKGROUND_TYPE
          Background attribute name for the theme hashtable
static java.lang.String BG_COLOR
          Background color attribute name for the theme hashtable
static java.lang.String BG_IMAGE
          Background image attribute name for the theme hashtable
static java.lang.String BORDER
          Border attribute name for the theme hashtable
static java.lang.String FG_COLOR
          Foreground color attribute name for the theme hashtable
static java.lang.String FONT
          Font attribute name for the theme hashtable
static java.lang.String MARGIN
          Margin attribute name for the theme hashtable
static java.lang.String MARGIN_UNIT
          The units of the margin
static java.lang.String PADDING
          Padding attribute name for the theme hashtable
static java.lang.String PADDING_UNIT
          The units of the padding
static java.lang.String PAINTER
          Painter attribute name for the style event
static java.lang.String TEXT_DECORATION
          Text decoration attribute for the style event
static byte TEXT_DECORATION_3D
          3D text effect using a font shadow
static byte TEXT_DECORATION_3D_LOWERED
          3D sunken text effect using a light font shadow
static byte TEXT_DECORATION_NONE
          Indicates no text decoration
static byte TEXT_DECORATION_OVERLINE
          Indicates overline
static byte TEXT_DECORATION_STRIKETHRU
          Indicates a strike-through line (usually used to denote deleted text)
static byte TEXT_DECORATION_UNDERLINE
          Indicates underline
static java.lang.String TRANSPARENCY
          Transparency attribute name for the theme hashtable
static byte UNIT_TYPE_DIPS
          Indicates the unit type for padding/margin in device independent pixels.
static byte UNIT_TYPE_PIXELS
          Indicates the unit type for padding/margin, the default is in device specific pixels
static byte UNIT_TYPE_SCREEN_PERCENTAGE
          Indicates the unit type for padding/margin in percentage of the size of the screen
 
Constructor Summary
Style()
          Each component when it draw itself uses this Object to determine in what colors it should use.
Style(int fgColor, int bgColor, Font f, byte transparency)
          Creates a new style with the given attributes
Style(int fgColor, int bgColor, Font f, byte transparency, Image im, byte backgroundType)
          Creates a new style with the given attributes
Style(Style style)
          Creates a full copy of the given style.
 
Method Summary
 void addStyleListener(StyleListener l)
          Adds a Style Listener to the Style Object.
 int getAlignment()
          Returns the alignment of the Label
 byte getBackgroundAlignment()
          Deprecated. the functionality of this method is now covered by background type
 int getBackgroundGradientEndColor()
          End color for the radial/linear gradient
 float getBackgroundGradientRelativeSize()
          Background radial gradient relative size
 float getBackgroundGradientRelativeX()
          Background radial gradient relative center position X
 float getBackgroundGradientRelativeY()
          Background radial gradient relative center position Y
 int getBackgroundGradientStartColor()
          Start color for the radial/linear gradient
 byte getBackgroundType()
          The type of the background defaults to BACKGROUND_IMAGE_SCALED
 int getBgColor()
          Background color for the component
 Image getBgImage()
          Background image for the component
 Painter getBgPainter()
          Return the background painter for this style, normally this would be the internal image/color painter but can be user defined
 byte getBgTransparency()
          Returns the transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.
 Border getBorder()
          Returns the border for the style
 int getFgColor()
          Foreground color for the component
 Font getFont()
          Font for the component
 int getMargin(boolean rtl, int orientation)
          Returns the Margin
 int getMargin(int orientation)
          Returns the Margin
 byte[] getMarginUnit()
          Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE
 int getMarginValue(boolean rtl, int orientation)
          Returns the Margin
 int getPadding(boolean rtl, int orientation)
          Returns the Padding in pixels
 int getPadding(int orientation)
          Returns the Padding
 byte[] getPaddingUnit()
          Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE
 int getPaddingValue(boolean rtl, int orientation)
          Returns the Padding in the internal value regardless of the unit
 int getTextDecoration()
          Returns the text decoration of this style
 boolean isLowered3DText()
          Returns true if the 3D text decoration is on, false otherwise
 boolean isModified()
          Returns true if the style was modified manually after it was created by the look and feel.
 boolean isOverline()
          Returns true if the overline text decoration is on, false otherwise
 boolean isRaised3DText()
          Returns true if the 3D text decoration is on, false otherwise
 boolean isStrikeThru()
          Returns true if the strike through text decoration is on, false otherwise
 boolean isUnderline()
          Returns true if the underline text decoration is on, false otherwise
 void merge(Style style)
          Merges the new style with the current style without changing the elements that were modified.
 void removeStyleListener(StyleListener l)
          Removes a Style Listener from the Style Object.
 void set3DText(boolean t, boolean raised)
          Sets the 3D text decoration for this style
 void setAlignment(int align)
          Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
 void setAlignment(int align, boolean override)
          Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
 void setBackgroundAlignment(byte backgroundAlignment)
          Deprecated. the functionality of this method is now covered by background type
 void setBackgroundAlignment(byte backgroundAlignment, boolean override)
          Deprecated. the functionality of this method is now covered by background type
 void setBackgroundGradientEndColor(int backgroundGradientEndColor)
          Sets the background color for the component
 void setBackgroundGradientEndColor(int backgroundGradientEndColor, boolean override)
          Sets the background color for the component
 void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize)
          Background radial gradient relative size
 void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize, boolean override)
          Background radial gradient relative size
 void setBackgroundGradientRelativeX(float backgroundGradientRelativeX)
          Background radial gradient relative center position X
 void setBackgroundGradientRelativeX(float backgroundGradientRelativeX, boolean override)
          Background radial gradient relative center position X
 void setBackgroundGradientRelativeY(float backgroundGradientRelativeY)
          Background radial gradient relative center position Y
 void setBackgroundGradientRelativeY(float backgroundGradientRelativeY, boolean override)
          Background radial gradient relative center position Y
 void setBackgroundGradientStartColor(int backgroundGradientStartColor)
          Sets the background color for the component
 void setBackgroundGradientStartColor(int backgroundGradientStartColor, boolean override)
          Sets the background color for the component
 void setBackgroundType(byte backgroundType)
          Sets the background type for the component
 void setBackgroundType(byte backgroundType, boolean override)
          Sets the background type for the component
 void setBgColor(int bgColor)
          Sets the background color for the component
 void setBgColor(int bgColor, boolean override)
          Sets the background color for the component
 void setBgImage(Image bgImage)
          Sets the background image for the component
 void setBgImage(Image bgImage, boolean override)
          Sets the background image for the component
 void setBgPainter(Painter bgPainter)
          Defines the background painter for this style, normally this would be the internal image/color painter but can be user defined
 void setBgTransparency(byte transparency)
          Sets the Component transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.
 void setBgTransparency(int transparency)
          Sets the Component transparency level.
 void setBgTransparency(int transparency, boolean override)
          Sets the Component transparency level.
 void setBorder(Border border)
          Sets the border for the style
 void setBorder(Border border, boolean override)
          Sets the border for the style
 void setFgColor(int fgColor)
          Sets the foreground color for the component
 void setFgColor(int fgColor, boolean override)
          Sets the foreground color for the component
 void setFont(Font font)
          Sets the font for the component
 void setFont(Font font, boolean override)
          Sets the font for the component
 void setMargin(int orientation, int gap)
          Sets the Style Margin
 void setMargin(int orientation, int gap, boolean override)
          Sets the Style Margin
 void setMargin(int top, int bottom, int left, int right)
          Sets the Style Margin
 void setMarginUnit(byte[] marginUnit)
          Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE
 void setOverline(boolean overline)
          Sets the overline text decoration for this style
 void setPadding(int orientation, int gap)
          Sets the Style Padding
 void setPadding(int orientation, int gap, boolean override)
          Sets the Style Padding
 void setPadding(int top, int bottom, int left, int right)
          Sets the Style Padding
 void setPaddingUnit(byte[] paddingUnit)
          Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE
 void setStrikeThru(boolean strikethru)
          Sets the strike through text decoration for this style
 void setTextDecoration(int textDecoration)
          Sets the text decoration of this style
 void setTextDecoration(int textDecoration, boolean override)
          Sets the text decoration of this style
 void setUnderline(boolean underline)
          Sets the underline text decoration for this style
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BG_COLOR

public static final java.lang.String BG_COLOR
Background color attribute name for the theme hashtable

See Also:
Constant Field Values

FG_COLOR

public static final java.lang.String FG_COLOR
Foreground color attribute name for the theme hashtable

See Also:
Constant Field Values

BG_IMAGE

public static final java.lang.String BG_IMAGE
Background image attribute name for the theme hashtable

See Also:
Constant Field Values

BACKGROUND_TYPE

public static final java.lang.String BACKGROUND_TYPE
Background attribute name for the theme hashtable

See Also:
Constant Field Values

BACKGROUND_ALIGNMENT

public static final java.lang.String BACKGROUND_ALIGNMENT
Background attribute name for the theme hashtable

See Also:
Constant Field Values

BACKGROUND_GRADIENT

public static final java.lang.String BACKGROUND_GRADIENT
Background attribute name for the theme hashtable

See Also:
Constant Field Values

FONT

public static final java.lang.String FONT
Font attribute name for the theme hashtable

See Also:
Constant Field Values

TRANSPARENCY

public static final java.lang.String TRANSPARENCY
Transparency attribute name for the theme hashtable

See Also:
Constant Field Values

MARGIN

public static final java.lang.String MARGIN
Margin attribute name for the theme hashtable

See Also:
Constant Field Values

BORDER

public static final java.lang.String BORDER
Border attribute name for the theme hashtable

See Also:
Constant Field Values

PADDING

public static final java.lang.String PADDING
Padding attribute name for the theme hashtable

See Also:
Constant Field Values

PAINTER

public static final java.lang.String PAINTER
Painter attribute name for the style event

See Also:
Constant Field Values

ALIGNMENT

public static final java.lang.String ALIGNMENT
Alignment attribute for the style event

See Also:
Constant Field Values

TEXT_DECORATION

public static final java.lang.String TEXT_DECORATION
Text decoration attribute for the style event

See Also:
Constant Field Values

PADDING_UNIT

public static final java.lang.String PADDING_UNIT
The units of the padding

See Also:
Constant Field Values

MARGIN_UNIT

public static final java.lang.String MARGIN_UNIT
The units of the margin

See Also:
Constant Field Values

BACKGROUND_NONE

public static final byte BACKGROUND_NONE
Indicates the background for the style would use a scaled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_SCALED

public static final byte BACKGROUND_IMAGE_SCALED
Indicates the background for the style would use a scaled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_BOTH

public static final byte BACKGROUND_IMAGE_TILE_BOTH
Indicates the background for the style would use a tiled image on both axis

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_VERTICAL

public static final byte BACKGROUND_IMAGE_TILE_VERTICAL
Indicates the background for the style would use a vertical tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_HORIZONTAL

public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED

public static final byte BACKGROUND_IMAGE_ALIGNED
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_TOP

public static final byte BACKGROUND_IMAGE_ALIGNED_TOP
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_BOTTOM

public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_LEFT

public static final byte BACKGROUND_IMAGE_ALIGNED_LEFT
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_RIGHT

public static final byte BACKGROUND_IMAGE_ALIGNED_RIGHT
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_CENTER

public static final byte BACKGROUND_IMAGE_ALIGNED_CENTER
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_TOP_LEFT

public static final byte BACKGROUND_IMAGE_ALIGNED_TOP_LEFT
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT

public static final byte BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT

public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT

public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT
Indicates the background for the style would use an unscaled image with an alignment

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP

public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER

public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM

public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT

public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER

public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT

public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT
Indicates the background for the style would use a horizontal tiled image

See Also:
Constant Field Values

BACKGROUND_GRADIENT_LINEAR_VERTICAL

public static final byte BACKGROUND_GRADIENT_LINEAR_VERTICAL
Indicates the background for the style would use a linear gradient

See Also:
Constant Field Values

BACKGROUND_GRADIENT_LINEAR_HORIZONTAL

public static final byte BACKGROUND_GRADIENT_LINEAR_HORIZONTAL
Indicates the background for the style would use a linear gradient

See Also:
Constant Field Values

BACKGROUND_GRADIENT_RADIAL

public static final byte BACKGROUND_GRADIENT_RADIAL
Indicates the background for the style would use a radial gradient

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGN_TOP

public static final byte BACKGROUND_IMAGE_ALIGN_TOP
Indicates the background alignment for use in tiling or aligned images

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGN_BOTTOM

public static final byte BACKGROUND_IMAGE_ALIGN_BOTTOM
Indicates the background alignment for use in tiling or aligned images

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGN_LEFT

public static final byte BACKGROUND_IMAGE_ALIGN_LEFT
Indicates the background alignment for use in tiling or aligned images

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGN_RIGHT

public static final byte BACKGROUND_IMAGE_ALIGN_RIGHT
Indicates the background alignment for use in tiling or aligned images

See Also:
Constant Field Values

BACKGROUND_IMAGE_ALIGN_CENTER

public static final byte BACKGROUND_IMAGE_ALIGN_CENTER
Indicates the background alignment for use in tiling or aligned images

See Also:
Constant Field Values

TEXT_DECORATION_NONE

public static final byte TEXT_DECORATION_NONE
Indicates no text decoration

See Also:
Constant Field Values

TEXT_DECORATION_UNDERLINE

public static final byte TEXT_DECORATION_UNDERLINE
Indicates underline

See Also:
Constant Field Values

TEXT_DECORATION_STRIKETHRU

public static final byte TEXT_DECORATION_STRIKETHRU
Indicates a strike-through line (usually used to denote deleted text)

See Also:
Constant Field Values

TEXT_DECORATION_OVERLINE

public static final byte TEXT_DECORATION_OVERLINE
Indicates overline

See Also:
Constant Field Values

TEXT_DECORATION_3D

public static final byte TEXT_DECORATION_3D
3D text effect using a font shadow

See Also:
Constant Field Values

TEXT_DECORATION_3D_LOWERED

public static final byte TEXT_DECORATION_3D_LOWERED
3D sunken text effect using a light font shadow

See Also:
Constant Field Values

UNIT_TYPE_PIXELS

public static final byte UNIT_TYPE_PIXELS
Indicates the unit type for padding/margin, the default is in device specific pixels

See Also:
Constant Field Values

UNIT_TYPE_SCREEN_PERCENTAGE

public static final byte UNIT_TYPE_SCREEN_PERCENTAGE
Indicates the unit type for padding/margin in percentage of the size of the screen

See Also:
Constant Field Values

UNIT_TYPE_DIPS

public static final byte UNIT_TYPE_DIPS
Indicates the unit type for padding/margin in device independent pixels. Device independent pixels try to aim at roghly 1 milimeter of the screen per DIP but make no guarantee for accuracy.

See Also:
Constant Field Values
Constructor Detail

Style

public Style()
Each component when it draw itself uses this Object to determine in what colors it should use. When a Component is generated it construct a default Style Object. The Default values for each Component can be changed by using the UIManager class


Style

public Style(Style style)
Creates a full copy of the given style. Notice that if the original style was modified manually (by invoking setters on it) it would not chnage when changing a theme/look and feel, however this newly created style would change in such a case.

Parameters:
style - the style to copy

Style

public Style(int fgColor,
             int bgColor,
             Font f,
             byte transparency)
Creates a new style with the given attributes

Parameters:
fgColor - foreground color
bgColor - background color
f - font
transparency - transparency value

Style

public Style(int fgColor,
             int bgColor,
             Font f,
             byte transparency,
             Image im,
             byte backgroundType)
Creates a new style with the given attributes

Parameters:
fgColor - foreground color
bgColor - background color
f - font
transparency - transparency value
im - background image
backgroundType - one of: BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL
Method Detail

merge

public void merge(Style style)
Merges the new style with the current style without changing the elements that were modified.

Parameters:
style - new values of styles from the current theme

isModified

public boolean isModified()
Returns true if the style was modified manually after it was created by the look and feel. If the style was modified manually (by one of the set methods) then it should be merged rather than overwritten.

Returns:
true if the style was modified

getBgColor

public int getBgColor()
Background color for the component

Returns:
the background color for the component

getBgImage

public Image getBgImage()
Background image for the component

Returns:
the background image for the component

getBackgroundType

public byte getBackgroundType()
The type of the background defaults to BACKGROUND_IMAGE_SCALED

Returns:
one of: BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL

getBackgroundAlignment

public byte getBackgroundAlignment()
Deprecated. the functionality of this method is now covered by background type

Return the alignment for the image or tiled image

Returns:
one of: BACKGROUND_IMAGE_ALIGN_TOP, BACKGROUND_IMAGE_ALIGN_BOTTOM, BACKGROUND_IMAGE_ALIGN_LEFT, BACKGROUND_IMAGE_ALIGN_RIGHT, BACKGROUND_IMAGE_ALIGN_CENTER

getBackgroundGradientStartColor

public int getBackgroundGradientStartColor()
Start color for the radial/linear gradient

Returns:
the start color for the radial/linear gradient

getBackgroundGradientEndColor

public int getBackgroundGradientEndColor()
End color for the radial/linear gradient

Returns:
the end color for the radial/linear gradient

getBackgroundGradientRelativeX

public float getBackgroundGradientRelativeX()
Background radial gradient relative center position X

Returns:
value between 0 and 1 with 0.5 representing the center of the component

getBackgroundGradientRelativeY

public float getBackgroundGradientRelativeY()
Background radial gradient relative center position Y

Returns:
value between 0 and 1 with 0.5 representing the center of the component

getBackgroundGradientRelativeSize

public float getBackgroundGradientRelativeSize()
Background radial gradient relative size

Returns:
value representing the relative size of the gradient

getFgColor

public int getFgColor()
Foreground color for the component

Returns:
the foreground color for the component

getFont

public Font getFont()
Font for the component

Returns:
the font for the component

setBgColor

public void setBgColor(int bgColor)
Sets the background color for the component

Parameters:
bgColor - RRGGBB color that ignors the alpha component

setAlignment

public void setAlignment(int align)
Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT

Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

setAlignment

public void setAlignment(int align,
                         boolean override)
Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT

Parameters:
align - alignment value
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

getAlignment

public int getAlignment()
Returns the alignment of the Label

Returns:
the alignment of the Label one of: CENTER, LEFT, RIGHT
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

setBgImage

public void setBgImage(Image bgImage)
Sets the background image for the component

Parameters:
bgImage - background image

setBackgroundType

public void setBackgroundType(byte backgroundType)
Sets the background type for the component

Parameters:
backgroundType - one of BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL

setBackgroundAlignment

public void setBackgroundAlignment(byte backgroundAlignment)
Deprecated. the functionality of this method is now covered by background type

Sets the background alignment for the component

Parameters:
backgroundAlignment - one of: BACKGROUND_IMAGE_ALIGN_TOP, BACKGROUND_IMAGE_ALIGN_BOTTOM, BACKGROUND_IMAGE_ALIGN_LEFT, BACKGROUND_IMAGE_ALIGN_RIGHT, BACKGROUND_IMAGE_ALIGN_CENTER

setBackgroundGradientStartColor

public void setBackgroundGradientStartColor(int backgroundGradientStartColor)
Sets the background color for the component

Parameters:
backgroundGradientStartColor - start color for the linear/radial gradient

setBackgroundGradientEndColor

public void setBackgroundGradientEndColor(int backgroundGradientEndColor)
Sets the background color for the component

Parameters:
backgroundGradientEndColor - end color for the linear/radial gradient

setBackgroundGradientRelativeX

public void setBackgroundGradientRelativeX(float backgroundGradientRelativeX)
Background radial gradient relative center position X

Parameters:
backgroundGradientRelativeX - x position of the radial gradient center

setBackgroundGradientRelativeY

public void setBackgroundGradientRelativeY(float backgroundGradientRelativeY)
Background radial gradient relative center position Y

Parameters:
backgroundGradientRelativeY - y position of the radial gradient center

setBackgroundGradientRelativeSize

public void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize)
Background radial gradient relative size

Parameters:
backgroundGradientRelativeSize - the size of the radial gradient

setFgColor

public void setFgColor(int fgColor)
Sets the foreground color for the component

Parameters:
fgColor - foreground color

setFont

public void setFont(Font font)
Sets the font for the component

Parameters:
font - the font

setUnderline

public void setUnderline(boolean underline)
Sets the underline text decoration for this style

Parameters:
underline - true to turn underline on, false to turn it off

isUnderline

public boolean isUnderline()
Returns true if the underline text decoration is on, false otherwise

Returns:
true if the underline text decoration is on, false otherwise

set3DText

public void set3DText(boolean t,
                      boolean raised)
Sets the 3D text decoration for this style

Parameters:
t - true to turn 3d shadow effect on, false to turn it off
raised - indicates a raised or lowered effect

isRaised3DText

public boolean isRaised3DText()
Returns true if the 3D text decoration is on, false otherwise

Returns:
true if the 3D text decoration is on, false otherwise

isLowered3DText

public boolean isLowered3DText()
Returns true if the 3D text decoration is on, false otherwise

Returns:
true if the 3D text decoration is on, false otherwise

setOverline

public void setOverline(boolean overline)
Sets the overline text decoration for this style

Parameters:
overline - true to turn overline on, false to turn it off

isOverline

public boolean isOverline()
Returns true if the overline text decoration is on, false otherwise

Returns:
true if the overline text decoration is on, false otherwise

setStrikeThru

public void setStrikeThru(boolean strikethru)
Sets the strike through text decoration for this style

Parameters:
strikethru - true to turn strike through on, false to turn it off

isStrikeThru

public boolean isStrikeThru()
Returns true if the strike through text decoration is on, false otherwise

Returns:
true if the strike through text decoration is on, false otherwise

getTextDecoration

public int getTextDecoration()
Returns the text decoration of this style

Returns:
the text decoration of this style (bitmask of the TEXT_DECORATION_* constants)

setTextDecoration

public void setTextDecoration(int textDecoration)
Sets the text decoration of this style

Parameters:
textDecoration - the textDecoration to set (bitmask of the TEXT_DECORATION_* constants)

setTextDecoration

public void setTextDecoration(int textDecoration,
                              boolean override)
Sets the text decoration of this style

Parameters:
textDecoration - the textDecoration to set (bitmask of the TEXT_DECORATION_* constants)
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

getBgTransparency

public byte getBgTransparency()
Returns the transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.

Returns:
the transparency level of the Component

setBgTransparency

public void setBgTransparency(byte transparency)
Sets the Component transparency (opacity) level of the Component, zero indicates fully transparent and FF indicates fully opaque.

Parameters:
transparency - transparency level as byte

setBgTransparency

public void setBgTransparency(int transparency)
Sets the Component transparency level. Valid values should be a number between 0-255

Parameters:
transparency - int value between 0-255

setPadding

public void setPadding(int top,
                       int bottom,
                       int left,
                       int right)
Sets the Style Padding

Parameters:
top - number of pixels to padd
bottom - number of pixels to padd
left - number of pixels to padd
right - number of pixels to padd

setPadding

public void setPadding(int orientation,
                       int gap)
Sets the Style Padding

Parameters:
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
gap - number of pixels to padd

setMargin

public void setMargin(int top,
                      int bottom,
                      int left,
                      int right)
Sets the Style Margin

Parameters:
top - number of margin pixels
bottom - number of margin pixels
left - number of margin pixels
right - number of margin pixels

setMargin

public void setMargin(int orientation,
                      int gap)
Sets the Style Margin

Parameters:
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
gap - number of margin pixels

getPaddingValue

public int getPaddingValue(boolean rtl,
                           int orientation)
Returns the Padding in the internal value regardless of the unit

Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
Returns:
number of padding pixels in the givven orientation

getPadding

public int getPadding(boolean rtl,
                      int orientation)
Returns the Padding in pixels

Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
Returns:
number of padding pixels in the givven orientation

getPadding

public int getPadding(int orientation)
Returns the Padding

Parameters:
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
Returns:
number of padding pixels in the givven orientation

getMargin

public int getMargin(int orientation)
Returns the Margin

Parameters:
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
Returns:
number of margin pixels in the givven orientation

getMargin

public int getMargin(boolean rtl,
                     int orientation)
Returns the Margin

Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
Returns:
number of margin pixels in the givven orientation

getMarginValue

public int getMarginValue(boolean rtl,
                          int orientation)
Returns the Margin

Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
Returns:
number of margin pixels in the givven orientation

setBgColor

public void setBgColor(int bgColor,
                       boolean override)
Sets the background color for the component

Parameters:
bgColor - RRGGBB color that ignors the alpha component
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBgImage

public void setBgImage(Image bgImage,
                       boolean override)
Sets the background image for the component

Parameters:
bgImage - background image
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundType

public void setBackgroundType(byte backgroundType,
                              boolean override)
Sets the background type for the component

Parameters:
backgroundType - one of BACKGROUND_IMAGE_SCALED, BACKGROUND_IMAGE_TILE_BOTH, BACKGROUND_IMAGE_TILE_VERTICAL, BACKGROUND_IMAGE_TILE_HORIZONTAL, BACKGROUND_IMAGE_ALIGNED, BACKGROUND_GRADIENT_LINEAR_HORIZONTAL, BACKGROUND_GRADIENT_LINEAR_VERTICAL, BACKGROUND_GRADIENT_RADIAL
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundAlignment

public void setBackgroundAlignment(byte backgroundAlignment,
                                   boolean override)
Deprecated. the functionality of this method is now covered by background type

Sets the background alignment for the component

Parameters:
backgroundAlignment - one of: BACKGROUND_IMAGE_ALIGN_TOP, BACKGROUND_IMAGE_ALIGN_BOTTOM, BACKGROUND_IMAGE_ALIGN_LEFT, BACKGROUND_IMAGE_ALIGN_RIGHT, BACKGROUND_IMAGE_ALIGN_CENTER
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundGradientStartColor

public void setBackgroundGradientStartColor(int backgroundGradientStartColor,
                                            boolean override)
Sets the background color for the component

Parameters:
backgroundGradientStartColor - start color for the linear/radial gradient
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundGradientEndColor

public void setBackgroundGradientEndColor(int backgroundGradientEndColor,
                                          boolean override)
Sets the background color for the component

Parameters:
backgroundGradientEndColor - end color for the linear/radial gradient
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundGradientRelativeX

public void setBackgroundGradientRelativeX(float backgroundGradientRelativeX,
                                           boolean override)
Background radial gradient relative center position X

Parameters:
backgroundGradientRelativeX - x position of the radial gradient center
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundGradientRelativeY

public void setBackgroundGradientRelativeY(float backgroundGradientRelativeY,
                                           boolean override)
Background radial gradient relative center position Y

Parameters:
backgroundGradientRelativeY - y position of the radial gradient center
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBackgroundGradientRelativeSize

public void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize,
                                              boolean override)
Background radial gradient relative size

Parameters:
backgroundGradientRelativeSize - the size of the radial gradient relative to the screens larger dimension
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setFgColor

public void setFgColor(int fgColor,
                       boolean override)
Sets the foreground color for the component

Parameters:
fgColor - foreground color
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setFont

public void setFont(Font font,
                    boolean override)
Sets the font for the component

Parameters:
font - the font
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setBgTransparency

public void setBgTransparency(int transparency,
                              boolean override)
Sets the Component transparency level. Valid values should be a number between 0-255

Parameters:
transparency - int value between 0-255
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setPadding

public void setPadding(int orientation,
                       int gap,
                       boolean override)
Sets the Style Padding

Parameters:
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
gap - number of pixels to padd
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

setMargin

public void setMargin(int orientation,
                      int gap,
                      boolean override)
Sets the Style Margin

Parameters:
orientation - one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
gap - number of margin pixels
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

addStyleListener

public void addStyleListener(StyleListener l)
Adds a Style Listener to the Style Object.

Parameters:
l - a style listener

removeStyleListener

public void removeStyleListener(StyleListener l)
Removes a Style Listener from the Style Object.

Parameters:
l - a style listener

setBorder

public void setBorder(Border border)
Sets the border for the style

Parameters:
border - new border object for the component

setBorder

public void setBorder(Border border,
                      boolean override)
Sets the border for the style

Parameters:
border - new border object for the component
override - If set to true allows the look and feel/theme to override the value in this attribute when changing a theme/look and feel

getBorder

public Border getBorder()
Returns the border for the style

Returns:
the border

getBgPainter

public Painter getBgPainter()
Return the background painter for this style, normally this would be the internal image/color painter but can be user defined

Returns:
the background painter

setBgPainter

public void setBgPainter(Painter bgPainter)
Defines the background painter for this style, normally this would be the internal image/color painter but can be user defined

Parameters:
bgPainter - new painter to install into the style

getPaddingUnit

public byte[] getPaddingUnit()
Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE

Returns:
the paddingUnit

setPaddingUnit

public void setPaddingUnit(byte[] paddingUnit)
Indicates the units used for padding elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE

Parameters:
paddingUnit - the paddingUnit to set

getMarginUnit

public byte[] getMarginUnit()
Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE

Returns:
the marginUnit

setMarginUnit

public void setMarginUnit(byte[] marginUnit)
Indicates the units used for margin elements, if null pixels are used if not this is a 4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or UNIT_TYPE_SCREEN_PERCENTAGE

Parameters:
marginUnit - the marginUnit to set