Source Code Cross Referenced for Tile.java in  » 6.0-JDK-Modules » j2me » com » sun » perseus » j2d » 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 » com.sun.perseus.j2d 
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:        package com.sun.perseus.j2d;
027:
028:        import org.w3c.dom.svg.SVGRect;
029:
030:        /**
031:         * This class is used to represent an area of the viewport.  It supports both
032:         * clipping areas, in viewport coordinates (which is why it uses integers), and
033:         * dirty area management.
034:         *
035:         * @author <a href="mailto:kevin.wong@sun.com">Kevin Wong</a>
036:         * @version $Id: Tile.java,v 1.6 2006/04/21 06:35:19 st125089 Exp $
037:         */
038:        public class Tile {
039:            /**
040:             * Start and end x tile coordinates.
041:             */
042:            public int x, maxX;
043:
044:            /**
045:             * Start and end y tile coordinates.
046:             */
047:            public int y, maxY;
048:
049:            /**
050:             * Default constructor.
051:             */
052:            public Tile() {
053:            }
054:
055:            /**
056:             * Copy constructor
057:             *
058:             * @param t the Tile to copy. Should not be null.
059:             */
060:            public Tile(Tile t) {
061:                this ();
062:                setTile(t);
063:            }
064:
065:            /**
066:             * Constructor with the Tile's coordinates.
067:             *
068:             * @param x the tile's origin along the x-axis
069:             * @param y the tile's origin along the y-axis
070:             * @param width the tile's width
071:             * @param height the tile's height
072:             */
073:            public Tile(int x, int y, int width, int height) {
074:                setTile(x, y, width, height);
075:            }
076:
077:            /**
078:             * Sets the tile's dimension and origin.
079:             *
080:             * @param x the tile's origin along the x-axis
081:             * @param y the tile's origin along the y-axis
082:             * @param width the tile's width
083:             * @param height the tile's height
084:             */
085:            public void setTile(int x, int y, int width, int height) {
086:                this .x = x;
087:                this .y = y;
088:                this .maxX = x + width - 1;
089:                this .maxY = y + height - 1;
090:            }
091:
092:            /**
093:             * Sets this tile to the same x/y/maxX/maxY as t.
094:             *
095:             * @param t the Tile to copy.
096:             */
097:            public void setTile(final Tile t) {
098:                this .x = t.x;
099:                this .y = t.y;
100:                this .maxX = t.maxX;
101:                this .maxY = t.maxY;
102:            }
103:
104:            /**
105:             * Sets this tile to be empty. Actually, this sets the tile to a one pixel tile
106:             * in the top left corner of the integer coordinate grid (i.e, in Integer.MIN_VALUE,
107:             * Integer.MIN_VALUE). This tile will never intersect with any other tile.
108:             */
109:            public void setEmptyTile() {
110:                this .x = Integer.MIN_VALUE;
111:                this .y = Integer.MIN_VALUE;
112:                this .maxX = Integer.MIN_VALUE;
113:                this .maxY = Integer.MIN_VALUE;
114:            }
115:
116:            /**
117:             * Adds the input tile to this tile.
118:             *
119:             * @param tile the Tile to add.
120:             */
121:            public void addTile(final Tile t) {
122:                addTile(t.x, t.y, t.maxX, t.maxY);
123:            }
124:
125:            /**
126:             * Adds the input tile, defined by its x, y, maxX, maxY
127:             * values, to this tile.
128:             *
129:             * @param tx the tile's x-axis origin
130:             * @param ty the tile's y-axis origin
131:             * @param tmaxX the tile's x-axis bottom right coordinate.
132:             * @param tmaxY the tile's y-axis bottom right coordinate.
133:             */
134:            public void addTile(final int tx, final int ty, final int tmaxX,
135:                    final int tmaxY) {
136:                if (tx < x) {
137:                    x = tx;
138:                }
139:                if (ty < y) {
140:                    y = ty;
141:                }
142:                if (tmaxX > maxX) {
143:                    maxX = tmaxX;
144:                }
145:                if (tmaxY > maxY) {
146:                    maxY = tmaxY;
147:                }
148:            }
149:
150:            /**
151:             * Adds the input Box to the tile, after snapping it to the integer grid.
152:             *
153:             * @param b the Box instance to snap to the grid and add to the tile. Should
154:             *        not be null.
155:             */
156:            public void addSnapBox(final Box b) {
157:                b.snap();
158:                addTile((int) b.x, (int) b.y, (int) (b.x + b.width - 1),
159:                        (int) (b.y + b.height - 1));
160:            }
161:
162:            /**
163:             * Sets the tile so that it snaps to the smallest pixel grid which completely
164:             * contains the input Box.
165:             *
166:             * @param b the Box instance to snap to the grid. If null, the tile is set to 
167:             *        have all its values set to Integer.MIN_VALUE.
168:             */
169:            public void snapBox(final Box b) {
170:                if (b == null) {
171:                    x = Integer.MIN_VALUE;
172:                    y = Integer.MIN_VALUE;
173:                    maxX = Integer.MIN_VALUE;
174:                    maxY = Integer.MIN_VALUE;
175:                } else {
176:                    b.snap();
177:                    x = (int) b.x;
178:                    y = (int) b.y;
179:                    maxX = (int) (b.x + b.width - 1);
180:                    maxY = (int) (b.y + b.height - 1);
181:                }
182:
183:            }
184:
185:            /**
186:             * @return true if the tile is hit by the input tile.
187:             * @param t the tile to check. Should not be null.
188:             */
189:            public boolean isHit(final Tile t) {
190:                return (t.maxX >= x) // Leave out tiles to the left of this tile
191:                        && (t.maxY >= y) // Leave out tiles to the top of this tile
192:                        && (t.x <= maxX) // Leave out tiles to the right of this tile
193:                        && (t.y <= maxY); // Leave out tiles to the bottom of this tile
194:            }
195:
196:            /**
197:             * Debug.
198:             */
199:            public String toString() {
200:                return "minX = " + x + " minY = " + y + " maxX = " + maxX
201:                        + " maxY = " + maxY;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.