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 TypeMethodDescriptionbooleanclone()booleancontains(int x, int y) Checks whether or not thisRectanglecontains the point at the specified location (x, y).booleancontains(int X, int Y, int W, int H) Checks whether thisRectangleentirely contains theRectangleat the specified location ( X , Y ) with the specified dimensions ( W , H ).booleanChecks whether or not thisRectangleentirely contains the specifiedRectangle.booleanChecks whether two rectangles are equal.intintgetWidth()intgetX()intgetY()inthashCode()Computes the intersection of thisRectanglewith the specifiedRectangle.final booleanintersects(int rX, int rY, int rW, int rH) Determines whether or not thisRectangleand the specifiedRectangleintersect.final booleanDetermines whether or not thisRectangleand the specifiedRectangleintersect.static voidTC main.toString()Returns aStringrepresenting thisRectangleand its values.translate(int tx, int ty) Translate the shape into another one.Computes the union of thisRectanglewith 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 thisRectangleand the specifiedRectangleintersect. Two rectangles intersect if their intersection is nonempty.- Parameters:
r- the specifiedRectangle- Returns:
trueif the specifiedRectangleand thisRectangleintersect;falseotherwise.
-
intersects
public final boolean intersects(int rX, int rY, int rW, int rH) Determines whether or not thisRectangleand the specifiedRectangleintersect. Two rectangles intersect if their intersection is nonempty.- Parameters:
rX- X of rectrY- Y of rectrW- Width of rectrH- Height of rect- Returns:
trueif the specifiedRectangleand thisRectangleintersect;falseotherwise.
-
contains
Checks whether or not thisRectangleentirely contains the specifiedRectangle.- Parameters:
r- the specifiedRectangle- Returns:
trueif theRectangleis contained entirely inside thisRectangle;falseotherwise.
-
contains
public boolean contains(int X, int Y, int W, int H) Checks whether thisRectangleentirely contains theRectangleat the specified location ( X , Y ) with the specified dimensions ( W , H ).- Specified by:
containsin interfaceShape- Parameters:
X- the specified x coordinateY- the specified y coordinateW- the width of theRectangleH- the height of theRectangle- Returns:
trueif theRectanglespecified by ( X , Y , W , H ) is entirely enclosed inside thisRectangle;falseotherwise.
-
contains
public boolean contains(int x, int y) Checks whether or not thisRectanglecontains the point at the specified location (x, y). -
toString
Returns aStringrepresenting thisRectangleand its values. -
equals
Checks whether two rectangles are equal.The result is
trueif and only if the argument is notnulland is aRectangleobject that has the same top-left corner, width, and height as thisRectangle. -
hashCode
public int hashCode() -
union
Computes the union of thisRectanglewith the specifiedRectangle. Returns a newRectanglethat represents the union of the two rectangles- Parameters:
r- the specifiedRectangle- Returns:
- the smallest
Rectanglecontaining both the specifiedRectangleand 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 thisRectanglewith the specifiedRectangle. Returns a newRectanglethat 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
Rectanglecontained in both the specifiedRectangleand 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:ShapeTranslate the shape into another one. -
clone
-