public class GPoint
extends java.lang.Object
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(java.awt.Point p)
Constructs a new
GPoint from an existing AWT Point. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.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. |
java.awt.Point |
toPoint()
Converts this
GPoint to the nearest integer-based Point. |
java.lang.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(java.awt.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 java.awt.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.hashCode in class java.lang.Objectpublic boolean equals(java.lang.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.equals in class java.lang.Objectobj - Any objecttrue if the obj is a GPoint
equal to this one, and false otherwisepublic java.lang.String toString()
GPoint to its string representation.toString in class java.lang.Object