|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.Point2D
java.awt.Point
public class Point
This class represents a point on the screen using cartesian coordinates. Remember that in screen coordinates, increasing x values go from left to right, and increasing y values go from top to bottom.
There are some public fields; if you mess with them in an inconsistent manner, it is your own fault when you get invalid results. Also, this class is not threadsafe.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Point2D |
---|
Point2D.Double, Point2D.Float |
Field Summary | |
---|---|
int |
x
The x coordinate. |
int |
y
The y coordinate. |
Constructor Summary | |
---|---|
Point()
Initializes a new instance of Point representing the
coordinates (0, 0). |
|
Point(int x,
int y)
Initializes a new instance of Point with the specified
coordinates. |
|
Point(Point p)
Initializes a new instance of Point with coordinates
identical to the coordinates of the specified point. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Tests whether or not this object is equal to the specified object. |
Point |
getLocation()
Returns the location of this point. |
double |
getX()
Get the x coordinate. |
double |
getY()
Get the y coordinate. |
void |
move(int x,
int y)
Sets this object's coordinates to the specified values. |
void |
setLocation(double x,
double y)
Sets this object's coordinates to the specified values. |
void |
setLocation(int x,
int y)
Sets this object's coordinates to the specified values. |
void |
setLocation(Point p)
Sets this object's coordinates to match those of the specified point. |
String |
toString()
Returns a string representation of this object. |
void |
translate(int dx,
int dy)
Changes the coordinates of this point such that the specified dx parameter is added to the existing X coordinate and
dy is added to the existing Y coordinate. |
Methods inherited from class java.awt.geom.Point2D |
---|
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public int x
getLocation()
,
move(int, int)
public int y
getLocation()
,
move(int, int)
Constructor Detail |
---|
public Point()
Point
representing the
coordinates (0, 0).
public Point(Point p)
Point
with coordinates
identical to the coordinates of the specified point.
p
- the point to copy the coordinates from
NullPointerException
- if p is nullpublic Point(int x, int y)
Point
with the specified
coordinates.
x
- the X coordinatey
- the Y coordinateMethod Detail |
---|
public double getX()
getX
in class Point2D
public double getY()
getY
in class Point2D
public Point getLocation()
setLocation(Point)
public void setLocation(Point p)
p
- the point to copy the coordinates from
NullPointerException
- if p is nullpublic void setLocation(int x, int y)
move()
method.
x
- the new X coordinatey
- the new Y coordinatepublic void setLocation(double x, double y)
Math.floor(double)
.
setLocation
in class Point2D
x
- the new X coordinatey
- the new Y coordinatepublic void move(int x, int y)
setLocation(int, int)
method.
x
- the new X coordinatey
- the new Y coordinatepublic void translate(int dx, int dy)
dx
parameter is added to the existing X coordinate and
dy
is added to the existing Y coordinate.
dx
- the amount to add to the X coordinatedy
- the amount to add to the Y coordinatepublic boolean equals(Object obj)
equals
in class Point2D
obj
- the object to test against for equality
Object.hashCode()
public String toString()
getClass().getName() + "[x=" + x + ",y=" + y + ']'
.
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |