Rectangle

Instances of this class represent rectangular areas in an (x, y) coordinate system. The top left corner of the rectangle is specified by its x and y values, and the extent of the rectangle is specified by its width and height. <p> The coordinate space for rectangles and points is considered to have increasing values downward and to the right from its origin making this the normal, computer graphics oriented notion of (x, y) coordinates rather than the strict mathematical one. </p> <p> The hashCode() method in this class uses the values of the public fields to compute the hash value. When storing instances of the class in hashed collections, do not modify these fields after the object has been inserted. </p> <p> Application code does <em>not</em> need to explicitly release the resources managed by each instance when those instances are no longer required, and thus no <code>dispose()</code> method is provided. </p>

@see Point @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this(int x, int y, int width, int height)

Construct a new instance of this class given the x, y, width and height values.

Members

Functions

add
void add(Rectangle rect)

Destructively replaces the x, y, width and height values in the receiver with ones which represent the union of the rectangles specified by the receiver and the given rectangle. <p> The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles. </p>

contains
bool contains(int x, int y)

Returns <code>true</code> if the point specified by the arguments is inside the area specified by the receiver, and <code>false</code> otherwise.

contains
bool contains(Point pt)

Returns <code>true</code> if the given point is inside the area specified by the receiver, and <code>false</code> otherwise.

intersect
void intersect(Rectangle rect)

Destructively replaces the x, y, width and height values in the receiver with ones which represent the intersection of the rectangles specified by the receiver and the given rectangle.

intersection
Rectangle intersection(Rectangle rect)

Returns a new rectangle which represents the intersection of the receiver and the given rectangle. <p> The intersection of two rectangles is the rectangle that covers the area which is contained within both rectangles. </p>

intersects
bool intersects(int x, int y, int width, int height)

Returns <code>true</code> if the rectangle described by the arguments intersects with the receiver and <code>false</code> otherwise. <p> Two rectangles intersect if the area of the rectangle representing their intersection is not empty. </p>

intersects
bool intersects(Rectangle rect)

Returns <code>true</code> if the given rectangle intersects with the receiver and <code>false</code> otherwise. <p> Two rectangles intersect if the area of the rectangle representing their intersection is not empty. </p>

isEmpty
bool isEmpty()

Returns <code>true</code> if the receiver does not cover any area in the (x, y) coordinate plane, and <code>false</code> if the receiver does cover some area in the plane. <p> A rectangle is considered to <em>cover area</em> in the (x, y) coordinate plane if both its width and height are non-zero. </p>

makeUnion
Rectangle makeUnion(Rectangle rect)

Returns a new rectangle which represents the union of the receiver and the given rectangle. <p> The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles. </p>

opEquals
equals_t opEquals(Object object)

Compares the argument to the receiver, and returns true if they represent the <em>same</em> object using a class specific comparison.

toHash
hash_t toHash()

Returns an integer hash code for the receiver. Any two objects that return <code>true</code> when passed to <code>equals</code> must return the same value for this method.

toString
String toString()

Returns a string containing a concise, human-readable description of the receiver.

Variables

height
int height;

the height of the rectangle

width
int width;

the width of the rectangle

x
int x;

the x coordinate of the rectangle

y
int y;

the y coordinate of the rectangle

Meta