Algorithm
Development Kit 1.0

algs.model
Interface IRectangle

All Known Implementing Classes:
TwoDRectangle

public interface IRectangle

Represents a rectangle in the Cartesian plane.

Classes that implement this interface must provide accurate Object.equals(Object) and Object.hashCode() methods. To be useful during debugging, one should also have a meaningful Object.toString() method.

Note that it is an invariant that getLeft() <= getRight() while getBottom() <= getTop()

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Method Summary
 boolean contains(IRectangle r)
          Determine if rectangle contains the given rectangle r.
 boolean equals(java.lang.Object o)
          Must properly compute equals(Object) to compare based on getXXX() values.
 double getBottom()
          return the y-coordinate value for the bottom.
 double getLeft()
          return the x-coordinate value for the left-side.
 double getRight()
          return the x-coordinate value for the right-side.
 double getTop()
          return the y-coordinate value for the top.
 boolean intersects(IPoint p)
          Determine if the given point intersects the rectangle.
 

Method Detail

getLeft

double getLeft()
return the x-coordinate value for the left-side.


getBottom

double getBottom()
return the y-coordinate value for the bottom.


getRight

double getRight()
return the x-coordinate value for the right-side.


getTop

double getTop()
return the y-coordinate value for the top.


intersects

boolean intersects(IPoint p)
Determine if the given point intersects the rectangle. The rectangle presents closed intervals on both the X and Y dimension.


contains

boolean contains(IRectangle r)
Determine if rectangle contains the given rectangle r. The rectangle presents closed intervals on both the X and Y dimension.


equals

boolean equals(java.lang.Object o)
Must properly compute equals(Object) to compare based on getXXX() values.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.