org.j4me.ui
Class Theme

java.lang.Object
  extended by org.j4me.ui.Theme

public class Theme
extends java.lang.Object

Derive this class to set the application's theme. A theme controls the color scheme and background graphics used to skin the application.

Themes do not alter the shapes or functionality of components. To change the behavior of appearance of any component it is up to you to derive a new component type and implement the changes.


Field Summary
static int BLACK
          Black
static int BLUE
          Blue
static int BLUE_GREEN
          Blue-green
static int BROWN
          Brown
static int BURNT_ORANGE
          Burnt orange
static int CYAN
          Cyan
static int DARK_GREEN
          Dark green
static int FOREST_GREEN
          Forest green
static int GRAY
          Gray
static int GREEN
          Green
static int LAVENDAR
          Lavendar
static int LIGHT_BLUE
          Light blue
static int LIGHT_GRAY
          Light gray
static int LIGHT_GREEN
          Light green
static int LIGHT_RED
          Light red
static int MAGENTA
          Magenta
static int MAROON
          Maroon
static int MEDIUM_GREEN
          Medium green
static int NAVY
          Navy blue
static int NEON_BLUE
          Neon blue
static int ORANGE
          Orange
static int RED
          Red
static int SILVER
          Silver
static int WHITE
          White
static int YELLOW
          Yellow
 
Constructor Summary
Theme()
          Creates a Theme object.
 
Method Summary
 int getBackgroundColor()
          Returns the color used as the background for the canvas section of the screen.
 int getBorderColor()
          Returns the color used for borders in the canvas section of the UI.
 javax.microedition.lcdui.Font getFont()
          Gets the basic default font.
 int getFontColor()
          The color of the text written with the font returned by getFont.
 int getHighlightColor()
          Returns the main color used in painting components.
 int getMenuBarBackgroundColor()
          Returns the primary color of the background of the menu bar.
 int getMenuBarBorderColor()
          Returns the color of the border around the menu bar.
 int getMenuBarHighlightColor()
          Returns the highlight color applied as a vertical gradient to the menu bar.
 javax.microedition.lcdui.Font getMenuFont()
          Returns the font used in the menu bar at the bottom of the canvas.
 int getMenuFontColor()
          The color of the text written with the font returned by getMenuFont.
 int getMenuFontHighlightColor()
          The color of the menu text when the menu button is pressed.
 int getMenuHeight()
          Gets the height of the menu bar in pixels.
 java.lang.String getMenuTextForCancel()
          Gets the localized menu text for Cancel buttons that appear on forms.
 java.lang.String getMenuTextForOK()
          Gets the localized menu text for OK buttons that appear on forms.
 int getScrollbarBackgroundColor()
          Returns the color of the background of the scrollbar.
 int getScrollbarBorderColor()
          Returns the color of the border around the scrollbar.
 int getScrollbarHighlightColor()
          Returns the highlight color applied as a horizontal gradient to the scrollbar.
 int getScrollbarTrackbarColor()
          Returns the color of the trackbar within the scrollbar.
 int getTitleBarBackgroundColor()
          Returns the primary color of the background of the title bar.
 int getTitleBarBorderColor()
          Returns the color of the border around the title bar.
 int getTitleBarHighlightColor()
          Returns the highlight color applied as a vertical gradient to the title bar.
 javax.microedition.lcdui.Font getTitleFont()
          Returns the font used for writing the title in the screen's title area.
 int getTitleFontColor()
          The color of the text written with the font returned by getTitleFont.
 int getTitleHeight()
          Gets the height of the title bar in pixels.
 int getVerticalScrollbarWidth()
          Returns the width of the vertical scrollbar.
static void gradientFill(javax.microedition.lcdui.Graphics g, int x, int y, int width, int height, boolean fillVertically, int primaryColor, int secondaryColor, double maxSecondary)
          Fills a rectangle with linear gradient.
 void paintBackground(javax.microedition.lcdui.Graphics g)
          Paints the background of the main section of the screen.
 void paintMenuBar(javax.microedition.lcdui.Graphics g, java.lang.String left, boolean highlightLeft, java.lang.String right, boolean highlightRight, int width, int height)
          Paints the menu bar at the bottom of the canvas.
