Source Code Cross Referenced for Point.java in  » Scripting » hecl » org » 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 » Scripting » hecl » org.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005, 2006 data2c GmbH (www.data2c.com)
003:         *
004:         * Author: Wolfgang S. Kechel - wolfgang.kechel@data2c.com
005:         * 
006:         * J2ME version of java.awt.Point.
007:         */
008:
009:        package org.awt;
010:
011:        //#ifndef j2se
012:        import org.awt.geom.Point2D;
013:
014:        public class Point extends Point2D {
015:            /**
016:             * The <i>x</i> coordinate.
017:             * If no <i>x</i> coordinate is set it will default to 0.
018:             *
019:             * @serial
020:             * @see #getLocation()
021:             * @see #move(int, int)
022:             */
023:            public int x;
024:
025:            /**
026:             * The <i>y</i> coordinate. 
027:             * If no <i>y</i> coordinate is set it will default to 0.
028:             *
029:             * @serial
030:             * @see #getLocation()
031:             * @see #move(int, int)
032:             */
033:            public int y;
034:
035:            /**
036:             * Constructs and initializes a point at the origin 
037:             * (0,&nbsp;0) of the coordinate space. 
038:             */
039:            public Point() {
040:                this (0, 0);
041:            }
042:
043:            /**
044:             * Constructs and initializes a point with the same location as
045:             * the specified <code>Point</code> object.
046:             * @param       p a point
047:             */
048:            public Point(Point p) {
049:                this (p.x, p.y);
050:            }
051:
052:            /**
053:             * Constructs and initializes a point at the specified 
054:             * (<i>x</i>,&nbsp;<i>y</i>) location in the coordinate space. 
055:             * @param       x   the <i>x</i> coordinate
056:             * @param       y   the <i>y</i> coordinate
057:             */
058:            public Point(int x, int y) {
059:                this .x = x;
060:                this .y = y;
061:            }
062:
063:            public Object clone() /*throws CloneNotSupportedException*/{
064:                return new Point(x, y);
065:            }
066:
067:            /**
068:             * Returns the X coordinate of the point in double precision.
069:             * @return the X coordinate of the point in double precision
070:             */
071:            public double getX() {
072:                return x;
073:            }
074:
075:            /**
076:             * Returns the Y coordinate of the point in double precision.
077:             * @return the Y coordinate of the point in double precision
078:             */
079:            public double getY() {
080:                return y;
081:            }
082:
083:            /**
084:             * Returns the location of this point.
085:             * This method is included for completeness, to parallel the
086:             * <code>getLocation</code> method of <code>Component</code>.
087:             * @return      a copy of this point, at the same location
088:             */
089:            public Point getLocation() {
090:                return new Point(x, y);
091:            }
092:
093:            /**
094:             * Sets the location of the point to the specified location.
095:             * This method is included for completeness, to parallel the
096:             * <code>setLocation</code> method of <code>Component</code>.
097:             * @param       p  a point, the new location for this point
098:             */
099:            public void setLocation(Point p) {
100:                setLocation(p.x, p.y);
101:            }
102:
103:            /**
104:             * Changes the point to have the specified location.
105:             * <p>
106:             * This method is included for completeness, to parallel the
107:             * <code>setLocation</code> method of <code>Component</code>.
108:             * Its behavior is identical with <code>move(int,&nbsp;int)</code>.
109:             * @param       x  the <i>x</i> coordinate of the new location
110:             * @param       y  the <i>y</i> coordinate of the new location
111:             */
112:            public void setLocation(int x, int y) {
113:                move(x, y);
114:            }
115:
116:            /**
117:             * Sets the location of this point to the specified double coordinates.
118:             * The double values will be rounded to integer values.
119:             * Any number smaller than <code>Integer.MIN_VALUE</code>
120:             * will be reset to <code>MIN_VALUE</code>, and any number
121:             * larger than <code>Integer.MAX_VALUE</code> will be
122:             * reset to <code>MAX_VALUE</code>.
123:             *
124:             * @param x the <i>x</i> coordinate of the new location
125:             * @param y the <i>y</i> coordinate of the new location
126:             * @see #getLocation
127:             */
128:            public void setLocation(double x, double y) {
129:                this .x = (int) Math.floor(x + 0.5);
130:                this .y = (int) Math.floor(y + 0.5);
131:            }
132:
133:            /**
134:             * Moves this point to the specified location in the 
135:             * (<i>x</i>,&nbsp;<i>y</i>) coordinate plane. This method
136:             * is identical with <code>setLocation(int,&nbsp;int)</code>.
137:             * @param       x  the <i>x</i> coordinate of the new location
138:             * @param       y  the <i>y</i> coordinate of the new location
139:             */
140:            public void move(int x, int y) {
141:                this .x = x;
142:                this .y = y;
143:            }
144:
145:            /**
146:             * Translates this point, at location (<i>x</i>,&nbsp;<i>y</i>), 
147:             * by <code>dx</code> along the <i>x</i> axis and <code>dy</code> 
148:             * along the <i>y</i> axis so that it now represents the point 
149:             * (<code>x</code>&nbsp;<code>+</code>&nbsp;<code>dx</code>, 
150:             * <code>y</code>&nbsp;<code>+</code>&nbsp;<code>dy</code>). 
151:             * @param       dx   the distance to move this point 
152:             *                            along the <i>x</i> axis
153:             * @param       dy    the distance to move this point 
154:             *                            along the <i>y</i> axis
155:             */
156:            public void translate(int dx, int dy) {
157:                this .x += dx;
158:                this .y += dy;
159:            }
160:
161:            /**
162:             * Determines whether or not two points are equal. Two instances of
163:             * <code>Point</code> are equal if the values of their 
164:             * <code>x</code> and <code>y</code> member fields, representing
165:             * their position in the coordinate space, are the same.
166:             * @param obj an object to be compared with this <code>Point</code>
167:             * @return <code>true</code> if the object to be compared is
168:             *         an instance of <code>Point</code> and has
169:             *         the same values; <code>false</code> otherwise.
170:             */
171:            public boolean equals(Object obj) {
172:                if (obj instanceof  Point) {
173:                    Point pt = (Point) obj;
174:                    return (x == pt.x) && (y == pt.y);
175:                }
176:                return super .equals(obj);
177:            }
178:
179:            /**
180:             * Returns a string representation of this point and its location 
181:             * in the (<i>x</i>,&nbsp;<i>y</i>) coordinate space. This method is 
182:             * intended to be used only for debugging purposes, and the content 
183:             * and format of the returned string may vary between implementations. 
184:             * The returned string may be empty but may not be <code>null</code>.
185:             * 
186:             * @return  a string representation of this point
187:             */
188:            public String toString() {
189:                return "Point[" + x + ", " + y + "]";
190:            }
191:        }
192:        //#endif
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.