Package com.sun.javafx.geom
Class Point2D
java.lang.Object
com.sun.javafx.geom.Point2D
A 2D geometric point that usually represents the x, y coordinates.
It can also represent a relative magnitude vector's x, y magnitudes.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
distance
(float px, float py) Returns the distance from thisPoint2D
to a specified point.static float
distance
(float x1, float y1, float x2, float y2) Returns the distance between two points.float
Returns the distance from thisPoint2D
to a specifiedPoint2D
.float
distanceSq
(float px, float py) Returns the square of the distance from thisPoint2D
to a specified point.static float
distanceSq
(float x1, float y1, float x2, float y2) Returns the square of the distance between two points.float
distanceSq
(Point2D pt) Returns the square of the distance from thisPoint2D
to a specifiedPoint2D
.boolean
Determines whether or not two points are equal.int
hashCode()
Returns the hashcode for thisPoint2D
.void
setLocation
(float x, float y) Sets the location of thisPoint2D
to the specifiedfloat
coordinates.void
Sets the location of thisPoint2D
to the same coordinates as the specifiedPoint2D
object.toString()
Returns aString
that represents the value of thisPoint2D
.
-
Field Details
-
x
public float xThe X coordinate of thisPoint2D
. -
y
public float yThe Y coordinate of thisPoint2D
.
-
-
Constructor Details
-
Point2D
public Point2D()Constructs and initializes aPoint2D
with coordinates (0, 0). -
Point2D
public Point2D(float x, float y) Constructs and initializes aPoint2D
with the specified coordinates.- Parameters:
x
- the X coordinate of the newly constructedPoint2D
y
- the Y coordinate of the newly constructedPoint2D
-
-
Method Details
-
setLocation
public void setLocation(float x, float y) Sets the location of thisPoint2D
to the specifiedfloat
coordinates.- Parameters:
x
- the new X coordinate of thisPoint2D
y
- the new Y coordinate of thisPoint2D
-
setLocation
Sets the location of thisPoint2D
to the same coordinates as the specifiedPoint2D
object.- Parameters:
p
- the specifiedPoint2D
to which to set thisPoint2D
-
distanceSq
public static float distanceSq(float x1, float y1, float x2, float y2) Returns the square of the distance between two points.- Parameters:
x1
- the X coordinate of the first specified pointy1
- the Y coordinate of the first specified pointx2
- the X coordinate of the second specified pointy2
- the Y coordinate of the second specified point- Returns:
- the square of the distance between the two sets of specified coordinates.
-
distance
public static float distance(float x1, float y1, float x2, float y2) Returns the distance between two points.- Parameters:
x1
- the X coordinate of the first specified pointy1
- the Y coordinate of the first specified pointx2
- the X coordinate of the second specified pointy2
- the Y coordinate of the second specified point- Returns:
- the distance between the two sets of specified coordinates.
-
distanceSq
public float distanceSq(float px, float py) Returns the square of the distance from thisPoint2D
to a specified point.- Parameters:
px
- the X coordinate of the specified point to be measured against thisPoint2D
py
- the Y coordinate of the specified point to be measured against thisPoint2D
- Returns:
- the square of the distance between this
Point2D
and the specified point.
-
distanceSq
Returns the square of the distance from thisPoint2D
to a specifiedPoint2D
.- Parameters:
pt
- the specified point to be measured against thisPoint2D
- Returns:
- the square of the distance between this
Point2D
to a specifiedPoint2D
.
-
distance
public float distance(float px, float py) Returns the distance from thisPoint2D
to a specified point.- Parameters:
px
- the X coordinate of the specified point to be measured against thisPoint2D
py
- the Y coordinate of the specified point to be measured against thisPoint2D
- Returns:
- the distance between this
Point2D
and a specified point.
-
distance
Returns the distance from thisPoint2D
to a specifiedPoint2D
.- Parameters:
pt
- the specified point to be measured against thisPoint2D
- Returns:
- the distance between this
Point2D
and the specifiedPoint2D
.
-
hashCode
public int hashCode()Returns the hashcode for thisPoint2D
. -
equals
Determines whether or not two points are equal. Two instances ofPoint2D
are equal if the values of theirx
andy
member fields, representing their position in the coordinate space, are the same. -
toString
Returns aString
that represents the value of thisPoint2D
.
-