protected  void paintMenuBarBackground(javax.microedition.lcdui.Graphics g, int x, int y, int width, int height)
          Paints the background area of the menu bar.
protected  void paintScrollbarBackground(javax.microedition.lcdui.Graphics g, int x, int y, int width, int height)
          Paints the background area of the scrollbar.
 void paintTitleBar(javax.microedition.lcdui.Graphics g, java.lang.String title, int width, int height)
          Paints the title bar of the canvas.
protected  void paintTitleBarBackground(javax.microedition.lcdui.Graphics g, int x, int y, int width, int height)
          Paints the background area of the title bar.
protected  void paintTrackbar(javax.microedition.lcdui.Graphics g, int x, int y, int width, int height)
          Paints the trackbar on the scrollbar.
 void paintVerticalScrollbar(javax.microedition.lcdui.Graphics g, int x, int y, int width, int height, int offset, int formHeight)
          Paints the vertical scrollbar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLACK

public static final int BLACK
Black

See Also:
Constant Field Values

BROWN

public static final int BROWN
Brown

See Also:
Constant Field Values

BLUE

public static final int BLUE
Blue

See Also:
Constant Field Values

NAVY

public static final int NAVY
Navy blue

See Also:
Constant Field Values

NEON_BLUE

public static final int NEON_BLUE
Neon blue

See Also:
Constant Field Values

LIGHT_BLUE

public static final int LIGHT_BLUE
Light blue

See Also:
Constant Field Values

RED

public static final int RED
Red

See Also:
Constant Field Values

MAROON

public static final int MAROON
Maroon

See Also:
Constant Field Values

LIGHT_RED

public static final int LIGHT_RED
Light red

See Also:
Constant Field Values

MAGENTA

public static final int MAGENTA
Magenta

See Also:
Constant Field Values

ORANGE

public static final int ORANGE
Orange

See Also:
Constant Field Values

BURNT_ORANGE

public static final int BURNT_ORANGE
Burnt orange

See Also:
Constant Field Values

YELLOW

public static final int YELLOW
Yellow

See Also:
Constant Field Values

GREEN

public static final int GREEN
Green

See Also:
Constant Field Values

MEDIUM_GREEN

public static final int MEDIUM_GREEN
Medium green

See Also:
Constant Field Values

LIGHT_GREEN

public static final int LIGHT_GREEN
Light green

See Also:
Constant Field Values

DARK_GREEN

public static final int DARK_GREEN
Dark green

See Also:
Constant Field Values

FOREST_GREEN

public static final int FOREST_GREEN
Forest green

See Also:
Constant Field Values

BLUE_GREEN

public static final int BLUE_GREEN
Blue-green

See Also:
Constant Field Values

CYAN

public static final int CYAN
Cyan

See Also:
Constant Field Values

SILVER

public static final int SILVER
Silver

See Also:
Constant Field Values

GRAY

public static final int GRAY
Gray

See Also:
Constant Field Values

LIGHT_GRAY

public static final int LIGHT_GRAY
Light gray

See Also:
Constant Field Values

LAVENDAR

public static final int LAVENDAR
Lavendar

See Also:
Constant Field Values

WHITE

public static final int WHITE
White

See Also:
Constant Field Values
Constructor Detail

Theme

public Theme()
Creates a Theme object. After creating the theme it must be attached to the UI manager to use it through the setTheme method.

Method Detail

getFont

public javax.microedition.lcdui.Font getFont()
Gets the basic default font. This font is used for writing menu options, labels, and regular text throughout the UI.

Returns:
The font used for normal text within the UI.
See Also:
getFontColor()

getMenuFont

public javax.microedition.lcdui.Font getMenuFont()
Returns the font used in the menu bar at the bottom of the canvas.

By default this font is the system font. Override this font to change the style of the title text.

Returns:
The font used for writing menu text.
See Also:
getMenuFontColor(), paintMenuBar(Graphics, String, boolean, String, boolean, int, int)

getTitleFont

public javax.microedition.lcdui.Font getTitleFont()
Returns the font used for writing the title in the screen's title area.

By default this font is the system font in bold. Override this font to change the style of the title text.

