@API(type=EXTENDABLE, src=PRIVATE) public class Rectangle extends java.lang.Object implements Shape
Modifier and Type | Field and Description |
---|---|
int |
height
The height.
|
int |
width
The width.
|
int |
x
The x.
|
int |
y
The y.
|
Constructor and Description |
---|
Rectangle(int x,
int y,
int width,
int height)
Constructor.
|
Rectangle(Rectangle r)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
adjacent(Rectangle r) |
java.lang.Object |
clone() |
boolean |
contains(int x,
int y)
Checks whether or not this
Rectangle contains the
point at the specified location
(x, y). |
boolean |
contains(int X,
int Y,
int W,
int H)
Checks whether this
Rectangle entirely contains the Rectangle at
the specified location ( X , Y ) with the specified dimensions ( W
, H ). |
boolean |
contains(Rectangle r)
Checks whether or not this
Rectangle entirely contains the specified
Rectangle . |
boolean |
equals(java.lang.Object obj)
Checks whether two rectangles are equal.
|
Rectangle |
getBounds() |
int |
getHeight() |
int |
getWidth() |
int |
getX() |
int |
getY() |
int |
hashCode() |
Rectangle |
intersection(Rectangle r)
Computes the intersection of this
Rectangle with the
specified Rectangle . |
boolean |
intersects(int rX,
int rY,
int rW,
int rH)
Determines whether or not this
Rectangle and the specified
Rectangle intersect. |
boolean |
intersects(Rectangle r)
Determines whether or not this
Rectangle and the specified
Rectangle intersect. |
static void |
main(java.lang.String[] args)
TC main.
|
java.lang.String |
toString()
Returns a
String representing this
Rectangle and its values. |
Shape |
translate(int tx,
int ty)
Translate the shape into another one.
|
Rectangle |
union(Rectangle r)
Computes the union of this
Rectangle with the
specified Rectangle . |
public int width
public int height
public int x
public int y
public Rectangle(int x, int y, int width, int height)
x
- The x coordinate.y
- The y coordinate.width
- The width.height
- The height.public Rectangle(Rectangle r)
r
- The other rectangle to be used.public final boolean intersects(Rectangle r)
Rectangle
and the specified
Rectangle
intersect. Two rectangles intersect if their intersection is nonempty.r
- the specified Rectangle
true
if the specified Rectangle
and this
Rectangle
intersect; false
otherwise.public final boolean intersects(int rX, int rY, int rW, int rH)
Rectangle
and the specified
Rectangle
intersect. Two rectangles intersect if their intersection is nonempty.rX
- X of rectrY
- Y of rectrW
- Width of rectrH
- Height of recttrue
if the specified Rectangle
and this
Rectangle
intersect; false
otherwise.public boolean contains(Rectangle r)
Rectangle
entirely contains the specified
Rectangle
.r
- the specified Rectangle
true
if the Rectangle
is contained entirely inside this
Rectangle
;false
otherwise.public boolean contains(int X, int Y, int W, int H)
Rectangle
entirely contains the Rectangle
at
the specified location ( X , Y ) with the specified dimensions ( W
, H ).contains
in interface Shape
X
- the specified x coordinateY
- the specified y coordinateW
- the width of the Rectangle
H
- the height of the Rectangle
true
if the Rectangle
specified by ( X ,
Y , W , H ) is entirely enclosed inside this
Rectangle
;false
otherwise.public boolean contains(int x, int y)
Rectangle
contains the
point at the specified location
(x, y).public java.lang.String toString()
String
representing this
Rectangle
and its values.toString
in class java.lang.Object
String
representing this
Rectangle
object's coordinate and size values.public boolean equals(java.lang.Object obj)
The result is true
if and only if the argument is not
null
and is a Rectangle
object that has the
same top-left corner, width, and height as this Rectangle
.
equals
in class java.lang.Object
obj
- the Object
to compare with
this Rectangle
true
if the objects are equal;
false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public Rectangle union(Rectangle r)
Rectangle
with the
specified Rectangle
. Returns a new
Rectangle
that
represents the union of the two rectanglesr
- the specified Rectangle
Rectangle
containing both
the specified Rectangle
and this
Rectangle
.public int getHeight()
public int getWidth()
public int getX()
public int getY()
public boolean adjacent(Rectangle r)
r
- The rectangle to check for adjacency.public Rectangle intersection(Rectangle r)
Rectangle
with the
specified Rectangle
. Returns a new Rectangle
that represents the intersection of the two rectangles.
If the two rectangles do not intersect, the result will be
an empty rectangle.r
- the specified Rectangle
Rectangle
contained in both the
specified Rectangle
and in
this Rectangle
; or if the rectangles
do not intersect, an empty rectangle.public static void main(java.lang.String[] args)
args
- Main argspublic Rectangle getBounds()
getBounds
in interface Shape
Shape.getBounds()
public Shape translate(int tx, int ty)
Shape
translate
in interface Shape
tx
- the distance by which coordinates are translated in the
X axis directionty
- the distance by which coordinates are translated in the
Y axis directionShape.translate(int, int)
public java.lang.Object clone()
clone
in class java.lang.Object
Object.clone()
© Copyright SyncRO Soft SRL 2002 - 2016. All rights reserved.