Class Point2D

java.lang.Object
com.sun.javafx.geom.Point2D

public class Point2D extends Object
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
    Modifier and Type
    Field
    Description
    float
    The X coordinate of this Point2D.
    float
    The Y coordinate of this Point2D.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs and initializes a Point2D with coordinates (0, 0).
    Point2D(float x, float y)
    Constructs and initializes a Point2D with the specified coordinates.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    distance(float px, float py)
    Returns the distance from this Point2D 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 this Point2D to a specified Point2D.
    float
    distanceSq(float px, float py)
    Returns the square of the distance from this Point2D 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
    Returns the square of the distance from this Point2D to a specified Point2D.
    boolean
    Determines whether or not two points are equal.
    int
    Returns the hashcode for this Point2D.
    void
    setLocation(float x, float y)
    Sets the location of this Point2D to the specified float coordinates.
    void
    Sets the location of this Point2D to the same coordinates as the specified Point2D object.
    Returns a String that represents the value of this Point2D.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      public float x
      The X coordinate of this Point2D.
    • y

      public float y
      The Y coordinate of this Point2D.
  • Constructor Details

    • Point2D

      public Point2D()
      Constructs and initializes a Point2D with coordinates (0, 0).
    • Point2D

      public Point2D(float x, float y)
      Constructs and initializes a Point2D with the specified coordinates.
      Parameters:
      x - the X coordinate of the newly constructed Point2D
      y - the Y coordinate of the newly constructed Point2D
  • Method Details

    • setLocation

      public void setLocation(float x, float y)
      Sets the location of this Point2D to the specified float coordinates.
      Parameters:
      x - the new X coordinate of this Point2D
      y - the new Y coordinate of this Point2D
    • setLocation

      public void setLocation(Point2D p)
      Sets the location of this Point2D to the same coordinates as the specified Point2D object.
      Parameters:
      p - the specified Point2D to which to set this Point2D
    • 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 point
      y1 - the Y coordinate of the first specified point
      x2 - the X coordinate of the second specified point
      y2 - 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 point
      y1 - the Y coordinate of the first specified point
      x2 - the X coordinate of the second specified point
      y2 - 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 this Point2D to a specified point.
      Parameters:
      px - the X coordinate of the specified point to be measured against this Point2D
      py - the Y coordinate of the specified point to be measured against this Point2D
      Returns:
      the square of the distance between this Point2D and the specified point.
    • distanceSq

      public float distanceSq(Point2D pt)
      Returns the square of the distance from this Point2D to a specified Point2D.
      Parameters:
      pt - the specified point to be measured against this Point2D
      Returns:
      the square of the distance between this Point2D to a specified Point2D.
    • distance

      public float distance(float px, float py)
      Returns the distance from this Point2D to a specified point.
      Parameters:
      px - the X coordinate of the specified point to be measured against this Point2D
      py - the Y coordinate of the specified point to be measured against this Point2D
      Returns:
      the distance between this Point2D and a specified point.
    • distance

      public float distance(Point2D pt)
      Returns the distance from this Point2D to a specified Point2D.
      Parameters:
      pt - the specified point to be measured against this Point2D
      Returns:
      the distance between this Point2D and the specified Point2D.
    • hashCode

      public int hashCode()
      Returns the hashcode for this Point2D.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this Point2D.
    • equals

      public boolean equals(Object obj)
      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.
      Overrides:
      equals in class Object
      Parameters:
      obj - an object to be compared with this Point2D
      Returns:
      true if the object to be compared is an instance of Point2D and has the same values; false otherwise.
    • toString

      public String toString()
      Returns a String that represents the value of this Point2D.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this Point2D.