fds.micro.ui
Class GraphicItem

java.lang.Object
  extended byfds.micro.ui.Component
      extended byfds.micro.ui.GraphicItem

public class GraphicItem
extends Component

This class implements an component that display a graphic shape.
An object of this class is dedicated to be used within an object of fds.micro.ui.AbstractPanel sub-class (J2ME).

Warning: Use this class only if you want to have control on rendering. If possible, always prefer javax.microedition.lcdui.GraphicItem.

A shape can be ARC, LINE, RECT or ROUND_RECT.

You can read below a typical use within a class that inherit fds.micro.ui.RowPanel:

 ...
 // Draw a half-circle (top part) with a diameter of 30 pixels. 
 this.append(new GraphicItem(GraphicItem.ARC, 30, 30, 0, 180));
 ...

Author:
Frédéric DE STEUR

Field Summary
static int ARC
          To draw an arc.
static int LINE
          To draw a line.
static int RECT
          To draw a rectangle.
static int ROUND_RECT
          To draw a rounded corners rectangle.
 
Fields inherited from class fds.micro.ui.Component
INTERN_BOTTOM_VALIGN, INTERN_CENTER_HALIGN, INTERN_CENTER_VALIGN, INTERN_LEFT_HALIGN, INTERN_RIGHT_HALIGN, INTERN_TOP_VALIGN
 
Constructor Summary
GraphicItem()
          Build a graphic item that will display an horizontal line of 100 pixels.
GraphicItem(int shape, int w, int h)
          Build a graphic item that will display the given shape.
GraphicItem(int shape, int w, int h, boolean filled)
          Build a graphic item that will display the given shape.
GraphicItem(int shape, int w, int h, int alt1, int alt2, boolean filled)
          Build an component that displays the given string.
 
Method Summary
 boolean isFilled()
          Get the filled flag.
 void keyPressed(int keyCode, int gameAction)
          Called to notify the component that a key is pressed.
 void pointerPressed(int xpos, int ypos)
          Called to notify the component that pointer device was pressed.
 void setFilled(boolean filled)
          Set a new value for filled flag.
 void setForeground(int redFore, int greenFore, int blueFore)
          Set the foreground color used to display the text.
 void setMaximumSize(int width, int height)
          Set the maximum size for this component.
 
Methods inherited from class fds.micro.ui.Component
addFocusListener, addItemListener, equals, getHAlign, getHeight, getParent, getVAlign, getWidth, getX, getY, isDisabled, isHaveFocus, isHidden, isManageFocus, isOpaque, removeFocusListener, removeItemListener, setBackground, setDisabled, setFocusColor, setHAlign, setHidden, setLocation, setManageFocus, setOpaque, setVAlign
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARC

public static final int ARC
To draw an arc.

See Also:
Constant Field Values

LINE

public static final int LINE
To draw a line.

See Also:
Constant Field Values

RECT

public static final int RECT
To draw a rectangle.

See Also:
Constant Field Values

ROUND_RECT

public static final int ROUND_RECT
To draw a rounded corners rectangle.

See Also:
Constant Field Values
Constructor Detail

GraphicItem

public GraphicItem()
Build a graphic item that will display an horizontal line of 100 pixels.


GraphicItem

public GraphicItem(int shape,
                   int w,
                   int h)
Build a graphic item that will display the given shape.

Parameters:
shape - The shape to display (Must be ARC, LINE, RECT or ROUND_RECT).
w - The width of the shape.
h - The height of the shape.
Throws:
java.lang.IllegalArgumentException - if shape have an invalid value.

GraphicItem

public GraphicItem(int shape,
                   int w,
                   int h,
                   boolean filled)
Build a graphic item that will display the given shape.

Parameters:
shape - The shape to display (Must be ARC, LINE, RECT or ROUND_RECT).
w - The width of the shape.
h - The height of the shape.
filled - Must be true to fill the shape with foreground color, otherwise only the outline is drawn.
Throws:
java.lang.IllegalArgumentException - if shape have an invalid value.

GraphicItem

public GraphicItem(int shape,
                   int w,
                   int h,
                   int alt1,
                   int alt2,
                   boolean filled)
Build an component that displays the given string.

Parameters:
shape - The shape to display (Must be ARC, LINE, RECT or ROUND_RECT).
w - The width of the shape.
h - The height of the shape.
alt1 - Only used if shape is ARC, LINE or ROUND_RECT:
ARC - The start angle in degrees.
LINE - The direction of ending point on x axis (-1 for left, 1 for right).
ROUND_RECT - the horizontal diameter of the arc at the four corners.
alt2 - Only used if shape is ARC, LINE or ROUND_RECT:
ARC - The arc angle in degrees.
LINE - The direction of ending point on y axis (-1 for up, 1 for down).
ROUND_RECT - the vertical diameter of the arc at the four corners.
filled - Must be true to fill the shape with foreground color, otherwise only the outline is drawn.
Throws:
java.lang.IllegalArgumentException - if shape have an invalid value.
Method Detail

isFilled

public boolean isFilled()
Get the filled flag.

Returns:
Returns true if the shape is filled with foreground color, otherwise false.

keyPressed

public void keyPressed(int keyCode,
                       int gameAction)
Called to notify the component that a key is pressed.

Specified by:
keyPressed in class Component
Parameters:
keyCode - The key code.
gameAction - Game action corresponding to the key code.

pointerPressed

public void pointerPressed(int xpos,
                           int ypos)
Called to notify the component that pointer device was pressed.

Specified by:
pointerPressed in class Component
Parameters:
xpos - The X position of pointer on parent Canvas.
ypos - The Y position of pointer on parent Canvas.

setFilled

public void setFilled(boolean filled)
Set a new value for filled flag.

Parameters:
filled - Must be true to fill the shape with foreground color, otherwise only the outline is drawn.

setForeground

public void setForeground(int redFore,
                          int greenFore,
                          int blueFore)
Set the foreground color used to display the text.

Parameters:
redFore - The red component of the color.
greenFore - The green component of the color.
blueFore - The blue component of the color.

setMaximumSize

public void setMaximumSize(int width,
                           int height)
Set the maximum size for this component.

Overrides:
setMaximumSize in class Component
Parameters:
width - The maximum width.
height - The maximum height.