maclib
Class Point

java.lang.Object
  extended by maclib.Point

public class Point
extends java.lang.Object

This class hides the class java.awt.Point in order to implement QuickDraw-like definitions for points. Implements also object methods for these points.

Version:
28 may 2001
Author:
Philippe Chassignet, Ecole Polytechnique
See Also:
MacLib, Point

Field Summary
 short h
          The x coordinate, as named in QuickDraw.
 short v
          The y coordinate, as named in QuickDraw.
 
Constructor Summary
Point()
          Constructs and initializes a point at coordinates (0,0).
Point(int h, int v)
          Constructs and initializes a point at the given coordinates.
 
Method Summary
 Point addPt(Point p)
          Translates this point by the displacement vector specified as the given point.
 boolean equalPt(Point pt)
          Determines whether this point and the given point have the same coordinates.
 boolean equalPt(java.awt.Point pt)
          Determines whether this point and the given point have the same coordinates.
 java.awt.Point getPoint()
          Converts this point as a java.awt.Point object.
 int hashCode()
          Returns a hash code for this point.
 boolean inRect(Rect r)
          Determines whether the pixel below and to the right of this point is enclosed in the specified rectangle.
 Point setPt(int h, int v)
          Sets the coordinates of this point to the specified location.
 Point setPt(Point pt)
          Sets the coordinates of this point as specified by the given Point object.
 Point setPt(java.awt.Point pt)
          Sets the coordinates of this point as specified by the given java.awt.Point object.
 Point subPt(Point p)
          Translates this point by the displacement vector specified as the inverse of the given point.
 java.lang.String toString()
          Returns a string representation for the location of this point.
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

h

public short h
The x coordinate, as named in QuickDraw.


v

public short v
The y coordinate, as named in QuickDraw.

Constructor Detail

Point

public Point()
Constructs and initializes a point at coordinates (0,0).


Point

public Point(int h,
             int v)
Constructs and initializes a point at the given coordinates.

Parameters:
h - the h coordinate of the new point.
v - the v coordinate of the new point.
Method Detail

getPoint

public java.awt.Point getPoint()
Converts this point as a java.awt.Point object.

Returns:
a new java.awt.Point object.
See Also:
Point

setPt

public Point setPt(int h,
                   int v)
Sets the coordinates of this point to the specified location.

Parameters:
h - the h coordinate of the new location.
v - the v coordinate of the new location.

setPt

public Point setPt(Point pt)
Sets the coordinates of this point as specified by the given Point object.

Parameters:
pt - the Point object used to specify the coordinates.

setPt

public Point setPt(java.awt.Point pt)
Sets the coordinates of this point as specified by the given java.awt.Point object.

Parameters:
pt - the java.awt.Point object that gives the coordinates.

addPt

public Point addPt(Point p)
Translates this point by the displacement vector specified as the given point. Adds the coordinates of p to the coordinates of this point.

Parameters:
p - the Point object used as a vector to specify the displacement.

subPt

public Point subPt(Point p)
Translates this point by the displacement vector specified as the inverse of the given point. Subtracts the coordinates of p from the coordinates of this point.

Parameters:
p - the Point object used as a vector to specify the displacement.

equalPt

public boolean equalPt(Point pt)
Determines whether this point and the given point have the same coordinates.

Parameters:
pt - the Point object to compare with.
Returns:
true if both points have same coordinates; false otherwise.

equalPt

public boolean equalPt(java.awt.Point pt)
Determines whether this point and the given point have the same coordinates.

Parameters:
pt - the java.awt.Point object to compare with.
Returns:
true if both points have same coordinates; false otherwise.
See Also:
Point

inRect

public boolean inRect(Rect r)
Determines whether the pixel below and to the right of this point is enclosed in the specified rectangle.

Parameters:
r - the Rect object to check with.
Returns:
true if so; false otherwise.
See Also:
Rect.ptInRect(Point)

toString

public java.lang.String toString()
Returns a string representation for the location of this point.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the coordinates.

hashCode

public int hashCode()
Returns a hash code for this point.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code build up from the coordinates.