|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.lcdui.game.LayerManager
Description:
The LayerManager maintains an ordered list to which Layers can be appended, inserted and removed. A Layer’s index correlates to its z-order; the layer at index 0 is closest to the user while a the Layer with the highest index is furthest away from the user. The indicies are always contiguous; that is, if a Layer is removed, the indicies of subsequent Layers will be adjusted to maintain continuity. The LayerManager class provides several features that control how the game’s Layers are rendered on the screen.
The view window controls the size of the visible region and its position relative to the LayerManager’s coordinate system. Changing the position of the view window enables effects such as scrolling or panning the user’s view. For example, to scroll to the right, simply move the view window’s location to the right. The size of the view window controls how large the user’s view will be, and is usually fixed at a size that is appropriate for the device’s screen.
Constructor Summary | |
LayerManager()
Creates a new LayerManager. |
Method Summary | |
void |
append(Layer l)
Appends a Layer to this LayerManager. |
Layer |
getLayerAt(int index)
Gets the Layer with the specified index. |
int |
getSize()
Gets the number of Layers in this LayerManager. |
void |
insert(Layer l,
int index)
Inserts a new Layer in this LayerManager at the specified index. |
void |
paint(Graphics g,
int x,
int y)
Renders the LayerManager’s current view window at the specified location. |
void |
remove(Layer l)
Removes the specified Layer from this LayerManager. |
void |
setViewWindow(int x,
int y,
int width,
int height)
Sets the view window on the LayerManager. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LayerManager()
Method Detail |
public void append(Layer l)
l
- The Layer to be added
java.lang.NullPointerException
- if the Layer l is nullpublic Layer getLayerAt(int index)
index
- The index to search for
java.lang.IndexOutOfBoundsException
- if the specified index is less than zero, or if it is equal to or
greater than the number of Layers added to the this LayerManagerpublic int getSize()
public void insert(Layer l, int index)
l
- The Layer to be insertedindex
- The index at which the new Layer is to be inserted
java.lang.NullPointerException
- if the Layer is null
java.lang.IndexOutOfBoundsException
- if the index is less than 0 or greater than the number of Layers
already added to the this LayerManagerpublic void paint(Graphics g, int x, int y)
The coordinates passed to this method determine where the LayerManager’s view window will be rendered relative to the origin of the Graphics object. For example, a game may use the top of the screen to display the current score, so to render the game’s layers below that area, the view window might be rendered at (0, 20). The location is relative to the Graphics object’s origin, so translating the Graphics object will change where the view window is rendered on the screen.
Rendering is subject to the clip region and translation of the Graphics object. Thus, only part of the speci- fied view window may be rendered if the clip region is not large enough.
g
- Graphics instance on which to draw the LayerManagerx
- The horizontal location at which to render the view window, relative to the Graphics’ originy
- The vertical location at which to render the view window, relative to the Graphics’ origin
java.lang.NullPointerException
- if g is nullpublic void remove(Layer l)
l
- The Layer to be removed
Throws:
java.lang.NullPointerException if the specified Layer is nullpublic void setViewWindow(int x, int y, int width, int height)
The view window stays in effect until it is modified by another call to this method. By default, the view window is set to the screen dimensions and is located at 0,0.
x
- The horizontal location of the view window relative to the LayerManager’s originy
- The vertical location of the view window relative to the LayerManager’s originwidth
- The Width of the view windowheight
- The Height of the view window
java.lang.IllegalArgumentException
- if the width or height is less than 0
|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2006 BenQ Mobile GmbH & Co. OHG or respective copyright owner. All Rights Reserved. BenQ Corp. is a trademark licensee of Siemens AG. |
For further information about Mobility Toolkit (MTK) visit our Developer Portal. |