
Eclipse Platform Release 4.2 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.eclipse.swt.graphics.Rectangle
public final class 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.
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.
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.
Application code does not need to explicitly release the
resources managed by each instance when those instances are no longer
required, and thus no dispose()
method is provided.
Point
,
Sample code and further information,
Serialized FormField Summary  

int 
height
the height of the rectangle 
int 
width
the width of the rectangle 
int 
x
the x coordinate of the rectangle 
int 
y
the y coordinate of the rectangle 
Constructor Summary  

Rectangle(int x,
int y,
int width,
int height)
Construct a new instance of this class given the x, y, width and height values. 
Method Summary  

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. 
boolean 
contains(int x,
int y)
Returns true if the point specified by the
arguments is inside the area specified by the receiver,
and false otherwise. 
boolean 
contains(Point pt)
Returns true if the given point is inside the
area specified by the receiver, and false
otherwise. 
boolean 
equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. 
int 
hashCode()
Returns an integer hash code for the receiver. 
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. 
Rectangle 
intersection(Rectangle rect)
Returns a new rectangle which represents the intersection of the receiver and the given rectangle. 
boolean 
intersects(int x,
int y,
int width,
int height)
Returns true if the rectangle described by the
arguments intersects with the receiver and false
otherwise. 
boolean 
intersects(Rectangle rect)
Returns true if the given rectangle intersects
with the receiver and false otherwise. 
boolean 
isEmpty()
Returns true if the receiver does not cover any
area in the (x, y) coordinate plane, and false if
the receiver does cover some area in the plane. 
String 
toString()
Returns a string containing a concise, humanreadable description of the receiver. 
Rectangle 
union(Rectangle rect)
Returns a new rectangle which represents the union of the receiver and the given rectangle. 
Methods inherited from class java.lang.Object 

clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Field Detail 

public int x
public int y
public int width
public int height
Constructor Detail 

public Rectangle(int x, int y, int width, int height)
x
 the x coordinate of the origin of the rectangley
 the y coordinate of the origin of the rectanglewidth
 the width of the rectangleheight
 the height of the rectangleMethod Detail 

public void add(Rectangle rect)
The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles.
rect
 the rectangle to merge with the receiver
IllegalArgumentException
 public boolean contains(int x, int y)
true
if the point specified by the
arguments is inside the area specified by the receiver,
and false
otherwise.
x
 the x coordinate of the point to test for containmenty
 the y coordinate of the point to test for containment
true
if the rectangle contains the point and false
otherwisepublic boolean contains(Point pt)
true
if the given point is inside the
area specified by the receiver, and false
otherwise.
pt
 the point to test for containment
true
if the rectangle contains the point and false
otherwise
IllegalArgumentException
 public boolean equals(Object object)
equals
in class Object
object
 the object to compare with this object
true
if the object is the same as this object and false
otherwisehashCode()
public int hashCode()
true
when passed to
equals
must return the same value for this
method.
hashCode
in class Object
equals(Object)
public void intersect(Rectangle rect)
rect
 the rectangle to intersect with the receiver
IllegalArgumentException
 public Rectangle intersection(Rectangle rect)
The intersection of two rectangles is the rectangle that covers the area which is contained within both rectangles.
rect
 the rectangle to intersect with the receiver
IllegalArgumentException
 public boolean intersects(int x, int y, int width, int height)
true
if the rectangle described by the
arguments intersects with the receiver and false
otherwise.
Two rectangles intersect if the area of the rectangle representing their intersection is not empty.
x
 the x coordinate of the origin of the rectangley
 the y coordinate of the origin of the rectanglewidth
 the width of the rectangleheight
 the height of the rectangle
true
if the rectangle intersects with the receiver, and false
otherwise
IllegalArgumentException
 intersection(Rectangle)
,
isEmpty()
public boolean intersects(Rectangle rect)
true
if the given rectangle intersects
with the receiver and false
otherwise.
Two rectangles intersect if the area of the rectangle representing their intersection is not empty.
rect
 the rectangle to test for intersection
true
if the rectangle intersects with the receiver, and false
otherwise
IllegalArgumentException
 intersection(Rectangle)
,
isEmpty()
public boolean isEmpty()
true
if the receiver does not cover any
area in the (x, y) coordinate plane, and false
if
the receiver does cover some area in the plane.
A rectangle is considered to cover area in the (x, y) coordinate plane if both its width and height are nonzero.
true
if the receiver is empty, and false
otherwisepublic String toString()
toString
in class Object
public Rectangle union(Rectangle rect)
The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles.
rect
 the rectangle to perform union with
IllegalArgumentException
 add(Rectangle)

Eclipse Platform Release 4.2 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2012. All rights reserved.