Source Code Cross Referenced for Layer.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 Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package javax.microedition.lcdui.game;
028:
029:        import javax.microedition.lcdui.Image;
030:        import javax.microedition.lcdui.Graphics;
031:
032:        /**
033:         * A Layer is an abstract class representing a visual element of a game. 
034:         * Each Layer has position (in terms of the upper-left corner of its visual 
035:         * bounds), width, height, and can be made visible or invisible.  
036:         * Layer subclasses must implement a {@link #paint(Graphics)} method so that 
037:         * they can be rendered.
038:         * <p>
039:         * The Layer's (x,y) position is always interpreted relative to the coordinate
040:         * system of the Graphics object that is passed to the Layer's paint() method. 
041:         * This coordinate system is referred to as the <em>painter's</em> coordinate 
042:         * system.  The initial location of a Layer is (0,0).
043:         *
044:         * <p>
045:         **/
046:
047:        public abstract class Layer {
048:
049:            /**
050:             * Creates a new Layer with the specified dimensions. 
051:             *
052:             * This constructor is declared package scope to
053:             * prevent developers from creating Layer subclasses
054:             *
055:             * By default, a Layer is visible and its upper-left  
056:             * corner is positioned at (0,0).
057:             * @param width The width of the layer, in pixels 
058:             * @param height The height of the layer, in pixels 
059:             *
060:             */
061:            Layer(int width, int height) {
062:                setWidthImpl(width);
063:                setHeightImpl(height);
064:            }
065:
066:            /**
067:             * Sets this Layer's position such that its upper-left corner
068:             * is located at (x,y) in the painter's coordinate system. 
069:             * A Layer is located at (0,0) by default.
070:             * <br>
071:             * @param x the horizontal position
072:             * @param y the vertical position
073:             * @see #move
074:             * @see #getX
075:             * @see #getY
076:             *
077:             */
078:            public void setPosition(int x, int y) {
079:                this .x = x;
080:                this .y = y;
081:            }
082:
083:            /**
084:             * Moves this Layer by the specified horizontal and vertical distances.  
085:             * <br>
086:             * The Layer's coordinates are subject to wrapping if the passed 
087:             * parameters will cause them to exceed beyond Integer.MAX_VALUE 
088:             * or Integer.MIN_VALUE.
089:             * @param dx the distance to move along horizontal axis (positive
090:             * to the right, negative to the left)
091:             * @param dy the distance to move along vertical axis (positive
092:             * down, negative up)
093:             * @see #setPosition
094:             * @see #getX
095:             * @see #getY
096:             *
097:             */
098:            public void move(int dx, int dy) {
099:                x += dx;
100:                y += dy;
101:            }
102:
103:            /**
104:             * Gets the horizontal position of this Layer's upper-left corner
105:             * in the painter's coordinate system.
106:             * <p>
107:             * @return the Layer's horizontal position.
108:             * @see #getY
109:             * @see #setPosition
110:             * @see #move
111:             *
112:             */
113:            public final int getX() {
114:                return x;
115:            }
116:
117:            /**
118:             * Gets the vertical position of this Layer's upper-left corner
119:             * in the painter's coordinate system.
120:             * <p>
121:             * @return the Layer's vertical position.
122:             * @see #getX
123:             * @see #setPosition
124:             * @see #move
125:             *
126:             */
127:            public final int getY() {
128:                return y;
129:            }
130:
131:            /**
132:             * Gets the current width of this layer, in pixels.
133:             * @return the width in pixels
134:             * @see #getHeight
135:             *
136:             **/
137:            public final int getWidth() {
138:                return width;
139:            }
140:
141:            /**
142:             * Gets the current height of this layer, in pixels.
143:             * @return the height in pixels
144:             * @see #getWidth
145:             *
146:             **/
147:            public final int getHeight() {
148:                return height;
149:            }
150:
151:            /**
152:             * Sets the visibility of this Layer.  A visible Layer is rendered when
153:             * its {@link #paint(Graphics)} method is called; an invisible Layer is
154:             * not rendered.
155:             * @param visible <code>true</code> to make the <code>Layer</code> visible, 
156:             * <code>false</code> to make it invisible
157:             * @see #isVisible
158:             *
159:             */
160:            public void setVisible(boolean visible) {
161:                this .visible = visible;
162:            }
163:
164:            /**
165:             * Gets the visibility of this Layer.
166:             * @return <code>true</code> if the <code>Layer</code> is visible,
167:             * <code>false</code> if it is invisible.
168:             * @see #setVisible
169:             *
170:             */
171:            public final boolean isVisible() {
172:                return visible;
173:            }
174:
175:            /**
176:             * Paints this Layer if it is visible.  The upper-left corner of the Layer
177:             * is rendered at it's current (x,y) position relative to the origin of
178:             * the provided Graphics object.  Applications may make use of Graphics
179:             * clipping and translation to control where the Layer is rendered and to
180:             * limit the region that is rendered.
181:             * <P>
182:             * Implementations of this method are responsible for checking if this
183:             * Layer is visible; this method does nothing if the Layer is not
184:             * visible.
185:             * <p>
186:             * The attributes of the Graphics object (clip region, translation, 
187:             * drawing color, etc.) are not modified as a result of calling this
188:             * method.
189:             *
190:             * @param g the graphics object for rendering the <code>Layer</code>
191:             * @throws NullPointerException if <code>g</code> is <code>null</code>
192:             */
193:            public abstract void paint(Graphics g);
194:
195:            /**
196:             * Sets the current width of this layer, in pixels.  The Layer's width is
197:             * used to determine its bounds for rendering purposes.
198:             * @param width The width in pixels
199:             * @throws IllegalArgumentException if the specified width is less than 0
200:             * @see #setHeightImpl
201:             * @see #getHeight
202:             * @see #getWidth
203:             *
204:             **/
205:            void setWidthImpl(int width) {
206:                if (width < 0) {
207:                    throw new IllegalArgumentException();
208:                }
209:                this .width = width;
210:            }
211:
212:            /**
213:             * Sets the current height of this layer, in pixels.  The Layer's height
214:             * is used to determine its bounds for rendering purposes.
215:             * @param height The height in pixels
216:             * @throws IllegalArgumentException if the specified height is less than 0
217:             * @see #setWidthImpl
218:             * @see #getHeight
219:             * @see #getWidth
220:             *
221:             **/
222:            void setHeightImpl(int height) {
223:                if (height < 0) {
224:                    throw new IllegalArgumentException();
225:                }
226:                this .height = height;
227:            }
228:
229:            /**
230:             * position of layer in x offset 
231:             */
232:            int x; // = 0;
233:
234:            /**
235:             * position of layer in y offset 
236:             */
237:            int y; // = 0;
238:
239:            /**
240:             * width of layer 
241:             */
242:            int width; // = 0;
243:
244:            /**
245:             * height of layer
246:             */
247:            int height; // = 0;
248:
249:            /** 
250:             * If the Layer is visible it will be drawn when <code>paint</code>
251:             * is called.
252:             */
253:            boolean visible = true;
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.