public class GPoint extends Object implements Serializable
Point class in
java.awt.| Constructor and Description |
|---|
GPoint()
Constructs a new
GPoint at the origin (0, 0). |
GPoint(double x,
double y)
Constructs a new
GPoint with the specified coordinates. |
GPoint(GPoint p)
Constructs a new
GPoint from an existing one. |
GPoint(Point p)
Constructs a new
GPoint from an existing AWT
Point. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(double x,
double y)
Returns true if this GPoint's coordinates equal the given coordinates.
|
boolean |
equals(Object obj)
Tests whether two
GPoint objects are equal. |
GPoint |
getLocation()
Returns a new
GPoint whose coordinates are the same as this
one. |
double |
getX()
Returns the x coordinate of this
GPoint. |
double |
getY()
Returns the y coordinate of this
GPoint. |
int |
hashCode()
Returns an integer hash code for the point.
|
void |
setLocation(double x,
double y)
Sets the location of the
GPoint to the specified
x and y values. |
void |
setLocation(GPoint p)
Sets the location of the
GPoint to that of an existing one. |
Point |
toPoint()
Converts this
GPoint to the nearest integer-based
Point. |
String |
toString()
Converts this
GPoint to its string representation. |
void |
translate(double dx,
double dy)
Adjusts the coordinates of a point by the specified
dx and
dy offsets. |
public GPoint()
GPoint at the origin (0, 0).public GPoint(double x,
double y)
GPoint with the specified coordinates.x - The x-coordinate of the pointy - The y-coordinate of the pointpublic GPoint(GPoint p)
GPoint from an existing one.p - The original pointpublic GPoint(Point p)
GPoint from an existing AWT
Point.p - An AWT Pointpublic double getX()
GPoint.GPointpublic double getY()
GPoint.GPointpublic void setLocation(double x,
double y)
GPoint to the specified
x and y values.x - The new x-coordinate for the pointy - The new y-coordinate for the pointpublic void setLocation(GPoint p)
GPoint to that of an existing one.p - An existing GPoint specifying the new locationpublic GPoint getLocation()
GPoint whose coordinates are the same as this
one.public void translate(double dx,
double dy)
dx and
dy offsets.dx - The change in the x direction (positive is rightward)dy - The change in the y direction (positive is downward)public Point toPoint()
GPoint to the nearest integer-based
Point.Pointpublic int hashCode()
GPoint is constructed from the hash codes from the
float values of the coordinates, which are the ones used in
the equals method.public boolean equals(Object obj)
GPoint objects are equal. Because
floating-point values are inexact, this method checks for equality by
comparing the float values (rather than the
double values) of the coordinates.public boolean equals(double x,
double y)
public String toString()
GPoint to its string representation.
Decimal point on each coord will be shown if not a whole number.
Examples: "(4, -7)" or "(-2.4, 3.68)"