jjil.core
Class Rect

java.lang.Object
  extended by jjil.core.Rect

public class Rect
extends java.lang.Object

Rect represents a rectangular region. The rectangle is specified using its upper left coordinate and size or the upper left and lower right coordinates. Methods allow the addition of a new point to the rectangle, merging rectangles, computing rectangle size, etc.

Author:
webb

Constructor Summary
Rect()
          Creates a new instance of Rect
Rect(int nTlx, int nTly, int nWidth, int nHeight)
          Create a new Rect specifying the upper left coordinate and size.
Rect(Point p)
          Create a new Rect (0 width and height) from a single point.
Rect(Point p1, Point p2)
          Create a new Rect specifying two corners.
 
Method Summary
 void add(Point p)
          Add a new point to the Rect, extending it if necessary.
 int getArea()
          Return area of the rectangle.
 int getHeight()
          Return the height of the rectangle.
 int getLeft()
          Return the left (horizontal) position of the rectangle.
 int getTop()
          Return the top (vertical) position of the rectangle.
 int getWidth()
          Return the width of the rectangle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rect

public Rect()
Creates a new instance of Rect


Rect

public Rect(int nTlx,
            int nTly,
            int nWidth,
            int nHeight)
Create a new Rect specifying the upper left coordinate and size.

Parameters:
nTlx - the upper left x (horizontal) coordinate
nTly - the upper left y (vertical) coordinate
nWidth - the width
nHeight - the height

Rect

public Rect(Point p1,
            Point p2)
Create a new Rect specifying two corners.

Parameters:
p1 - the first corner.
p2 - the second corner.

Rect

public Rect(Point p)
Create a new Rect (0 width and height) from a single point.

Parameters:
p - the point.
Method Detail

add

public void add(Point p)
Add a new point to the Rect, extending it if necessary.

Parameters:
p - the new Point

getArea

public int getArea()
Return area of the rectangle.

Returns:
the Rect's area.

getLeft

public int getLeft()
Return the left (horizontal) position of the rectangle.

Returns:
returns the left edge of the rectangle.

getHeight

public int getHeight()
Return the height of the rectangle.

Returns:
the rectangle's height.

getTop

public int getTop()
Return the top (vertical) position of the rectangle.

Returns:
the top (vertical) edge of the rectangle.

getWidth

public int getWidth()
Return the width of the rectangle.

Returns:
the width of the rectangle.