com.incrediblesoft.redjey
Class Component

java.lang.Object
  extended by com.incrediblesoft.redjey.Component
Direct Known Subclasses:
Container, ImageItem, TextComponent

public abstract class Component
extends java.lang.Object


Field Summary
static int BOTTOM_LAYOUT
           
static int DISABLED
           
static int H_EXPAND
          Set this flag to say layout manager that this component is willing to have max available width;
static int HCENTER_LAYOUT
           
static int HIGHLIGHTED
           
static int LEFT_LAYOUT
          Layout constants
static int NORMAL
          Predefined component states
static int PRESSED
           
static int RIGHT_LAYOUT
           
static int TOP_LAYOUT
           
static int TOTAL_STATES
           
static int V_EXPAND
          Set this flag to say layout manager that this component is willing to have max available height; Not implemented yet.
static int VCENTER_LAYOUT
           
 
Constructor Summary
Component()
          Constructs component
Component(java.lang.String styleClassName)
          Constructs component with a given style class
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds action listener to this component.
 void addMouseListener(MouseListener listener)
          Adds mouse listener to this component.
 void dispatchEvent(AbstractEvent event)
          Dispatches event to children
 void fireActionEvent()
          Generates and dispatched ActionEvent to listeners
 Rectangle getAbsoluteRect()
           
 int getAbsoluteX()
          Returns X-coordinate in device's screen coordinate system
 int getAbsoluteY()
          Returns Y-coordinate in device's screen coordinate system
 int getAlignment()
          Returns component alignment hints
 Rectangle getBounds()
           
 Dimension getClientSize()
          Returns client's area dimension
 int getContentAlignment()
          Returns content alignment hints
 Style getCurrentStyle()
          Returns current active style
 int getHeight()
          Returns the height of component
abstract  java.lang.String getName()
          This method is used to retrieve the appropriate style set from a hashtable of styles
 Component getParent()
          Returns component's parent
 Dimension getPreferredSize()
          Returns preferred size.
 int getState()
          Returns current state
 Style getStyle(int state)
          Returns style associated with a given component's state
 Style[] getStyleClass()
          Returns the current set of styles.
 int getWidth()
          Returns the width of component
 int getX()
           
 int getY()
           
 void invalidate()
          Reset validation flag.
 void invalidateTree()
          Invalidates all component tree hierarchy
 boolean isFocused()
          Returns the focus state of component
 boolean isHighlightable()
          Returns true if this component can be highlighted
 boolean isVisible()
          Returns weather component is visible or not
 boolean keyPressed(int keycode)
          Is not realized yet
 boolean keyReleased(int keycode)
          Is not realized yet
 void paint(javax.microedition.lcdui.Graphics g)
          Paints component.
 void removeActonListener(ActionListener listener)
          Removes action listener from this component.
 void removeMouseListener(MouseListener listener)
          Removes mouse listener from this component.
 void repaint()
          Causes application triggered repaint request
 void repaint(int x, int y, int width, int height)
          Dispatched repaint request
 Component setAlignment(int anchor)
          Sets component alignment hints.
 void setBounds(int x, int y, int width, int height)
           
 void setContentAlignment(int anchor)
          Sets content alignment hints.
 void setLocation(int x, int y)
          Sets component location relative to parent's coordinates.
 void setPreferredSize(Dimension dim)
          Sets the predefined preferred dimensions.
 void setSize(Dimension size)
          Sets the size of component
 void setSize(int width, int height)
          Sets the size of component
 void setState(int state)
          Sets component state (NORMAL, FOCUSED, DISABLED or custom one).
 void setStyle(Style style)
           
 void setStyle(Style style, int state)
          Sets the style that will represent some state of component
 void setStyleClass(java.lang.String className)
          Sets the set of styles of the corresponding class.
 void setTag(java.lang.String tag)
          Assigns text label to component, to retrieve later from toString() method.
 void setVisible(boolean visible)
          Set this component visible or not
 void setX(int x)
           
 void setY(int y)
           
 void tick(int dt)
          Called every tick.
 java.lang.String toString()
           
 void validate()
          Validate component
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT_LAYOUT

public static final int LEFT_LAYOUT
Layout constants

See Also:
Constant Field Values

RIGHT_LAYOUT

public static final int RIGHT_LAYOUT
See Also:
Constant Field Values

TOP_LAYOUT

public static final int TOP_LAYOUT
See Also:
Constant Field Values

BOTTOM_LAYOUT

public static final int BOTTOM_LAYOUT
See Also:
Constant Field Values

HCENTER_LAYOUT

public static final int HCENTER_LAYOUT
See Also:
Constant Field Values

VCENTER_LAYOUT

public static final int VCENTER_LAYOUT
See Also:
Constant Field Values

H_EXPAND

public static final int H_EXPAND
Set this flag to say layout manager that this component is willing to have max available width;

See Also:
Constant Field Values

V_EXPAND

public static final int V_EXPAND
Set this flag to say layout manager that this component is willing to have max available height; Not implemented yet.

See Also:
Constant Field Values

NORMAL

public static final int NORMAL
Predefined component states

See Also:
Constant Field Values

HIGHLIGHTED

public static final int HIGHLIGHTED
See Also:
Constant Field Values

PRESSED

public static final int PRESSED
See Also:
Constant Field Values

DISABLED

public static final int DISABLED
See Also:
Constant Field Values

TOTAL_STATES

