|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.lwuit.plaf.Style
public class Style
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 Theming, 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:
The Margin and Padding is inspired by W3 Box Model
************************** * Margin * * ******************** * * * Padding * * * * *********** * * * * * Content * * * * * *********** * * * * Padding * * * ******************** * * Margin * **************************
Field Summary | |
---|---|
static String |
BG_COLOR
Background color attribute name for the theme hashtable. |
static String |
BG_IMAGE
Background image attribute name for the theme hashtable. |
static String |
BG_SELECTION_COLOR
Background selection color attribute name for the theme hashtable. |
static String |
BORDER
Border attribute name for the theme hashtable. |
static String |
FG_COLOR
Foreground color attribute name for the theme hashtable. |
static String |
FG_SELECTION_COLOR
Foreground color attribute name for the theme hashtable. |
static String |
FONT
Font attribute name for the theme hashtable. |
static String |
MARGIN
Margin attribute name for the theme hashtable. |
static String |
PADDING
Padding attribute name for the theme hashtable. |
static String |
SCALED_IMAGE
Scaled image attribute name for the theme hashtable. |
static String |
TRANSPARENCY
Transparency attribute name for the theme hashtable. |
Constructor Summary | |
---|---|
Style()
Each component when it draw itself uses this Object to determine in what colors it should use. |
|
Style(Color fgColor,
Color bgColor,
Color fgSelectionColor,
Color bgSelectionColor,
Font f,
byte transparency)
Creates a new style with the given attributes. |
|
Style(Color fgColor,
Color bgColor,
Color fgSelectionColor,
Color bgSelectionColor,
Font f,
byte transparency,
Image im,
boolean scaledImage)
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. |
Color |
getBgColor()
Returns the background color for the component. |
Image |
getBgImage()
Returns the 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. |
Color |
getBgSelectionColor()
Returns the background selection color for the component. |
byte |
getBgTransparency()
Returns the transparency level of the Component. |
Border |
getBorder()
Returns the border for the style. |
Color |
getFgColor()
Returns the foreground color for the component. |
Color |
getFgSelectionColor()
Returns the foreground selection color for the component. |
Font |
getFont()
Returns the font for the component. |
int |
getMargin(int orientation)
Returns the Margin. |
int |
getPadding(int orientation)
Returns the Padding. |
boolean |
isModified()
Returns true if the style was modified manually after it was created by the look and feel. |
boolean |
isScaleImage()
Indicates whether the image in the background is scaled. |
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 |
setBgColor(Color bgColor)
Sets the background color for the component. |
void |
setBgColor(Color 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 |
setBgSelectionColor(Color bgSelectionColor)
Sets the background selection color for the component. |
void |
setBgSelectionColor(Color bgSelectionColor,
boolean override)
Sets the background selection color for the component. |
void |
setBgTransparency(byte transparency)
Sets the Component transparency level. |
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(Color fgColor)
Sets the foreground color for the component. |
void |
setFgColor(Color fgColor,
boolean override)
Sets the foreground color for the component. |
void |
setFgSelectionColor(Color fgSelectionColor)
Sets the foreground selection color for the component. |
void |
setFgSelectionColor(Color fgSelectionColor,
boolean override)
Sets the foreground selection 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 |
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 |
setScaleImage(boolean scaleImage)
Set to true if the image in the background is scaled, false if it is tiled. |
void |
setScaleImage(boolean scaleImage,
boolean override)
Set to true if the image in the background is scaled, false if it is tiled. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String BG_COLOR
public static final String FG_COLOR
public static final String BG_IMAGE
public static final String BG_SELECTION_COLOR
public static final String FG_SELECTION_COLOR
public static final String FONT
public static final String SCALED_IMAGE
public static final String TRANSPARENCY
public static final String MARGIN
public static final String BORDER
public static final String PADDING
Constructor Detail |
---|
public Style()
public Style(Style style)
style
- the style to be copiedpublic Style(Color fgColor, Color bgColor, Color fgSelectionColor, Color bgSelectionColor, Font f, byte transparency)
fgColor
- foreground colorbgColor
- background colorfgSelectionColor
- foreground selection colorbgSelectionColor
- background selection colorf
- fonttransparency
- transparency levelpublic Style(Color fgColor, Color bgColor, Color fgSelectionColor, Color bgSelectionColor, Font f, byte transparency, Image im, boolean scaledImage)
fgColor
- foreground colorbgColor
- background colorfgSelectionColor
- foreground selection colorbgSelectionColor
- background selection colorf
- fonttransparency
- transparency levelim
- underlying imagescaledImage
- indicates whether image is scaledMethod Detail |
---|
public void merge(Style style)
style
- new values of styles from the current themepublic boolean isModified()
public Color getBgColor()
setBgColor(java.awt.Color)
public Image getBgImage()
setBgImage(com.sun.dtv.lwuit.Image)
public Color getFgColor()
setFgColor(java.awt.Color)
public Font getFont()
setFont(com.sun.dtv.lwuit.Font)
public void setBgColor(Color bgColor)
bgColor
- RRGGBB color that ignores the alpha componentgetBgColor()
public void setBgImage(Image bgImage)
bgImage
- the imagegetBgImage()
public void setFgColor(Color fgColor)
fgColor
- the colorgetFgColor()
public void setFont(Font font)
font
- the fontgetFont()
public Color getBgSelectionColor()
setBgSelectionColor(java.awt.Color)
public void setBgSelectionColor(Color bgSelectionColor)
bgSelectionColor
- the colorgetBgSelectionColor()
public Color getFgSelectionColor()
setFgSelectionColor(java.awt.Color)
public void setFgSelectionColor(Color fgSelectionColor)
fgSelectionColor
- the colorgetFgSelectionColor()
public boolean isScaleImage()
setScaleImage(boolean)
public void setScaleImage(boolean scaleImage)
scaleImage
- value indicating whether the image in the background is
scaledisScaleImage()
public byte getBgTransparency()
setBgTransparency(byte)
public void setBgTransparency(byte transparency)
transparency
- transparency level as bytegetBgTransparency()
public void setBgTransparency(int transparency)
transparency
- int value between 0-255getBgTransparency()
public void setPadding(int top, int bottom, int left, int right)
top
- number of pixels to padbottom
- number of pixels to padleft
- number of pixels to padright
- number of pixels to padgetPadding(int)
public void setPadding(int orientation, int gap)
orientation
- one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHTgap
- number of pixels to padgetPadding(int)
public void setMargin(int top, int bottom, int left, int right)
top
- number of margin pixelsbottom
- number of margin pixelsleft
- number of margin pixelsright
- number of margin pixelsgetMargin(int)
public void setMargin(int orientation, int gap)
orientation
- one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHTgap
- number of margin pixelsgetMargin(int)
public int getPadding(int orientation)
orientation
- one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
setPadding(int, int)
public int getMargin(int orientation)
orientation
- one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHT
setMargin(int, int)
public void setBgColor(Color bgColor, boolean override)
bgColor
- RRGGBB color that ignores the alpha componentoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetBgColor()
public void setBgImage(Image bgImage, boolean override)
bgImage
- the imageoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetBgImage()
public void setFgColor(Color fgColor, boolean override)
fgColor
- the coloroverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetFgColor()
public void setFont(Font font, boolean override)
font
- the fontoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetFont()
public void setBgSelectionColor(Color bgSelectionColor, boolean override)
bgSelectionColor
- the coloroverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetBgSelectionColor()
public void setFgSelectionColor(Color fgSelectionColor, boolean override)
fgSelectionColor
- the coloroverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetFgSelectionColor()
public void setScaleImage(boolean scaleImage, boolean override)
scaleImage
- value indicating whether the image in the background is scaledoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelisScaleImage()
public void setBgTransparency(int transparency, boolean override)
transparency
- the transparency leveloverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetBgTransparency()
public void setPadding(int orientation, int gap, boolean override)
orientation
- one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHTgap
- number of pixels to padoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetPadding(int)
public void setMargin(int orientation, int gap, boolean override)
orientation
- one of: Component.TOP, Component.BOTTOM, Component.LEFT, Component.RIGHTgap
- number of margin pixelsoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetMargin(int)
public void addStyleListener(StyleListener l)
l
- a style listenerremoveStyleListener(com.sun.dtv.lwuit.events.StyleListener)
public void removeStyleListener(StyleListener l)
l
- a style listeneraddStyleListener(com.sun.dtv.lwuit.events.StyleListener)
public void setBorder(Border border)
border
- new border object for the componentgetBorder()
public void setBorder(Border border, boolean override)
border
- new border object for the componentoverride
- If set to true allows the look and feel/theme to override
the value in this attribute when changing a theme/look and feelgetBorder()
public Border getBorder()
setBorder(com.sun.dtv.lwuit.plaf.Border)
public Painter getBgPainter()
setBgPainter(com.sun.dtv.lwuit.Painter)
public void setBgPainter(Painter bgPainter)
bgPainter
- new painter to install into the stylegetBgPainter()
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |