Documentation of 'edu.rit.draw.item.Point' Java class
Point
edu.rit.draw.item

Class Point

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable


    public class Point
    extends java.lang.Object
    implements java.io.Externalizable
    Class Point provides an (x,y) point on a drawing. Operations are provided for doing arithmetic on points.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Point()
      Construct a new point at location (0,0).
      Point(double x, double y)
      Construct a new point at location (x,y).
      Point(Point thePoint)
      Construct a new point at the same location as the given point.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Size absDifference(Point thePoint)
      Returns a Size object representing the absolute difference between this point and the given point.
      Point add(double dx, double dy)
      Returns a new point at the given offsets from this point.
      Point add(Size theSize)
      Returns a new point at the given width and height away from this point.
      Size difference(Point thePoint)
      Returns a Size object representing the difference between this point and the given point.
      Point e(double distance)
      Returns a new point that is the given distance east of this point.
      Point e(Size theSize)
      Returns a new point that is the given distance east of this point.
      boolean equals(java.lang.Object obj)
      Determine if this point is equal to the given object.
      int hashCode()
      Returns a hash code for this point.
      Point max(Point thePoint)
      Returns a new point that is the maximum of this point and the given point.
      Point min(Point thePoint)
      Returns a new point that is the minimum of this point and the given point.
      Point n(double distance)
      Returns a new point that is the given distance north of this point.
      Point n(Size theSize)
      Returns a new point that is the given distance north of this point.
      void readExternal(java.io.ObjectInput in)
      Read this point from the given object input stream.
      Point s(double distance)
      Returns a new point that is the given distance south of this point.
      Point s(Size theSize)
      Returns a new point that is the given distance south of this point.
      Point sub(double dx, double dy)
      Returns a new point at the given offsets from this point.
      Point sub(Size theSize)
      Returns a new point at the given width and height away from this point.
      java.lang.String toString()
      Returns a string version of this point.
      Point w(double distance)
      Returns a new point that is the given distance west of this point.
      Point w(Size theSize)
      Returns a new point that is the given distance east of this point.
      void writeExternal(java.io.ObjectOutput out)
      Write this point to the given object output stream.
      double x()
      Returns this point's X coordinate.
      double y()
      Returns this point's Y coordinate.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Point

        public Point()
        Construct a new point at location (0,0).
      • Point

        public Point(double x,
                     double y)
        Construct a new point at location (x,y).
        Parameters:
        x - X coordinate.
        y - Y coordinate.
      • Point

        public Point(Point thePoint)
        Construct a new point at the same location as the given point.
        Parameters:
        thePoint - Point to copy.
    • Method Detail

      • x

        public double x()
        Returns this point's X coordinate.
      • y

        public double y()
        Returns this point's Y coordinate.
      • add

        public Point add(double dx,
                         double dy)
        Returns a new point at the given offsets from this point.
        Parameters:
        dx - X offset; added to this point's X coordinate.
        dy - Y offset; added to this point's Y coordinate.
      • add

        public Point add(Size theSize)
        Returns a new point at the given width and height away from this point. theSize's width is added to this point's X coordinate. theSize's height is added to this point's Y coordinate.
        Parameters:
        theSize - Size object containing width and height.
      • sub

        public Point sub(double dx,
                         double dy)
        Returns a new point at the given offsets from this point.
        Parameters:
        dx - X offset; subtracted from this point's X coordinate.
        dy - Y offset; subtracted from this point's Y coordinate.
      • sub

        public Point sub(Size theSize)
        Returns a new point at the given width and height away from this point. theSize's width is subtracted from this point's X coordinate. theSize's height is subtracted from this point's Y coordinate.
        Parameters:
        theSize - Size object containing width and height.
      • difference

        public Size difference(Point thePoint)
        Returns a Size object representing the difference between this point and the given point. The size object's width is this point's X coordinate minus thePoint's X coordinate. The size object's height is this point's Y coordinate minus thePoint's Y coordinate.
        Parameters:
        thePoint - Point object.
      • absDifference

        public Size absDifference(Point thePoint)
        Returns a Size object representing the absolute difference between this point and the given point. The size object's width is the absolute value of this point's X coordinate minus thePoint's X coordinate. The size object's height is the absolute value of this point's Y coordinate minus thePoint's Y coordinate.
        Parameters:
        thePoint - Point object.
      • max

        public Point max(Point thePoint)
        Returns a new point that is the maximum of this point and the given point. Each coordinate of the returned point is the maximum of the corresponding coordinates of this point and thePoint.
        Parameters:
        thePoint - Point object.
      • min

        public Point min(Point thePoint)
        Returns a new point that is the minimum of this point and the given point. Each coordinate of the returned point is the minimum of the corresponding coordinates of this point and thePoint.
        Parameters:
        thePoint - Point object.
      • n

        public Point n(double distance)
        Returns a new point that is the given distance north of this point. The new point's X coordinate is the same as this point's X coordinate. The new point's Y coordinate is this point's Y coordinate minus distance.
        Parameters:
        distance - Distance of new point from this point.
      • s

        public Point s(double distance)
        Returns a new point that is the given distance south of this point. The new point's X coordinate is the same as this point's X coordinate. The new point's Y coordinate is this point's Y coordinate plus distance.
        Parameters:
        distance - Distance of new point from this point.
      • e

        public Point e(double distance)
        Returns a new point that is the given distance east of this point. The new point's X coordinate is this point's X coordinate plus distance. The new point's Y coordinate is the same as this point's Y coordinate.
        Parameters:
        distance - Distance of new point from this point.
      • w

        public Point w(double distance)
        Returns a new point that is the given distance west of this point. The new point's X coordinate is this point's X coordinate minus distance. The new point's Y coordinate is the same as this point's Y coordinate.
        Parameters:
        distance - Distance of new point from this point.
      • n

        public Point n(Size theSize)
        Returns a new point that is the given distance north of this point. The new point's X coordinate is the same as this point's X coordinate. The new point's Y coordinate is this point's Y coordinate minus theSize.height().
        Parameters:
        theSize - Distance of new point from this point = theSize.height().
      • s

        public Point s(Size theSize)
        Returns a new point that is the given distance south of this point. The new point's X coordinate is the same as this point's X coordinate. The new point's Y coordinate is this point's Y coordinate plus theSize.height().
        Parameters:
        theSize - Distance of new point from this point = theSize.height().
      • e

        public Point e(Size theSize)
        Returns a new point that is the given distance east of this point. The new point's X coordinate is this point's X coordinate plus theSize.width(). The new point's Y coordinate is the same as this point's Y coordinate.
        Parameters:
        theSize - Distance of new point from this point = theSize.width().
      • w

        public Point w(Size theSize)
        Returns a new point that is the given distance east of this point. The new point's X coordinate is this point's X coordinate minus theSize.width(). The new point's Y coordinate is the same as this point's Y coordinate.
        Parameters:
        theSize - Distance of new point from this point = theSize.width().
      • writeExternal

        public void writeExternal(java.io.ObjectOutput out)
                           throws java.io.IOException
        Write this point to the given object output stream.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Parameters:
        out - Object output stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • readExternal

        public void readExternal(java.io.ObjectInput in)
                          throws java.io.IOException
        Read this point from the given object input stream.
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - Object input stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • equals

        public boolean equals(java.lang.Object obj)
        Determine if this point is equal to the given object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Object to test.
        Returns:
        True if this point is equal to obj, false otherwise.
      • hashCode

        public int hashCode()
        Returns a hash code for this point.
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a string version of this point.
        Overrides:
        toString in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.