org.eclipse.swt.graphics
Class Rectangle

java.lang.Object
  |
  +--org.eclipse.swt.graphics.Rectangle
All Implemented Interfaces:
Serializable, org.eclipse.swt.internal.SerializableCompatibility

public final class Rectangle
extends Object
implements org.eclipse.swt.internal.SerializableCompatibility

Safe:

See Also:
Serialized Form

Field Summary
 int height
          Enabled: the height of the rectangle
 int width
          Enabled: the width of the rectangle
 int x
          Enabled: the x coordinate of the rectangle
 int y
          Enabled: the y coordinate of the rectangle
 
Constructor Summary
Rectangle(int x, int y, int width, int height)
          Enabled: Construct a new instance of this class given the x, y, width and height values.
 
Method Summary
 void add(Rectangle rect)
          Suppressed: 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)
          Enabled: Returns true if the point specified by the arguments is inside the area specified by the receiver, and false otherwise.
 boolean contains(Point pt)
          Enabled: Returns true if the given point is inside the area specified by the receiver, and false otherwise.
 boolean equals(Object object)
          Suppressed: Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
 int hashCode()
          Suppressed: Returns an integer hash code for the receiver.
 Rectangle intersection(Rectangle rect)
          Enabled: Returns a new rectangle which represents the intersection of the receiver and the given rectangle.
 boolean intersects(Rectangle rect)
          Enabled: Returns true if the given rectangle intersects with the receiver and false otherwise.
 boolean isEmpty()
          Enabled: 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()
          Suppressed: Returns a string containing a concise, human-readable description of the receiver.
 Rectangle union(Rectangle rect)
          Enabled: 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

x

public int x
Enabled: the x coordinate of the rectangle


y

public int y
Enabled: the y coordinate of the rectangle


width

public int width
Enabled: the width of the rectangle


height

public int height
Enabled: the height of the rectangle

Constructor Detail

Rectangle

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

Parameters:
x - the x coordinate of the origin of the rectangle
y - the y coordinate of the origin of the rectangle
width - the width of the rectangle
height - the height of the rectangle
Method Detail

add

public void add(Rectangle rect)
Suppressed: 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.

The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles.

Parameters:
rect - the rectangle to merge with the receiver

contains

public boolean contains(int x,
                        int y)
Enabled: Returns true if the point specified by the arguments is inside the area specified by the receiver, and false otherwise.

Parameters:
x - the x coordinate of the point to test for containment
y - the y coordinate of the point to test for containment
Returns:
true if the rectangle contains the point and false otherwise

contains

public boolean contains(Point pt)
Enabled: Returns true if the given point is inside the area specified by the receiver, and false otherwise.

Parameters:
pt - the point to test for containment
Returns:
true if the rectangle contains the point and false otherwise

equals

public boolean equals(Object object)
Suppressed: Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Overrides:
equals in class Object
Parameters:
object - the object to compare with this object
Returns:
true if the object is the same as this object and false otherwise
See Also:
hashCode()

hashCode

public int hashCode()
Suppressed: Returns an integer hash code for the receiver. Any two objects which return true when passed to equals must return the same value for this method.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

intersection

public Rectangle intersection(Rectangle rect)
Enabled: Returns a new rectangle which represents the intersection of the receiver and the given rectangle.

The intersection of two rectangles is the rectangle that covers the area which is contained within both rectangles.

Parameters:
rect - the rectangle to intersect with the receiver
Returns:
the intersection of the receiver and the argument

intersects

public boolean intersects(Rectangle rect)
Enabled: Returns 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.

Parameters:
rect - the rectangle to test for intersection
Returns:
true if the rectangle intersects with the receiver, and false otherwise
See Also:
intersection(org.eclipse.swt.graphics.Rectangle), isEmpty()

isEmpty

public boolean isEmpty()
Enabled: 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.

A rectangle is considered to cover area in the (x, y) coordinate plane if both its width and height are non-zero.

Returns:
true if the receiver is empty, and false otherwise

toString

public String toString()
Suppressed: Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
a string representation of the rectangle

union

public Rectangle union(Rectangle rect)
Enabled: Returns a new rectangle which represents the union of the receiver and the given rectangle.

The union of two rectangles is the smallest single rectangle that completely covers both of the areas covered by the two given rectangles.

Parameters:
rect - the rectangle to perform union with
Returns:
the union of the receiver and the argument
See Also:
add(org.eclipse.swt.graphics.Rectangle)


comments?