public static final int TOTAL_STATES
See Also:
Constant Field Values
Constructor Detail

Component

public Component()
Constructs component


Component

public Component(java.lang.String styleClassName)
Constructs component with a given style class

Parameters:
styleClassName - style class
Method Detail

getName

public abstract java.lang.String getName()
This method is used to retrieve the appropriate style set from a hashtable of styles

Returns:
Name of component

getParent

public Component getParent()
Returns component's parent

Returns:
parent component

isHighlightable

public boolean isHighlightable()
Returns true if this component can be highlighted

Returns:
true/false

getWidth

public int getWidth()
Returns the width of component

Returns:
width

getHeight

public int getHeight()
Returns the height of component

Returns:
height

setSize

public void setSize(Dimension size)
Sets the size of component

Parameters:
size - new size

setSize

public void setSize(int width,
                    int height)
Sets the size of component

Parameters:
width - width
height - height

setLocation

public void setLocation(int x,
                        int y)
Sets component location relative to parent's coordinates.

Parameters:
x - x
y - y

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)

setX

public void setX(int x)

setY

public void setY(int y)

getX

public int getX()

getY

public int getY()

getAbsoluteX

public int getAbsoluteX()
Returns X-coordinate in device's screen coordinate system

Returns:
X-coordinate

getAbsoluteY

public int getAbsoluteY()
Returns Y-coordinate in device's screen coordinate system

Returns:
Y-coordinate

getBounds

public Rectangle getBounds()

getAbsoluteRect

public Rectangle getAbsoluteRect()

getClientSize

public Dimension getClientSize()
Returns client's area dimension

Returns:
Dimension

getPreferredSize

public Dimension getPreferredSize()
Returns preferred size. Preferred size is used by Layout managers

Returns:
Dimension

setPreferredSize

public void setPreferredSize(Dimension dim)
Sets the predefined preferred dimensions.

Parameters:
dim - Dimension

setAlignment

public Component setAlignment(int anchor)
Sets component alignment hints. Used by Layout managers. These hints say how to layout component.

Parameters:
anchor - See *_LAYOUT constants

getAlignment

public int getAlignment()
Returns component alignment hints

Returns:
Alignment hints

setContentAlignment

public void setContentAlignment(int anchor)
Sets content alignment hints. These hints say paint() method how to draw content within component client area if its size is bigger then preffered one.

Parameters:
anchor - See *_LAYOUT constants

getContentAlignment

public int getContentAlignment()
Returns content alignment hints

Returns:
Alignment hints

setState

public void setState(int state)
Sets component state (NORMAL, FOCUSED, DISABLED or custom one). It is also changes appearance styles.

Parameters:
state - Component state index

getState

public int getState()
Returns current state

Returns:
state

getStyleClass

public Style[] getStyleClass()
Returns the current set of styles.

Returns:
Set of styles

setStyleClass

public void setStyleClass(java.lang.String className)
Sets the set of styles of the corresponding class.

Parameters:
className - The name of style class.

setStyle

public void setStyle(Style style)

setStyle

public void setStyle(Style style,
                     int state)
Sets the style that will represent some state of component

Parameters:
style - style to set
state - state to represent

getCurrentStyle

public Style getCurrentStyle()
Returns current active style

Returns:
style

getStyle

public Style getStyle(int state)
Returns style associated with a given component's state

Parameters:
state - component state
Returns:
style

setVisible

public void setVisible(boolean visible)
Set this component visible or not

Parameters:
visible - true / false

isVisible

public boolean isVisible()
Returns weather component is visible or not

Returns:
true / false

keyPressed

public boolean keyPressed(int keycode)
Is not realized yet

Parameters:
keycode -
Returns:

keyReleased

public boolean keyReleased(int keycode)
Is not realized yet

Parameters:
keycode -
Returns:

dispatchEvent

public void dispatchEvent(AbstractEvent event)
Dispatches event to children

Parameters:
event -

fireActionEvent

public void fireActionEvent()
Generates and dispatched ActionEvent to listeners


isFocused

public boolean isFocused()
Returns the focus state of component

Returns:
true if component is focused, false otherwise

invalidate

public void invalidate()
Reset validation flag. This means that component needs to be validated again.


invalidateTree

public void invalidateTree()
Invalidates all component tree hierarchy


validate

public void validate()
Validate component


addActionListener

public void addActionListener(ActionListener listener)
Adds action listener to this component.

Parameters:
listener - action listener

removeActonListener

public void removeActonListener(ActionListener listener)
Removes action listener from this component.

Parameters:
listener - action listener

addMouseListener

public void addMouseListener(MouseListener listener)
Adds mouse listener to this component.

Parameters:
listener - mouse listener

removeMouseListener

public void removeMouseListener(MouseListener listener)
Removes mouse listener from this component.

Parameters:
listener - mouse listener

tick

public void tick(int dt)
Called every tick. Subclasses must override this method to do custom actions that depend on real time.

Parameters:
dt - time in milliseconds

paint

public void paint(javax.microedition.lcdui.Graphics g)
Paints component.

Parameters:
g - Graphics object

repaint

public void repaint()
Causes application triggered repaint request


repaint

public void repaint(int x,
                    int y,
                    int width,
                    int height)
Dispatched repaint request

Parameters:
x - area x
y - area y
width - area width
height - area height

setTag

public void setTag(java.lang.String tag)
Assigns text label to component, to retrieve later from toString() method. Used for debugging purposes only.

Parameters:
tag - String label

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object