Returns:
The font used for writing the title in the title area at the top of the screen.
See Also:
getTitleFontColor(), paintTrackbar(Graphics, int, int, int, int)

getFontColor

public int getFontColor()
The color of the text written with the font returned by getFont. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change the text color.

Returns:
The color of text written with the font from getFont.
See Also:
getFontColor()

getMenuFontColor

public int getMenuFontColor()
The color of the text written with the font returned by getMenuFont. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change the text color.

Returns:
The color of text written with the font from getMenuFont.
See Also:
getMenuFont(), paintMenuBar(Graphics, String, boolean, String, boolean, int, int)

getMenuFontHighlightColor

public int getMenuFontHighlightColor()
The color of the menu text when the menu button is pressed. Normally it will be the color returned by getMenuFontColor. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change the text color.

Returns:
The color of the menu text when its menu button is pressed.
See Also:
getMenuFont(), getMenuFontColor(), paintMenuBar(Graphics, String, boolean, String, boolean, int, int)

getTitleFontColor

public int getTitleFontColor()
The color of the text written with the font returned by getTitleFont. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change the text color.

Returns:
The color of text written with the font from getTitleFont.
See Also:
getTitleFont(), paintTrackbar(Graphics, int, int, int, int)

getBorderColor

public int getBorderColor()
Returns the color used for borders in the canvas section of the UI. An example of a border is the outline around a text box. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The color of the borders in the UI.

getBackgroundColor

public int getBackgroundColor()
Returns the color used as the background for the canvas section of the screen. This is the area that is not the title bar at the top or menu bar at the bottom. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The color of the title border.

getHighlightColor

public int getHighlightColor()
Returns the main color used in painting components. For example a progress bar will use this color to show the completed progress. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The primary color used to paint components.

getTitleBarBorderColor

public int getTitleBarBorderColor()
Returns the color of the border around the title bar. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

By default this is the same color as the menu border. Override this method to change it.

Returns:
The color of the title border.
See Also:
paintTrackbar(Graphics, int, int, int, int)

getTitleBarBackgroundColor

public int getTitleBarBackgroundColor()
Returns the primary color of the background of the title bar. A second color defined by getTitleBarHighlightColor is overlaid with a vertical gradient.

Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

By default this is the same color as the menu bar background. Override this method to change it.

Returns:
The primary color of the title bar background.
See Also:
getTitleBarHighlightColor()

getTitleBarHighlightColor

public int getTitleBarHighlightColor()
Returns the highlight color applied as a vertical gradient to the title bar.

Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

By default this is the same color as the menu bar highlight. Override this method to change it.

Returns:
The highlight color of the title bar background.
See Also:
getTitleBarBackgroundColor()

getMenuBarBorderColor

public int getMenuBarBorderColor()
Returns the color of the border around the menu bar. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The color of the border around the menu bar.
See Also:
paintMenuBar(Graphics, String, boolean, String, boolean, int, int)

getMenuBarBackgroundColor

public int getMenuBarBackgroundColor()
Returns the primary color of the background of the menu bar. A second color defined by getMenuBarHighlightColor is overlaid with a vertical gradient.

Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The color of the border around the menu bar.
See Also:
getMenuBarHighlightColor()

getMenuBarHighlightColor

public int getMenuBarHighlightColor()
Returns the highlight color applied as a vertical gradient to the menu bar.

Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The highlight color of the menu bar background.
See Also:
getMenuBarBackgroundColor()

getTitleHeight

public int getTitleHeight()
Gets the height of the title bar in pixels. This method is called whenever the title is set and the title bar is going to be painted.

Returns:
The height of the title bar in pixels.
See Also:
paintTrackbar(Graphics, int, int, int, int)

paintTitleBar

public void paintTitleBar(javax.microedition.lcdui.Graphics g,
                          java.lang.String title,
                          int width,
                          int height)
Paints the title bar of the canvas. This method is called only when the title has been set through setTitle and the canvas is not in full screen mode.

The supplied Graphics will be set with an appropriate clip and translated such that (0,0) is the top-left corner of the title bar.

Override this method to change the appearance of the title bar. For example background or logo images can be placed throughout the application by painting them here.

