| java.lang.Object org.eclipse.swt.graphics.Rectangle
Rectangle | final public class Rectangle implements SerializableCompatibility(Code) | | 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.
See Also: Point |
Constructor Summary | |
public | 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 | |
public 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. | public 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. | public boolean | contains(Point pt) Returns true if the given point is inside the
area specified by the receiver, and false
otherwise. | public boolean | equals(Object object) Compares the argument to the receiver, and returns true
if they represent the same object using a class
specific comparison. | public int | hashCode() Returns an integer hash code for the receiver. | public 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. | public Rectangle | intersection(Rectangle rect) Returns a new rectangle which represents the intersection
of the receiver and the given rectangle. | public 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. | public boolean | intersects(Rectangle rect) Returns true if the given rectangle intersects
with the receiver and false otherwise. | public 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. | public String | toString() Returns a string containing a concise, human-readable
description of the receiver. | public Rectangle | union(Rectangle rect) Returns a new rectangle which represents the union of
the receiver and the given rectangle. |
height | public int height(Code) | | the height of the rectangle
|
serialVersionUID | final static long serialVersionUID(Code) | | |
width | public int width(Code) | | the width of the rectangle
|
x | public int x(Code) | | the x coordinate of the rectangle
|
y | public int y(Code) | | the y coordinate of the rectangle
|
Rectangle | public Rectangle(int x, int y, int width, int height)(Code) | | 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 Parameters: y - the y coordinate of the origin of the rectangle Parameters: width - the width of the rectangle Parameters: height - the height of the rectangle |
add | public void add(Rectangle rect)(Code) | | 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 exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
|
contains | public boolean contains(int x, int y)(Code) | | 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 Parameters: y - the y coordinate of the point to test for containment true if the rectangle contains the point and false otherwise |
contains | public boolean contains(Point pt)(Code) | | 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 true if the rectangle contains the point and false otherwise exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
|
equals | public boolean equals(Object object)(Code) | | Compares the argument to the receiver, and returns true
if they represent the same object using a class
specific comparison.
Parameters: object - the object to compare with this object true if the object is the same as this object and false otherwise See Also: Rectangle.hashCode() |
hashCode | public int hashCode()(Code) | | Returns an integer hash code for the receiver. Any two
objects that return true when passed to
equals must return the same value for this
method.
the receiver's hash See Also: Rectangle.equals(Object) |
intersect | public void intersect(Rectangle rect)(Code) | | 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.
Parameters: rect - the rectangle to intersect with the receiver exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
since 3.0 |
intersection | public Rectangle intersection(Rectangle rect)(Code) | | 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 the intersection of the receiver and the argument exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
|
intersects | public boolean intersects(int x, int y, int width, int height)(Code) | | Returns 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.
Parameters: x - the x coordinate of the origin of the rectangle Parameters: y - the y coordinate of the origin of the rectangle Parameters: width - the width of the rectangle Parameters: height - the height of the rectangle true if the rectangle intersects with the receiver, and false otherwise exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
See Also: Rectangle.intersection(Rectangle) See Also: Rectangle.isEmpty() since: 3.0 |
intersects | public boolean intersects(Rectangle rect)(Code) | | 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 true if the rectangle intersects with the receiver, and false otherwise exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
See Also: Rectangle.intersection(Rectangle) See Also: Rectangle.isEmpty() |
isEmpty | public boolean isEmpty()(Code) | | 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.
true if the receiver is empty, and false otherwise |
toString | public String toString()(Code) | | Returns a string containing a concise, human-readable
description of the receiver.
a string representation of the rectangle |
union | public Rectangle union(Rectangle rect)(Code) | | 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 the union of the receiver and the argument exception: IllegalArgumentException - - ERROR_NULL_ARGUMENT - if the argument is null
See Also: Rectangle.add(Rectangle) |
|
|