Package ro.sync.exml.view.graphics
Class Rectangle
java.lang.Object
ro.sync.exml.view.graphics.Rectangle
- All Implemented Interfaces:
Shape
- Direct Known Subclasses:
ImageLayoutInformation
Rectangle.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
clone()
boolean
contains
(int x, int y) Checks whether or not thisRectangle
contains the point at the specified location (x, y).boolean
contains
(int X, int Y, int W, int H) Checks whether thisRectangle
entirely contains theRectangle
at the specified location ( X , Y ) with the specified dimensions ( W , H ).boolean
Checks whether or not thisRectangle
entirely contains the specifiedRectangle
.boolean
Checks whether two rectangles are equal.int
int
getWidth()
int
getX()
int
getY()
int
hashCode()
Computes the intersection of thisRectangle
with the specifiedRectangle
.final boolean
intersects
(int rX, int rY, int rW, int rH) Determines whether or not thisRectangle
and the specifiedRectangle
intersect.final boolean
Determines whether or not thisRectangle
and the specifiedRectangle
intersect.static void
TC main.toString()
Returns aString
representing thisRectangle
and its values.translate
(int tx, int ty) Translate the shape into another one.Computes the union of thisRectangle
with the specifiedRectangle
.
-
Field Details
-
width
public int widthThe width. -
height
public int heightThe height. -
x
public int xThe x. -
y
public int yThe y.
-
-
Constructor Details
-
Rectangle
public Rectangle(int x, int y, int width, int height) Constructor.- Parameters:
x
- The x coordinate.y
- The y coordinate.width
- The width.height
- The height.
-
Rectangle
Copy constructor.- Parameters:
r
- The other rectangle to be used.
-
-
Method Details
-
intersects
Determines whether or not thisRectangle
and the specifiedRectangle
intersect. Two rectangles intersect if their intersection is nonempty.- Parameters:
r
- the specifiedRectangle
- Returns:
true
if the specifiedRectangle
and thisRectangle
intersect;false
otherwise.
-
intersects
public final boolean intersects(int rX, int rY, int rW, int rH) Determines whether or not thisRectangle
and the specifiedRectangle
intersect. Two rectangles intersect if their intersection is nonempty.- Parameters:
rX
- X of rectrY
- Y of rectrW
- Width of rectrH
- Height of rect- Returns:
true
if the specifiedRectangle
and thisRectangle
intersect;false
otherwise.
-
contains
Checks whether or not thisRectangle
entirely contains the specifiedRectangle
.- Parameters:
r
- the specifiedRectangle
- Returns:
true
if theRectangle
is contained entirely inside thisRectangle
;false
otherwise.
-
contains
public boolean contains(int X, int Y, int W, int H) Checks whether thisRectangle
entirely contains theRectangle
at the specified location ( X , Y ) with the specified dimensions ( W , H ).- Specified by:
contains
in interfaceShape
- Parameters:
X
- the specified x coordinateY
- the specified y coordinateW
- the width of theRectangle
H
- the height of theRectangle
- Returns:
true
if theRectangle
specified by ( X , Y , W , H ) is entirely enclosed inside thisRectangle
;false
otherwise.
-
contains
public boolean contains(int x, int y) Checks whether or not thisRectangle
contains the point at the specified location (x, y). -
toString
Returns aString
representing thisRectangle
and its values. -
equals
Checks whether two rectangles are equal.The result is
true
if and only if the argument is notnull
and is aRectangle
object that has the same top-left corner, width, and height as thisRectangle
. -
hashCode
public int hashCode() -
union
Computes the union of thisRectangle
with the specifiedRectangle
. Returns a newRectangle
that represents the union of the two rectangles- Parameters:
r
- the specifiedRectangle
- Returns:
- the smallest
Rectangle
containing both the specifiedRectangle
and thisRectangle
.
-
getHeight
public int getHeight()- Returns:
- The rectangle height.
-
getWidth
public int getWidth()- Returns:
- The rectangle width.
-
getX
public int getX()- Returns:
- The rectangle x coordinate.
-
getY
public int getY()- Returns:
- The rectangle y coordinate.
-
adjacent
- Parameters:
r
- The rectangle to check for adjacency.- Returns:
- True if the rectangles are neighbours around one margin and they do not intersect each other.
-
intersection
Computes the intersection of thisRectangle
with the specifiedRectangle
. Returns a newRectangle
that represents the intersection of the two rectangles. If the two rectangles do not intersect, the result will be an empty rectangle.- Parameters:
r
- the specifiedRectangle
- Returns:
- the largest
Rectangle
contained in both the specifiedRectangle
and in thisRectangle
; or if the rectangles do not intersect, an empty rectangle.
-
main
TC main.- Parameters:
args
- Main args
-
getBounds
-
translate
Description copied from interface:Shape
Translate the shape into another one. -
clone
-