Parameters:
g - is the Graphics object to paint with.
title - is the text for the title bar as defined by the canvas class.
width - is the width of the title bar in pixels.
height - is the height of the title bar in pixels.

paintTitleBarBackground

protected void paintTitleBarBackground(javax.microedition.lcdui.Graphics g,
                                       int x,
                                       int y,
                                       int width,
                                       int height)
Paints the background area of the title bar. The text will be added later by the calling paintTitleBar method.

Parameters:
g - is the Graphics object to paint with.
x - is the top-left X-coordinate pixel of the title bar.
y - is the top-left Y-coordinate pixel of the title bar.
width - is the width of the title bar in pixels.
height - is the height of the title bar in pixels.
See Also:
paintTrackbar(Graphics, int, int, int, int)

getMenuHeight

public int getMenuHeight()
Gets the height of the menu bar in pixels. This method is called whenever the menu is going to be painted.

Returns:
The height of the menu bar in pixels.
See Also:
paintMenuBar(Graphics, String, boolean, String, boolean, int, int)

paintMenuBar

public void paintMenuBar(javax.microedition.lcdui.Graphics g,
                         java.lang.String left,
                         boolean highlightLeft,
                         java.lang.String right,
                         boolean highlightRight,
                         int width,
                         int height)
Paints the menu bar at the bottom of the canvas. This method is not called if the canvas is in full screen mode.

The supplied Graphics will be set with an appropriate clip and translated such that (0,0) is the top-left corner of the title bar.

Override this method to change the appearance or functionality of the menu. Be careful not to write strings that are too long and will not fit on the menu bar.

Parameters:
g - is the Graphics object to paint with.
left - is the text to write on the left side of the menu bar. The left side is associated with dimissing input such as a "Cancel" button.
highlightLeft - is true if the menu text left should be highlighted to indicate the left menu button is currently pressed.
right - is the text to write on the right side of the menu bar. The right side is associated with accepting input such as an "OK" button.
highlightRight - is true if the menu text right should be highlighted to indicate the right menu button is currently pressed.
width - is the width of the menu bar in pixels.
height - is the height of the menu bar in pixels.

paintMenuBarBackground

protected void paintMenuBarBackground(javax.microedition.lcdui.Graphics g,
                                      int x,
                                      int y,
                                      int width,
                                      int height)
Paints the background area of the menu bar. The text will be added later by the calling paintMenuBar method.

Parameters:
g - is the Graphics object to paint with.
x - is the top-left X-coordinate pixel of the menu bar.
y - is the top-left Y-coordinate pixel of the menu bar.
width - is the width of the menu bar in pixels.
height - is the height of the menu bar in pixels.
See Also:
paintMenuBar(Graphics, String, boolean, String, boolean, int, int)

getMenuTextForOK

public java.lang.String getMenuTextForOK()
Gets the localized menu text for OK buttons that appear on forms. By default this is "OK".

Returns:
The text used for the OK button on forms.

getMenuTextForCancel

public java.lang.String getMenuTextForCancel()
Gets the localized menu text for Cancel buttons that appear on forms. By default this is "Cancel".

Returns:
The text used for the Cancel button on forms.

paintBackground

public void paintBackground(javax.microedition.lcdui.Graphics g)
Paints the background of the main section of the screen. This includes everything except for the title bar at the top and menu bar at the bottom. However, if this canvas is in full screen mode, then this method paints the entire screen.

After this method is called, the screen's paintCanvas method will be.

By default this method paints the entire background the color specified by getBackgroundColor. Override this implementation to provide a different background for the entire application, such as an image.

Parameters:
g - is the Graphics object to paint with.

paintVerticalScrollbar

public void paintVerticalScrollbar(javax.microedition.lcdui.Graphics g,
                                   int x,
                                   int y,
                                   int width,
                                   int height,
                                   int offset,
                                   int formHeight)
Paints the vertical scrollbar. The scrollbar must go on the right side of the form and span from the top to the bottom. Its width is returned from this method and used to calculate the width of the remaining form area to draw components in.

