|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.lcdui.game.Layer
A Layer is an abstract class representing a visual element of a game.
Each Layer has position (in terms of the upper-left corner of its visual
bounds), width, height, and can be made visible or invisible.
Layer subclasses must implement a paint(Graphics)
method so that
they can be rendered.
The Layer's (x,y) position is always interpreted relative to the coordinate system of the Graphics object that is passed to the Layer's paint() method. This coordinate system is referred to as the painter's coordinate system. The initial location of a Layer is (0,0).
Method Summary | |
int |
getHeight()
Gets the current height of this layer, in pixels. |
int |
getWidth()
Gets the current width of this layer, in pixels. |
int |
getX()
Gets the horizontal position of this Layer's upper-left corner in the painter's coordinate system. |
int |
getY()
Gets the vertical position of this Layer's upper-left corner in the painter's coordinate system. |
boolean |
isVisible()
Gets the visibility of this Layer. |
void |
move(int dx,
int dy)
Moves this Layer by the specified horizontal and vertical distances. |
abstract void |
paint(Graphics g)
Paints this Layer if it is visible. |
void |
setPosition(int x,
int y)
Sets this Layer's position such that its upper-left corner is located at (x,y) in the painter's coordinate system. |
void |
setVisible(boolean visible)
Sets the visibility of this Layer. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void setPosition(int x, int y)
x
- the horizontal positiony
- the vertical positionmove(int, int)
,
getX()
,
getY()
public void move(int dx, int dy)
dx
- the distance to move along horizontal axis (positive
to the right, negative to the left)dy
- the distance to move along vertical axis (positive
down, negative up)setPosition(int, int)
,
getX()
,
getY()
public final int getX()
getY()
,
setPosition(int, int)
,
move(int, int)
public final int getY()
getX()
,
setPosition(int, int)
,
move(int, int)
public final int getWidth()
getHeight()
public final int getHeight()
getWidth()
public void setVisible(boolean visible)
paint(Graphics)
method is called; an invisible Layer is
not rendered.visible
- true
to make the Layer
visible,
false
to make it invisibleisVisible()
public final boolean isVisible()
true
if the Layer
is visible,
false
if it is invisible.setVisible(boolean)
public abstract void paint(Graphics g)
Implementations of this method are responsible for checking if this Layer is visible; this method does nothing if the Layer is not visible.
The attributes of the Graphics object (clip region, translation, drawing color, etc.) are not modified as a result of calling this method.
g
- the graphics object for rendering the Layer
NullPointerException
- if g
is null
|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |