public class java.awt
Point


Show All Login
Java SE 6
  
Extends: Point2D
Implements: Serializable
Details
A point representing a location in (x,y) coordinate space, specified in integer precision.
version1.40, 02/24/06
since1.0

Fields
public int x Details
The X coordinate of this Point. If no X coordinate is set it will default to 0.
serial
since1.0
See also getLocation(), move(int, int)
public int y Details
The Y coordinate of this Point. If no Y coordinate is set it will default to 0.
serial
since1.0
See also getLocation(), move(int, int)

Constructors
public Point() Details
Constructs and initializes a point at the origin (0, 0) of the coordinate space.
since1.1
public Point(Point p) Details
Constructs and initializes a point with the same location as the specified Point object.
pa point
since1.1
public Point(int x, int y) Details
Constructs and initializes a point at the specified (x,y) location in the coordinate space.
xthe X coordinate of the newly constructed Point
ythe Y coordinate of the newly constructed Point
since1.0

Methods
public boolean equals(Object obj) Details
Determines whether or not two points are equal. Two instances of Point2D are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
objan object to be compared with this Point2D
returntrue if the object to be compared is an instance of Point2D and has the same values; false otherwise.
public void move(int x, int y) Details
Moves this point to the specified location in the (x,y) coordinate plane. This method is identical with setLocation(int, int).
xthe X coordinate of the new location
ythe Y coordinate of the new location
See also setLocation(int, int)
public String toString() Details
Returns a string representation of this point and its location in the (x,y) coordinate space. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
returna string representation of this point
public void translate(int dx, int dy) Details
Translates this point, at location (x,y), by dx along the x axis and dy along the y axis so that it now represents the point (x+dx,y+dy).
dxthe distance to move this point along the X axis
dythe distance to move this point along the Y axis

Properties
public void setLocation(Point p) Details
Sets the location of the point to the specified location. This method is included for completeness, to parallel the setLocation method of Component.
pa point, the new location for this point
since1.1
See also setLocation(java.awt.Point), getLocation
public void setLocation(int x, int y) Details
Changes the point to have the specified location.

This method is included for completeness, to parallel the setLocation method of Component. Its behavior is identical with move(int, int).
xthe X coordinate of the new location
ythe Y coordinate of the new location
since1.1
See also setLocation(int, int), getLocation, move(int, int)

public void setLocation(double x, double y) Details
Sets the location of this point to the specified double coordinates. The double values will be rounded to integer values. Any number smaller than Integer.MIN_VALUE will be reset to MIN_VALUE, and any number larger than Integer.MAX_VALUE will be reset to MAX_VALUE.
xthe X coordinate of the new location
ythe Y coordinate of the new location
See also getLocation
public Point getLocation() Details
Returns the location of this point. This method is included for completeness, to parallel the getLocation method of Component.
returna copy of this point, at the same location
since1.1
See also getLocation, setLocation(java.awt.Point), setLocation(int, int)
public double getX() Details
Returns the X coordinate of this Point2D in double precision.
since1.2
public double getY() Details
Returns the Y coordinate of this Point2D in double precision.
since1.2