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
@API(type=EXTENDABLE, src=PRIVATE) public class Rectangle extends java.lang.Object implements Shape
Rectangle.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
adjacent(Rectangle r)
java.lang.Object
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
contains(Rectangle r)
Checks whether or not thisRectangle
entirely contains the specifiedRectangle
.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 thisRectangle
with the specifiedRectangle
.boolean
intersects(int rX, int rY, int rW, int rH)
Determines whether or not thisRectangle
and the specifiedRectangle
intersect.boolean
intersects(Rectangle r)
Determines whether or not thisRectangle
and the specifiedRectangle
intersect.static void
main(java.lang.String[] args)
TC main.java.lang.String
toString()
Returns aString
representing thisRectangle
and its values.Shape
translate(int tx, int ty)
Translate the shape into another one.Rectangle
union(Rectangle r)
Computes the union of thisRectangle
with the specifiedRectangle
.
-
-
-
Constructor Detail
-
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
public Rectangle(Rectangle r)
Copy constructor.- Parameters:
r
- The other rectangle to be used.
-
-
Method Detail
-
intersects
public final boolean intersects(Rectangle r)
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
public boolean contains(Rectangle r)
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
public java.lang.String toString()
Returns aString
representing thisRectangle
and its values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
representing thisRectangle
object's coordinate and size values.
-
equals
public boolean equals(java.lang.Object obj)
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
.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- theObject
to compare with thisRectangle
- Returns:
true
if the objects are equal;false
otherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
union
public Rectangle union(Rectangle r)
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
public boolean adjacent(Rectangle r)
- 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
public Rectangle intersection(Rectangle r)
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
public static void main(java.lang.String[] args)
TC main.- Parameters:
args
- Main args
-
getBounds
public Rectangle getBounds()
- Specified by:
getBounds
in interfaceShape
- Returns:
- The bounds of this shape.
- See Also:
Shape.getBounds()
-
translate
public Shape translate(int tx, int ty)
Description copied from interface:Shape
Translate the shape into another one.- Specified by:
translate
in interfaceShape
- Parameters:
tx
- the distance by which coordinates are translated in the X axis directionty
- the distance by which coordinates are translated in the Y axis direction- Returns:
- The newly translated shape
- See Also:
Shape.translate(int, int)
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
- See Also:
Object.clone()
-
-