org.garret.perst
Class Rectangle

java.lang.Object
  extended by org.garret.perst.Rectangle
All Implemented Interfaces:
java.lang.Cloneable, IValue

public class Rectangle
extends java.lang.Object
implements IValue, java.lang.Cloneable

R2 rectangle class. This class is used in spatial index.


Constructor Summary
Rectangle()
          Default constructor for PERST
Rectangle(int top, int left, int bottom, int right)
          Construct rectangle with specified coordinates
Rectangle(Rectangle r)
          Create copy of the rectangle
 
Method Summary
 long area()
          Rectangle area
 java.lang.Object clone()
          Clone rectangle
 boolean contains(Rectangle r)
          Checks if this rectangle contains the specified rectangle
 boolean equals(java.lang.Object o)
          Check if two rectangles are equal
 int getBottom()
          Greatest Y coordinate of the rectangle
 int getLeft()
          Smallest X coordinate of the rectangle
 int getRight()
          Greatest X coordinate of the rectangle
 int getTop()
          Smallest Y coordinate of the rectangle
 int hashCode()
          Hash code consists of all rectangle coordinates
 boolean intersects(Rectangle r)
          Checks if this rectangle intersects with specified rectangle
 void join(Rectangle r)
          Join two rectangles.
static Rectangle join(Rectangle a, Rectangle b)
          Non destructive join of two rectangles.
static long joinArea(Rectangle a, Rectangle b)
          Area of covered rectangle for two sepcified rectangles
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rectangle

public Rectangle()
Default constructor for PERST


Rectangle

public Rectangle(int top,
                 int left,
                 int bottom,
                 int right)
Construct rectangle with specified coordinates


Rectangle

public Rectangle(Rectangle r)
Create copy of the rectangle

Method Detail

area

public final long area()
Rectangle area


clone

public java.lang.Object clone()
Clone rectangle

Overrides:
clone in class java.lang.Object

contains

public final boolean contains(Rectangle r)
Checks if this rectangle contains the specified rectangle


equals

public boolean equals(java.lang.Object o)
Check if two rectangles are equal

Overrides:
equals in class java.lang.Object

getBottom

public final int getBottom()
Greatest Y coordinate of the rectangle


getLeft

public final int getLeft()
Smallest X coordinate of the rectangle


getRight

public final int getRight()
Greatest X coordinate of the rectangle


getTop

public final int getTop()
Smallest Y coordinate of the rectangle


hashCode

public int hashCode()
Hash code consists of all rectangle coordinates

Overrides:
hashCode in class java.lang.Object

intersects

public final boolean intersects(Rectangle r)
Checks if this rectangle intersects with specified rectangle


join

public final void join(Rectangle r)
Join two rectangles. This rectangle is updates to contain cover of this and specified rectangle.

Parameters:
r - rectangle to be joined with this rectangle

join

public static Rectangle join(Rectangle a,
                             Rectangle b)
Non destructive join of two rectangles.

Parameters:
a - first joined rectangle
b - second joined rectangle
Returns:
rectangle containing cover of these two rectangles

joinArea

public static long joinArea(Rectangle a,
                            Rectangle b)
Area of covered rectangle for two sepcified rectangles


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object