Java Doc for LayerManager.java in  » 6.0-JDK-Modules » j2me » javax » microedition » lcdui » game » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » javax.microedition.lcdui.game 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.microedition.lcdui.game.LayerManager

LayerManager
public class LayerManager (Code)
The LayerManager manages a series of Layers. The LayerManager simplifies the process of rendering the Layers that have been added to it by automatically rendering the correct regions of each Layer in the appropriate order.

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 indices are always contiguous; that is, if a Layer is removed, the indices 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.

In this example, the view window is set to 85 x 85 pixels and is located at (52, 11) in the LayerManager's coordinate system. The Layers appear at their respective positions relative to the LayerManager's origin.

Specifying the View Window

The LayerManager.paint(Graphics,int,int) method includes an (x,y) location that controls where the view window is rendered relative to the screen. Changing these parameters does not change the contents of the view window, it simply changes the location where the view window is drawn. Note that this location is relative to the origin of the Graphics object, and thus it is subject to the translation attributes of the Graphics object.

For example, if a game uses the top of the screen to display the current score, the view window may be rendered at (17, 17) to provide enough space for the score.

Drawing the View Window




Constructor Summary
public  LayerManager()
     Creates a new LayerManager.

Method Summary
public  voidappend(Layer l)
     Appends a Layer to this LayerManager.
public  LayergetLayerAt(int index)
     Gets the Layer with the specified index.
public  intgetSize()
     Gets the number of Layers in this LayerManager.
public  voidinsert(Layer l, int index)
     Inserts a new Layer in this LayerManager at the specified index.
public  voidpaint(Graphics g, int x, int y)
     Renders the LayerManager's current view window at the specified location.

The LayerManager renders each of its layers in order of descending index, thereby implementing the correct z-order.

public  voidremove(Layer l)
     Removes the specified Layer from this LayerManager.
public  voidsetViewWindow(int x, int y, int width, int height)
     Sets the view window on the LayerManager.

The view window specifies the region that the LayerManager draws when its LayerManager.paint method is called.



Constructor Detail
LayerManager
public LayerManager()(Code)
Creates a new LayerManager.




Method Detail
append
public void append(Layer l)(Code)
Appends a Layer to this LayerManager. The Layer is appended to the list of existing Layers such that it has the highest index (i.e. it is furthest away from the user). The Layer is first removed from this LayerManager if it has already been added.
See Also:   LayerManager.insert(Layer,int)
See Also:   LayerManager.remove(Layer)
Parameters:
  l - the Layer to be added
throws:
  NullPointerException - if the Layer isnull



getLayerAt
public Layer getLayerAt(int index)(Code)
Gets the Layer with the specified index.
Parameters:
  index - the index of the desired Layer the Layer that has the specified index
throws:
  IndexOutOfBoundsException - if the specifiedindex is less thanzero, or if it is equal to or greater than the number of Layers addedto the this LayerManager



getSize
public int getSize()(Code)
Gets the number of Layers in this LayerManager.

the number of Layers




insert
public void insert(Layer l, int index)(Code)
Inserts a new Layer in this LayerManager at the specified index. The Layer is first removed from this LayerManager if it has already been added.
See Also:   LayerManager.append(Layer)
See Also:   LayerManager.remove(Layer)
Parameters:
  l - the Layer to be inserted
Parameters:
  index - the index at which the new Layer isto be inserted
throws:
  NullPointerException - if the Layer isnull
throws:
  IndexOutOfBoundsException - if the index is less than0 orgreater than the number of Layers already added to the this orif the index is greater than the number of Layers already addedto this LayerManager minus one and the Layer has already been addedto this LayerManagerLayerManager



paint
public void paint(Graphics g, int x, int y)(Code)
Renders the LayerManager's current view window at the specified location.

The LayerManager renders each of its layers in order of descending index, thereby implementing the correct z-order. Layers that are completely outside of the view window are not rendered.

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.

The clip region of the Graphics object is intersected with a region having the same dimensions as the view window and located at (x,y). The LayerManager then translates the graphics object such that the point (x,y) corresponds to the location of the viewWindow in the coordinate system of the LayerManager. The Layers are then rendered in the appropriate order. The translation and clip region of the Graphics object are restored to their prior values before this method returns.

Rendering is subject to the clip region and translation of the Graphics object. Thus, only part of the specified view window may be rendered if the clip region is not large enough.

For performance reasons, this method may ignore Layers that are invisible or that would be rendered entirely outside of the Graphics object's clip region. The attributes of the Graphics object are not restored to a known state between calls to the Layers' paint methods. The clip region may extend beyond the bounds of a Layer; it is the responsibility of the Layer to ensure that rendering operations are performed within its bounds.


See Also:   LayerManager.setViewWindow
Parameters:
  g - the graphics instance with which to draw the LayerManager
Parameters:
  x - the horizontal location at which to render the view window,relative to the Graphics' translated origin
Parameters:
  y - the vertical location at which to render the view window,relative to the Graphics' translated origin
throws:
  NullPointerException - if g is null




remove
public void remove(Layer l)(Code)
Removes the specified Layer from this LayerManager. This method does nothing if the specified Layer is not added to the this LayerManager.
See Also:   LayerManager.append(Layer)
See Also:   LayerManager.insert(Layer,int)
Parameters:
  l - the Layer to be removed
throws:
  NullPointerException - if the specified Layer isnull



setViewWindow
public void setViewWindow(int x, int y, int width, int height)(Code)
Sets the view window on the LayerManager.

The view window specifies the region that the LayerManager draws when its LayerManager.paint method is called. It allows the developer to control the size of the visible region, as well as the location of the view window relative to the LayerManager's coordinate system.

The view window stays in effect until it is modified by another call to this method. By default, the view window is located at (0,0) in the LayerManager's coordinate system and its width and height are both set to Integer.MAX_VALUE.
Parameters:
  x - the horizontal location of the view window relative to theLayerManager's origin
Parameters:
  y - the vertical location of the view window relative to theLayerManager's origin
Parameters:
  width - the width of the view window
Parameters:
  height - the height of the view window
throws:
  IllegalArgumentException - if the width orheight is less than 0




Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.