acm.graphics
Class GPoint

java.lang.Object
  extended by acm.graphics.GPoint

public class GPoint
extends Object
implements Serializable

This class is a double-precision version of the Point class in java.awt.


Constructor Summary
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.
 
Method Summary
 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.
 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.
 void translate(double dx, double dy)
Adjusts the coordinates of a point by the specified dx and dy offsets.
 

Constructor Detail

public GPoint()

Constructs a new GPoint at the origin (0, 0).

 
Usage: pt = new GPoint(); 
 


public GPoint(double x, double y)

Constructs a new GPoint with the specified coordinates.

 
Usage: pt = new GPoint(x, y); 
Parameters: 
 The x-coordinate of the point
 The y-coordinate of the point
 


public GPoint(GPoint p)

Constructs a new GPoint from an existing one.

 
Usage: pt = new GPoint(p); 
Parameter: 
 The original point
 


public GPoint(Point p)

Constructs a new GPoint from an existing AWT Point.

 
Usage: pt = new GPoint(p); 
Parameter: 
 An AWT Point
 

Method Detail

public GPoint getLocation()

Returns a new GPoint whose coordinates are the same as this one.

 
Usage: p = pt.getLocation(); 
Returns: A new point with the same coordinates
 


public double getX()

Returns the x coordinate of this GPoint.

 
Usage: x = pt.getX(); 
Returns: The x coordinate of this GPoint
 


public double getY()

Returns the y coordinate of this GPoint.

 
Usage: y = pt.getY(); 
Returns: The y coordinate of this GPoint
 


public void setLocation(double x, double y)

Sets the location of the GPoint to the specified x and y values.

 
Usage: pt.setLocation(x, y); 
Parameters: 
 The new x-coordinate for the point
 The new y-coordinate for the point
 


public void setLocation(GPoint p)

Sets the location of the GPoint to that of an existing one.

 
Usage: pt.setLocation(p); 
Parameter: 
 An existing GPoint specifying the new location
 


public Point toPoint()

Converts this GPoint to the nearest integer-based Point.

 
Usage: size = dim.toPoint(); 
Returns: The closest integer-based Point
 


public void translate(double dx, double dy)

Adjusts the coordinates of a point by the specified dx and dy offsets.

 
Usage: pt.translate(dx, dy); 
Parameters: 
dx  The change in the x direction (positive is rightward)
dy  The change in the y direction (positive is downward)