Source Code Cross Referenced for Point.java in  » 6.0-JDK-Modules » j2me » java » awt » 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 » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)Point.java	1.23 06/10/10
003:         *
004:         * Copyright  1990-2006 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 java.awt;
028:
029:        /**
030:         * The <code>Point</code> class represents a location in a
031:         * two-dimensional (<i>x</i>,&nbsp;<i>y</i>) coordinate space.
032:         *
033:         * @version 	1.18, 08/19/02
034:         * @author 	Sami Shaio
035:         * @since       JDK1.0
036:         */
037:        public class Point implements  java.io.Serializable, Cloneable {
038:            /**
039:             * The <i>x</i> coordinate. 
040:             * @since   JDK1.0
041:             */
042:            public int x;
043:            /**
044:             * The <i>y</i> coordinate. 
045:             * @since   JDK1.0
046:             */
047:            public int y;
048:            /*
049:             * JDK 1.1 serialVersionUID 
050:             */
051:            private static final long serialVersionUID = -5276940640259749850L;
052:
053:            /**
054:             * Constructs and initializes a point at the origin 
055:             * (0,&nbsp;0) of the coordinate space. 
056:             * @param       x   the <i>x</i> coordinate.
057:             * @param       y   the <i>y</i> coordinate.
058:             * @since       JDK1.1
059:             */
060:            public Point() {
061:                this (0, 0);
062:            }
063:
064:            /**
065:             * Constructs and initializes a point with the same location as
066:             * the specified <code>Point</code> object.
067:             * @param       p a point.
068:             * @since       JDK1.1
069:             */
070:            public Point(Point p) {
071:                this (p.x, p.y);
072:            }
073:
074:            /**
075:             * Constructs and initializes a point at the specified 
076:             * (<i>x</i>,&nbsp;<i>y</i>) location in the coordinate space. 
077:             * @param       x   the <i>x</i> coordinate.
078:             * @param       y   the <i>y</i> coordinate.
079:             * @since       JDK1.0
080:             */
081:            public Point(int x, int y) {
082:                this .x = x;
083:                this .y = y;
084:            }
085:
086:            /**
087:             * Returns the location of this point.
088:             * This method is included for completeness, to parallel the
089:             * <code>getLocation</code> method of <code>Component</code>.
090:             * @return      a copy of this point, at the same location.
091:             * @see         java.awt.Component#getLocation
092:             * @see         java.awt.Point#setLocation(java.awt.Point)
093:             * @see         java.awt.Point#setLocation(int, int)
094:             * @since       JDK1.1
095:             */
096:            public Point getLocation() {
097:                return new Point(x, y);
098:            }
099:
100:            /**
101:             * Sets the location of the point to the specificed location.
102:             * This method is included for completeness, to parallel the
103:             * <code>setLocation</code> method of <code>Component</code>.
104:             * @param       p  a point, the new location for this point.
105:             * @see         java.awt.Component#setLocation(java.awt.Point)
106:             * @see         java.awt.Point#getLocation
107:             * @since       JDK1.1
108:             */
109:            public void setLocation(Point p) {
110:                setLocation(p.x, p.y);
111:            }
112:
113:            /**
114:             * Changes the point to have the specificed location.
115:             * <p>
116:             * This method is included for completeness, to parallel the
117:             * <code>setLocation</code> method of <code>Component</code>.
118:             * Its behavior is identical with <code>move(int,&nbsp;int)</code>.
119:             * @param       x  the <i>x</i> coordinate of the new location.
120:             * @param       y  the <i>y</i> coordinate of the new location.
121:             * @see         java.awt.Component#setLocation(int, int)
122:             * @see         java.awt.Point#getLocation
123:             * @see         java.awt.Point#move(int, int)
124:             * @since       JDK1.1
125:             */
126:            public void setLocation(int x, int y) {
127:                move(x, y);
128:            }
129:
130:            /**
131:             * Moves this point to the specificed location in the 
132:             * (<i>x</i>,&nbsp;<i>y</i>) coordinate plane. This method
133:             * is identical with <code>setLocation(int,&nbsp;int)</code>.
134:             * @param       x  the <i>x</i> coordinate of the new location.
135:             * @param       y  the <i>y</i> coordinate of the new location.
136:             * @see         java.awt.Component#setLocation(int, int)
137:             * @since       JDK1.0
138:             */
139:            public void move(int x, int y) {
140:                this .x = x;
141:                this .y = y;
142:            }
143:
144:            /**
145:             * Translates this point, at location (<i>x</i>,&nbsp;<i>y</i>), 
146:             * by <code>dx</code> along the <i>x</i> axis and <code>dy</code> 
147:             * along the <i>y</i> axis so that it now represents the point 
148:             * (<code>x</code>&nbsp;<code>+</code>&nbsp;<code>dx</code>, 
149:             * <code>y</code>&nbsp;<code>+</code>&nbsp;<code>dy</code>). 
150:             * @param       dx   the distance to move this point 
151:             *                            along the <i>x</i> axis.
152:             * @param       dy    the distance to move this point 
153:             *                            along the <i>y</i> axis.
154:             * @since       JDK1.0
155:             */
156:            public void translate(int x, int y) {
157:                this .x += x;
158:                this .y += y;
159:            }
160:
161:            /**
162:             * Returns the hashcode for this point.
163:             * @return      a hash code for this point.
164:             * @since       JDK1.0
165:             */
166:            public int hashCode() {
167:                return x ^ (y * 31);
168:            }
169:
170:            /**
171:             * Determines whether two points are equal. Two instances of
172:             * <code>Point</code> are equal if the values of their 
173:             * <code>x</code> and <code>y</code> member fields, representing
174:             * their position in the coordinate space, are the same.
175:             * @param      obj   an object to be compared with this point.
176:             * @return     <code>true</code> if the object to be compared is
177:             *                     an instance of <code>Point</code> and has
178:             *                     the same values; <code>false</code> otherwise.
179:             * @since      JDK1.0
180:             */
181:            public boolean equals(Object obj) {
182:                if (obj instanceof  Point) {
183:                    Point pt = (Point) obj;
184:                    return (x == pt.x) && (y == pt.y);
185:                }
186:                return false;
187:            }
188:
189:            /**
190:             * Returns a representation of this point and its location
191:             * in the (<i>x</i>,&nbsp;<i>y</i>) coordinate space as a string.
192:             * @return    a string representation of this point, 
193:             *                 including the values of its member fields.
194:             * @since     JDK1.0
195:             */
196:            public String toString() {
197:                return getClass().getName() + "[x=" + x + ",y=" + y + "]";
198:            }
199:
200:            /**
201:             * Creates a new object of the same class and with the
202:             * same contents as this object.
203:             * @return     a clone of this instance.
204:             * @exception  OutOfMemoryError            if there is not enough memory.
205:             * @see        java.lang.Cloneable
206:             * @since      1.2
207:             */
208:            public Object clone() {
209:                try {
210:                    return super .clone();
211:                } catch (CloneNotSupportedException e) {
212:                    // this shouldn't happen, since we are Cloneable
213:                    throw new InternalError();
214:                }
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.