Parameters:
g - is the Graphics object to paint with.
x - is the top-left X-coordinate pixel of the form area.
y - is the top-left Y-coordinate pixel of the form area.
width - is the width of the form area in pixels.
height - is the height of the form area in pixels.
offset - is the vertical scrolling position of the top pixel to show on the form area.
formHeight - is the total height of all the components on the form. This is bigger than height.

paintScrollbarBackground

protected void paintScrollbarBackground(javax.microedition.lcdui.Graphics g,
                                        int x,
                                        int y,
                                        int width,
                                        int height)
Paints the background area of the scrollbar. This does not include the trackbar (which will be painted later by paintScrollbarTrackbar).

Parameters:
g - is the Graphics object to paint with.
x - is the top-left X-coordinate pixel of the scrollbar.
y - is the top-left Y-coordinate pixel of the scrollbar.
width - is the width of the scrollbar in pixels.
height - is the height of the scrollbar in pixels.
See Also:
paintVerticalScrollbar(Graphics, int, int, int, int, int, int), paintTrackbar(Graphics, int, int, int, int)

paintTrackbar

protected void paintTrackbar(javax.microedition.lcdui.Graphics g,
                             int x,
                             int y,
                             int width,
                             int height)
Paints the trackbar on the scrollbar. The trackbar is the sliding bit found on the scrollbar that shows the user where the current screen is relative to the scrolling.

Parameters:
g - is the Graphics object to paint with.
x - is the top-left X-coordinate pixel of the trackbar.
y - is the top-left Y-coordinate pixel of the trackbar.
width - is the width of the trackbar in pixels.
height - is the height of the trackbar in pixels.
See Also:
paintVerticalScrollbar(Graphics, int, int, int, int, int, int), paintScrollbarBackground(Graphics, int, int, int, int)

getVerticalScrollbarWidth

public int getVerticalScrollbarWidth()
Returns the width of the vertical scrollbar.

Returns:
The number of pixels wide the scrollbar is.

getScrollbarBorderColor

public int getScrollbarBorderColor()
Returns the color of the border around the scrollbar. Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

By default this is the same as the border color. Override this method to change it.

Returns:
The color of the border around the scrollbar.
See Also:
paintVerticalScrollbar(Graphics, int, int, int, int, int, int)

getScrollbarBackgroundColor

public int getScrollbarBackgroundColor()
Returns the color of the background of the scrollbar. This is the area without the trackbar on it.

By default this is the same as the scrollbar's border color. Override this method to change it.

Returns:
The color of the scrollbar background.
See Also:
paintVerticalScrollbar(Graphics, int, int, int, int, int, int)

getScrollbarHighlightColor

public int getScrollbarHighlightColor()
Returns the highlight color applied as a horizontal gradient to the scrollbar.

Colors are defined as 0xAARRGGBB; the first-byte alpha-channel is ignored.

Override this method to change it.

Returns:
The highlight color of the scrollbar background.
See Also:
getScrollbarBackgroundColor()

getScrollbarTrackbarColor

public int getScrollbarTrackbarColor()
Returns the color of the trackbar within the scrollbar. The trackbar is the block that moves up and down the scrollbar to visually inform the user of where in the scrolling they are.

By default this is the same as the menu bar's background color. Override this method to change it.

Returns:
The color of the scrollbar's trackbar.
See Also:
paintVerticalScrollbar(Graphics, int, int, int, int, int, int)

gradientFill

public static void gradientFill(javax.microedition.lcdui.Graphics g,
                                int x,
                                int y,
                                int width,
                                int height,
                                boolean fillVertically,
                                int primaryColor,
                                int secondaryColor,
                                double maxSecondary)
Fills a rectangle with linear gradient. The gradient colors go from primaryColor to secondaryColor at maxSecondary. So if maxSecondary == 0.70 then a line across the fill rectangle 70% of the way would be secondaryColor.

Parameters:
g - is the Graphics object for painting.
x - is the left edge of the rectangle.
y - is the top edge of the rectangle.
width - is the width of the rectangle.
height - is the height of the rectangle.
fillVertically - is true if the gradient goes from top-to-bottom or false for left-to-right.
primaryColor - is the main color.
secondaryColor - is the highlight color.
maxSecondary - is between 0.00 and 1.00 and says how far down the fill will secondaryColor peak.