APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt

public Class Point

extends Point2D
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.awt.geom.Point2D, java.beans.Transient, java.io.Serial

A point representing a location in (x,y) coordinate space, specified in integer precision.
Author
Sami Shaio
Since
1.0

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Use serialVersionUID from JDK 1.1 for interoperability.

public int
x

The X coordinate of this Point.

public int
y

The Y coordinate of this Point.

Constructor Summary

AccessConstructor and Description
public
Point()

Constructs and initializes a point at the origin (0, 0) of the coordinate space.

public
Point(Point
a point
p
)

Constructs and initializes a point with the same location as the specified Point object.

public
Point(int
the X coordinate of the newly constructed Point
x
,
int
the Y coordinate of the newly constructed Point
y
)

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the object to be compared is an instance of Point2D and has the same values; false otherwise.
equals
(Object
an object to be compared with this Point2D
obj
)

Overrides java.awt.geom.Point2D.equals.

Determines whether or not two points are equal.

public Point

Returns:

a copy of this point, at the same location
getLocation
()

Returns the location of this point.

public double
getX()

Implements abstract java.awt.geom.Point2D.getX.

Returns the X coordinate of this Point2D in double precision.

public double
getY()

Implements abstract java.awt.geom.Point2D.getY.

Returns the Y coordinate of this Point2D in double precision.

public void
move(int
the X coordinate of the new location
x
,
int
the Y coordinate of the new location
y
)

Moves this point to the specified location in the (x,y) coordinate plane.

public void
setLocation(Point
a point, the new location for this point
p
)

Sets the location of the point to the specified location.

public void
setLocation(int
the X coordinate of the new location
x
,
int
the Y coordinate of the new location
y
)

Changes the point to have the specified location.

public void
setLocation(double
the X coordinate of the new location
x
,
double
the Y coordinate of the new location
y
)

Implements abstract java.awt.geom.Point2D.setLocation.

Sets the location of this point to the specified double coordinates.

public String

Returns:

a string representation of this point
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this point and its location in the (x,y) coordinate space.

public void
translate(int
the distance to move this point along the X axis
dx
,
int
the distance to move this point along the Y axis
dy
)

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).

Inherited from java.awt.geom.Point2D:
clonedistancedistancedistancedistanceSqdistanceSqdistanceSqhashCodesetLocation

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.1 for interoperability.

Annotations
@Serial
xback to summary
public int x

The X coordinate of this Point. If no X coordinate is set it will default to 0.

Since
1.0
See Also
getLocation(), move(int, int)
yback to summary
public int y

The Y coordinate of this Point. If no Y coordinate is set it will default to 0.

Since
1.0
See Also
getLocation(), move(int, int)

Constructor Detail

Pointback to summary
public Point()

Constructs and initializes a point at the origin (0, 0) of the coordinate space.

Since
1.1
Pointback to summary
public Point(Point p)

Constructs and initializes a point with the same location as the specified Point object.

Parameters
p:Point

a point

Since
1.1
Pointback to summary
public Point(int x, int y)

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Parameters
x:int

the X coordinate of the newly constructed Point

y:int

the Y coordinate of the newly constructed Point

Since
1.0

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.awt.geom.Point2D.equals.

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.

Parameters
obj:Object

an object to be compared with this Point2D

Returns:boolean

true if the object to be compared is an instance of Point2D and has the same values; false otherwise.

getLocationback to summary
public Point getLocation()

Returns the location of this point. This method is included for completeness, to parallel the getLocation method of Component.

Returns:Point

a copy of this point, at the same location

Annotations
@Transient
Since
1.1
See Also
java.awt.Component#getLocation, java.awt.Point#setLocation(java.awt.Point), java.awt.Point#setLocation(int, int)
getXback to summary
public double getX()

Implements abstract java.awt.geom.Point2D.getX.

Doc from java.awt.geom.Point2D.getX.

Returns the X coordinate of this Point2D in double precision.

Since
1.2
getYback to summary
public double getY()

Implements abstract java.awt.geom.Point2D.getY.

Doc from java.awt.geom.Point2D.getY.

Returns the Y coordinate of this Point2D in double precision.

Since
1.2
moveback to summary
public void move(int x, int y)

Moves this point to the specified location in the (x,y) coordinate plane. This method is identical with setLocation(int, int).

Parameters
x:int

the X coordinate of the new location

y:int

the Y coordinate of the new location

See Also
java.awt.Component#setLocation(int, int)
setLocationback to summary
public void setLocation(Point p)

Sets the location of the point to the specified location. This method is included for completeness, to parallel the setLocation method of Component.

Parameters
p:Point

a point, the new location for this point

Since
1.1
See Also
java.awt.Component#setLocation(java.awt.Point), java.awt.Point#getLocation
setLocationback to summary
public void setLocation(int x, int y)

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).

Parameters
x:int

the X coordinate of the new location

y:int

the Y coordinate of the new location

Since
1.1
See Also
java.awt.Component#setLocation(int, int), java.awt.Point#getLocation, java.awt.Point#move(int, int)
setLocationback to summary
public void setLocation(double x, double y)

Implements abstract java.awt.geom.Point2D.setLocation.

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.

Parameters
x:double

the X coordinate of the new location

y:double

the Y coordinate of the new location

See Also
getLocation
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

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.

Returns:String

a string representation of this point

translateback to summary
public void translate(int dx, int dy)

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).

Parameters
dx:int

the distance to move this point along the X axis

dy:int

the distance to move this point along the Y axis