edu.rit.slides.items
Class Point

java.lang.Object
  extended by edu.rit.slides.items.Point
All Implemented Interfaces:
Externalizable, Serializable

public class Point
extends Object
implements Externalizable

Class Point provides an (x,y) point on a slide. Operations are provided for doing arithmetic on points.

A point is used to specify the location of a SlideItem. Class Point also keeps track of the "last point." When a slide item is created, its location is stored as the last point; see the documentation for the various slide items for more information. The static Point.last() method returns the last point; combined with point arithmetic, this can be used to position the next slide item relative to the previous slide item.

See Also:
Serialized Form

Constructor Summary
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
 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.
 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(Object obj)
          Determine if this point is equal to the given object.
 int hashCode()
          Returns a hash code for this point.
static Point last()
          Returns the last 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(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.
 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(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
clone, finalize, 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

last

public static Point last()
Returns the last point.


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.

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(ObjectOutput out)
                   throws IOException
Write this point to the given object output stream.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Read this point from the given object input stream.

Specified by:
readExternal in interface Externalizable
Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.

equals

public boolean equals(Object obj)
Determine if this point is equal to the given object.

Overrides:
equals in class 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 Object

toString

public String toString()
Returns a string version of this point.

Overrides:
toString in class Object


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.