KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > Point


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9  
10    $Log: Point.java,v $
11    Revision 1.3 2004/01/15 15:20:29 bobintetley
12    Java2D work
13
14    Revision 1.2 2004/01/06 08:28:02 bobintetley
15    Header fixes
16
17  
18  */

19 package swingwt.awt;
20
21 public class Point extends swingwt.awt.geom.Point2D {
22
23     public int x;
24     public int y;
25     public Point() {
26     this(0, 0);
27     }
28     public Point(Point p) {
29     this(p.x, p.y);
30     }
31     public Point(int x, int y) {
32     this.x = x;
33     this.y = y;
34     }
35     public double getX() {
36     return x;
37     }
38     public double getY() {
39     return y;
40     }
41     public Point getLocation() {
42     return new Point(x, y);
43     }
44     public void setLocation(Point p) {
45     setLocation(p.x, p.y);
46     }
47     public void setLocation(int x, int y) {
48     move(x, y);
49     }
50     public void setLocation(double x, double y) {
51     this.x = (int) Math.floor(x+0.5);
52     this.y = (int) Math.floor(y+0.5);
53     }
54     public void move(int x, int y) {
55     this.x = x;
56     this.y = y;
57     }
58     public void translate(int dx, int dy) {
59     this.x += dx;
60     this.y += dy;
61     }
62     public boolean equals(Object JavaDoc obj) {
63     if (obj instanceof Point) {
64         Point pt = (Point)obj;
65         return (x == pt.x) && (y == pt.y);
66     }
67     return super.equals(obj);
68     }
69     public String JavaDoc toString() {
70     return getClass().getName() + "[x=" + x + ",y=" + y + "]";
71     }
72 }
Popular Tags