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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatdistance(float px, float py) Returns the distance from thisPoint2Dto a specified point.static floatdistance(float x1, float y1, float x2, float y2) Returns the distance between two points.floatReturns the distance from thisPoint2Dto a specifiedPoint2D.floatdistanceSq(float px, float py) Returns the square of the distance from thisPoint2Dto a specified point.static floatdistanceSq(float x1, float y1, float x2, float y2) Returns the square of the distance between two points.floatdistanceSq(Point2D pt) Returns the square of the distance from thisPoint2Dto a specifiedPoint2D.booleanDetermines whether or not two points are equal.inthashCode()Returns the hashcode for thisPoint2D.voidsetLocation(float x, float y) Sets the location of thisPoint2Dto the specifiedfloatcoordinates.voidSets the location of thisPoint2Dto the same coordinates as the specifiedPoint2Dobject.toString()Returns aStringthat 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 aPoint2Dwith coordinates (0, 0). -
Point2D
public Point2D(float x, float y) Constructs and initializes aPoint2Dwith the specified coordinates.- Parameters:
x- the X coordinate of the newly constructedPoint2Dy- the Y coordinate of the newly constructedPoint2D
-
-
Method Details
-
setLocation
public void setLocation(float x, float y) Sets the location of thisPoint2Dto the specifiedfloatcoordinates.- Parameters:
x- the new X coordinate of thisPoint2Dy- the new Y coordinate of thisPoint2D
-
setLocation
Sets the location of thisPoint2Dto the same coordinates as the specifiedPoint2Dobject.- Parameters:
p- the specifiedPoint2Dto 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 thisPoint2Dto a specified point.- Parameters:
px- the X coordinate of the specified point to be measured against thisPoint2Dpy- the Y coordinate of the specified point to be measured against thisPoint2D- Returns:
- the square of the distance between this
Point2Dand the specified point.
-
distanceSq
Returns the square of the distance from thisPoint2Dto a specifiedPoint2D.- Parameters:
pt- the specified point to be measured against thisPoint2D- Returns:
- the square of the distance between this
Point2Dto a specifiedPoint2D.
-
distance
public float distance(float px, float py) Returns the distance from thisPoint2Dto a specified point.- Parameters:
px- the X coordinate of the specified point to be measured against thisPoint2Dpy- the Y coordinate of the specified point to be measured against thisPoint2D- Returns:
- the distance between this
Point2Dand a specified point.
-
distance
Returns the distance from thisPoint2Dto a specifiedPoint2D.- Parameters:
pt- the specified point to be measured against thisPoint2D- Returns:
- the distance between this
Point2Dand the specifiedPoint2D.
-
hashCode
public int hashCode()Returns the hashcode for thisPoint2D. -
equals
Determines whether or not two points are equal. Two instances ofPoint2Dare equal if the values of theirxandymember fields, representing their position in the coordinate space, are the same. -
toString
Returns aStringthat represents the value of thisPoint2D.
-