example.chooser
Class ColorChooser

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by example.chooser.ColorChooser

public class ColorChooser
extends javax.microedition.lcdui.Canvas

A Color chooser. This screen can be used to display and choose colors. The current color is always available via the getColor and getGrayScale methods. It can be set with setColor. A palette provides some reuse of colors, the current index in the palette can get set and retrieved. When the chooser is active the user may set the index in the palette, and change the red, green, and blue components. The application using the chooser must add commands to the chooser as appropriate to terminate selection and to change to other screens. The chooser adapts to the available screen size and font sizes.


Field Summary
(package private) static int BORDER
           
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
ColorChooser(boolean isColor, int numColors)
           
 
Method Summary
 int getBlueComponent()
          Gets the blue component of the current color.
 int getColor()
          Gets the current color.
 int getDelta()
          Get the delta used to increment/decrement.
 int getGrayScale()
           
 int getGreenComponent()
          Gets the green component of the current color.
 int getPaletteIndex()
          Get the current palette index.
 int getRadix()
          Get the radix used to display numbers.
 int getRedComponent()
          Gets the red component of the current color.
protected  void keyPressed(int key)
           
 void keyRepeated(int key)
           
protected  void paint(javax.microedition.lcdui.Graphics g)
           
 void setColor(int RGB)
          Sets the current color to the specified RGB values.
 void setColor(int red, int green, int blue)
          Sets the current color to the specified RGB values.
 void setDelta(int delta)
          Set the delta used to increment/decrement.
 void setGrayScale(int value)
          Sets the current grayscale.
 boolean setPaletteIndex(int index)
          Select which entry in the Palette to use for the current color.
 void setRadix(int rad)
          Set the radix used to display numbers.
protected  void showNotify()
          The canvas is being displayed.
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyReleased, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BORDER

static final int BORDER
See Also:
Constant Field Values
Constructor Detail

ColorChooser

public ColorChooser(boolean isColor,
                    int numColors)
Method Detail

setPaletteIndex

public boolean setPaletteIndex(int index)
Select which entry in the Palette to use for the current color.

Parameters:
index - index into the palette; 0..10.

getPaletteIndex

public int getPaletteIndex()
Get the current palette index.

Returns:
the current index in the palette.

setColor

public void setColor(int red,
                     int green,
                     int blue)
Sets the current color to the specified RGB values.

Parameters:
red - The red component of the color being set in range 0-255.
green - The green component of the color being set in range 0-255.
blue - The blue component of the color being set in range 0-255.

setColor

public void setColor(int RGB)
Sets the current color to the specified RGB values. All subsequent rendering operations will use this specified color. The RGB value passed in is interpreted with the least significant eight bits giving the blue component, the next eight more significant bits giving the green component, and the next eight more significant bits giving the red component. That is to say, the color component is specified like 0x00RRGGBB.

Parameters:
RGB - The color being set.

getColor

public int getColor()
Gets the current color.

Returns:
an integer in form 0x00RRGGBB
See Also:
setColor(int, int, int)

getRedComponent

public int getRedComponent()
Gets the red component of the current color.

Returns:
integer value in range 0-255
See Also:
setColor(int, int, int)

getGreenComponent

public int getGreenComponent()
Gets the green component of the current color.

Returns:
integer value in range 0-255
See Also:
setColor(int, int, int)

getBlueComponent

public int getBlueComponent()
Gets the blue component of the current color.

Returns:
integer value in range 0-255
See Also:
setColor(int, int, int)

getGrayScale

public int getGrayScale()

setGrayScale

public void setGrayScale(int value)
Sets the current grayscale. For color the value is used to set each component.

Parameters:
value - - the value in range 0-255

showNotify

protected void showNotify()
The canvas is being displayed. Compute the relative placement of items the depend on the screen size.

Overrides:
showNotify in class javax.microedition.lcdui.Canvas

paint

protected void paint(javax.microedition.lcdui.Graphics g)
Specified by:
paint in class javax.microedition.lcdui.Canvas

setRadix

public void setRadix(int rad)
Set the radix used to display numbers. The default is decimal (10).


getRadix

public int getRadix()
Get the radix used to display numbers.


setDelta

public void setDelta(int delta)
Set the delta used to increment/decrement. The default is 32.


getDelta

public int getDelta()
Get the delta used to increment/decrement.


keyRepeated

public void keyRepeated(int key)
Overrides:
keyRepeated in class javax.microedition.lcdui.Canvas

keyPressed

protected void keyPressed(int key)
Overrides:
keyPressed in class javax.microedition.lcdui.Canvas