< prev index next >

src/java.desktop/share/classes/java/awt/geom/Point2D.java

Print this page

        

*** 26,36 **** package java.awt.geom; import java.io.Serializable; /** ! * The <code>Point2D</code> class defines a point representing a location * in {@code (x,y)} coordinate space. * <p> * This class is only the abstract superclass for all objects that * store a 2D coordinate. * The actual storage representation of the coordinates is left to --- 26,36 ---- package java.awt.geom; import java.io.Serializable; /** ! * The {@code Point2D} class defines a point representing a location * in {@code (x,y)} coordinate space. * <p> * This class is only the abstract superclass for all objects that * store a 2D coordinate. * The actual storage representation of the coordinates is left to
*** 40,84 **** * @since 1.2 */ public abstract class Point2D implements Cloneable { /** ! * The <code>Float</code> class defines a point specified in float * precision. * @since 1.2 */ public static class Float extends Point2D implements Serializable { /** ! * The X coordinate of this <code>Point2D</code>. * @since 1.2 * @serial */ public float x; /** ! * The Y coordinate of this <code>Point2D</code>. * @since 1.2 * @serial */ public float y; /** ! * Constructs and initializes a <code>Point2D</code> with * coordinates (0,&nbsp;0). * @since 1.2 */ public Float() { } /** ! * Constructs and initializes a <code>Point2D</code> with * the specified coordinates. * * @param x the X coordinate of the newly ! * constructed <code>Point2D</code> * @param y the Y coordinate of the newly ! * constructed <code>Point2D</code> * @since 1.2 */ public Float(float x, float y) { this.x = x; this.y = y; --- 40,84 ---- * @since 1.2 */ public abstract class Point2D implements Cloneable { /** ! * The {@code Float} class defines a point specified in float * precision. * @since 1.2 */ public static class Float extends Point2D implements Serializable { /** ! * The X coordinate of this {@code Point2D}. * @since 1.2 * @serial */ public float x; /** ! * The Y coordinate of this {@code Point2D}. * @since 1.2 * @serial */ public float y; /** ! * Constructs and initializes a {@code Point2D} with * coordinates (0,&nbsp;0). * @since 1.2 */ public Float() { } /** ! * Constructs and initializes a {@code Point2D} with * the specified coordinates. * * @param x the X coordinate of the newly ! * constructed {@code Point2D} * @param y the Y coordinate of the newly ! * constructed {@code Point2D} * @since 1.2 */ public Float(float x, float y) { this.x = x; this.y = y;
*** 108,119 **** this.x = (float) x; this.y = (float) y; } /** ! * Sets the location of this <code>Point2D</code> to the ! * specified <code>float</code> coordinates. * * @param x the new X coordinate of this {@code Point2D} * @param y the new Y coordinate of this {@code Point2D} * @since 1.2 */ --- 108,119 ---- this.x = (float) x; this.y = (float) y; } /** ! * Sets the location of this {@code Point2D} to the ! * specified {@code float} coordinates. * * @param x the new X coordinate of this {@code Point2D} * @param y the new Y coordinate of this {@code Point2D} * @since 1.2 */
*** 121,133 **** this.x = x; this.y = y; } /** ! * Returns a <code>String</code> that represents the value ! * of this <code>Point2D</code>. ! * @return a string representation of this <code>Point2D</code>. * @since 1.2 */ public String toString() { return "Point2D.Float["+x+", "+y+"]"; } --- 121,133 ---- this.x = x; this.y = y; } /** ! * Returns a {@code String} that represents the value ! * of this {@code Point2D}. ! * @return a string representation of this {@code Point2D}. * @since 1.2 */ public String toString() { return "Point2D.Float["+x+", "+y+"]"; }
*** 137,181 **** */ private static final long serialVersionUID = -2870572449815403710L; } /** ! * The <code>Double</code> class defines a point specified in ! * <code>double</code> precision. * @since 1.2 */ public static class Double extends Point2D implements Serializable { /** ! * The X coordinate of this <code>Point2D</code>. * @since 1.2 * @serial */ public double x; /** ! * The Y coordinate of this <code>Point2D</code>. * @since 1.2 * @serial */ public double y; /** ! * Constructs and initializes a <code>Point2D</code> with * coordinates (0,&nbsp;0). * @since 1.2 */ public Double() { } /** ! * Constructs and initializes a <code>Point2D</code> with the * specified coordinates. * * @param x the X coordinate of the newly ! * constructed <code>Point2D</code> * @param y the Y coordinate of the newly ! * constructed <code>Point2D</code> * @since 1.2 */ public Double(double x, double y) { this.x = x; this.y = y; --- 137,181 ---- */ private static final long serialVersionUID = -2870572449815403710L; } /** ! * The {@code Double} class defines a point specified in ! * {@code double} precision. * @since 1.2 */ public static class Double extends Point2D implements Serializable { /** ! * The X coordinate of this {@code Point2D}. * @since 1.2 * @serial */ public double x; /** ! * The Y coordinate of this {@code Point2D}. * @since 1.2 * @serial */ public double y; /** ! * Constructs and initializes a {@code Point2D} with * coordinates (0,&nbsp;0). * @since 1.2 */ public Double() { } /** ! * Constructs and initializes a {@code Point2D} with the * specified coordinates. * * @param x the X coordinate of the newly ! * constructed {@code Point2D} * @param y the Y coordinate of the newly ! * constructed {@code Point2D} * @since 1.2 */ public Double(double x, double y) { this.x = x; this.y = y;
*** 205,217 **** this.x = x; this.y = y; } /** ! * Returns a <code>String</code> that represents the value ! * of this <code>Point2D</code>. ! * @return a string representation of this <code>Point2D</code>. * @since 1.2 */ public String toString() { return "Point2D.Double["+x+", "+y+"]"; } --- 205,217 ---- this.x = x; this.y = y; } /** ! * Returns a {@code String} that represents the value ! * of this {@code Point2D}. ! * @return a string representation of this {@code Point2D}. * @since 1.2 */ public String toString() { return "Point2D.Double["+x+", "+y+"]"; }
*** 236,275 **** */ protected Point2D() { } /** ! * Returns the X coordinate of this <code>Point2D</code> in ! * <code>double</code> precision. ! * @return the X coordinate of this <code>Point2D</code>. * @since 1.2 */ public abstract double getX(); /** ! * Returns the Y coordinate of this <code>Point2D</code> in ! * <code>double</code> precision. ! * @return the Y coordinate of this <code>Point2D</code>. * @since 1.2 */ public abstract double getY(); /** ! * Sets the location of this <code>Point2D</code> to the ! * specified <code>double</code> coordinates. * * @param x the new X coordinate of this {@code Point2D} * @param y the new Y coordinate of this {@code Point2D} * @since 1.2 */ public abstract void setLocation(double x, double y); /** ! * Sets the location of this <code>Point2D</code> to the same ! * coordinates as the specified <code>Point2D</code> object. ! * @param p the specified <code>Point2D</code> to which to set ! * this <code>Point2D</code> * @since 1.2 */ public void setLocation(Point2D p) { setLocation(p.getX(), p.getY()); } --- 236,275 ---- */ protected Point2D() { } /** ! * Returns the X coordinate of this {@code Point2D} in ! * {@code double} precision. ! * @return the X coordinate of this {@code Point2D}. * @since 1.2 */ public abstract double getX(); /** ! * Returns the Y coordinate of this {@code Point2D} in ! * {@code double} precision. ! * @return the Y coordinate of this {@code Point2D}. * @since 1.2 */ public abstract double getY(); /** ! * Sets the location of this {@code Point2D} to the ! * specified {@code double} coordinates. * * @param x the new X coordinate of this {@code Point2D} * @param y the new Y coordinate of this {@code Point2D} * @since 1.2 */ public abstract void setLocation(double x, double y); /** ! * Sets the location of this {@code Point2D} to the same ! * coordinates as the specified {@code Point2D} object. ! * @param p the specified {@code Point2D} to which to set ! * this {@code Point2D} * @since 1.2 */ public void setLocation(Point2D p) { setLocation(p.getX(), p.getY()); }
*** 312,379 **** return Math.sqrt(x1 * x1 + y1 * y1); } /** * Returns the square of the distance from this ! * <code>Point2D</code> to a specified point. * * @param px the X coordinate of the specified point to be measured ! * against this <code>Point2D</code> * @param py the Y coordinate of the specified point to be measured ! * against this <code>Point2D</code> * @return the square of the distance between this ! * <code>Point2D</code> and the specified point. * @since 1.2 */ public double distanceSq(double px, double py) { px -= getX(); py -= getY(); return (px * px + py * py); } /** * Returns the square of the distance from this ! * <code>Point2D</code> to a specified <code>Point2D</code>. * * @param pt the specified point to be measured ! * against this <code>Point2D</code> * @return the square of the distance between this ! * <code>Point2D</code> to a specified <code>Point2D</code>. * @since 1.2 */ public double distanceSq(Point2D pt) { double px = pt.getX() - this.getX(); double py = pt.getY() - this.getY(); return (px * px + py * py); } /** ! * Returns the distance from this <code>Point2D</code> to * a specified point. * * @param px the X coordinate of the specified point to be measured ! * against this <code>Point2D</code> * @param py the Y coordinate of the specified point to be measured ! * against this <code>Point2D</code> ! * @return the distance between this <code>Point2D</code> * and a specified point. * @since 1.2 */ public double distance(double px, double py) { px -= getX(); py -= getY(); return Math.sqrt(px * px + py * py); } /** ! * Returns the distance from this <code>Point2D</code> to a ! * specified <code>Point2D</code>. * * @param pt the specified point to be measured ! * against this <code>Point2D</code> ! * @return the distance between this <code>Point2D</code> and ! * the specified <code>Point2D</code>. * @since 1.2 */ public double distance(Point2D pt) { double px = pt.getX() - this.getX(); double py = pt.getY() - this.getY(); --- 312,379 ---- return Math.sqrt(x1 * x1 + y1 * y1); } /** * Returns the square of the distance from this ! * {@code Point2D} to a specified point. * * @param px the X coordinate of the specified point to be measured ! * against this {@code Point2D} * @param py the Y coordinate of the specified point to be measured ! * against this {@code Point2D} * @return the square of the distance between this ! * {@code Point2D} and the specified point. * @since 1.2 */ public double distanceSq(double px, double py) { px -= getX(); py -= getY(); return (px * px + py * py); } /** * Returns the square of the distance from this ! * {@code Point2D} to a specified {@code Point2D}. * * @param pt the specified point to be measured ! * against this {@code Point2D} * @return the square of the distance between this ! * {@code Point2D} to a specified {@code Point2D}. * @since 1.2 */ public double distanceSq(Point2D pt) { double px = pt.getX() - this.getX(); double py = pt.getY() - this.getY(); return (px * px + py * py); } /** ! * Returns the distance from this {@code Point2D} to * a specified point. * * @param px the X coordinate of the specified point to be measured ! * against this {@code Point2D} * @param py the Y coordinate of the specified point to be measured ! * against this {@code Point2D} ! * @return the distance between this {@code Point2D} * and a specified point. * @since 1.2 */ public double distance(double px, double py) { px -= getX(); py -= getY(); return Math.sqrt(px * px + py * py); } /** ! * Returns the distance from this {@code Point2D} to a ! * specified {@code Point2D}. * * @param pt the specified point to be measured ! * against this {@code Point2D} ! * @return the distance between this {@code Point2D} and ! * the specified {@code Point2D}. * @since 1.2 */ public double distance(Point2D pt) { double px = pt.getX() - this.getX(); double py = pt.getY() - this.getY();
*** 396,423 **** throw new InternalError(e); } } /** ! * Returns the hashcode for this <code>Point2D</code>. ! * @return a hash code for this <code>Point2D</code>. */ public int hashCode() { long bits = java.lang.Double.doubleToLongBits(getX()); bits ^= java.lang.Double.doubleToLongBits(getY()) * 31; return (((int) bits) ^ ((int) (bits >> 32))); } /** * Determines whether or not two points are equal. Two instances of ! * <code>Point2D</code> are equal if the values of their ! * <code>x</code> and <code>y</code> member fields, representing * their position in the coordinate space, are the same. ! * @param obj an object to be compared with this <code>Point2D</code> ! * @return <code>true</code> if the object to be compared is ! * an instance of <code>Point2D</code> and has ! * the same values; <code>false</code> otherwise. * @since 1.2 */ public boolean equals(Object obj) { if (obj instanceof Point2D) { Point2D p2d = (Point2D) obj; --- 396,423 ---- throw new InternalError(e); } } /** ! * Returns the hashcode for this {@code Point2D}. ! * @return a hash code for this {@code Point2D}. */ public int hashCode() { long bits = java.lang.Double.doubleToLongBits(getX()); bits ^= java.lang.Double.doubleToLongBits(getY()) * 31; return (((int) bits) ^ ((int) (bits >> 32))); } /** * Determines whether or not two points are equal. Two instances of ! * {@code Point2D} are equal if the values of their ! * {@code x} and {@code y} member fields, representing * their position in the coordinate space, are the same. ! * @param obj an object to be compared with this {@code Point2D} ! * @return {@code true} if the object to be compared is ! * an instance of {@code Point2D} and has ! * the same values; {@code false} otherwise. * @since 1.2 */ public boolean equals(Object obj) { if (obj instanceof Point2D) { Point2D p2d = (Point2D) obj;
< prev index next >