|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.maryanovsky.gwtutils.client.geom.Rectangle
public final class Rectangle
A rectangle, in integer coordinates.
Constructor Summary | |
---|---|
Rectangle()
Creates a new Rectangle of 0x0 size at
0,0 coordinates. |
|
Rectangle(int x,
int y,
int width,
int height)
Creates a new Rectangle with the specified arguments. |
|
Rectangle(PointView point,
SizeView size)
Creates a new rectangle at the specified coordinates and with the specified size. |
|
Rectangle(RectangleView rectangle)
Creates a new rectangle with the same values as the specified one. |
Method Summary | |
---|---|
boolean |
contains(PointView point)
Returns whether this rectangle contains the specified point. |
boolean |
contains(RectangleView rectangle)
Returns whether this rectangle contains the specified one. |
boolean |
equals(int x,
int y,
int width,
int height)
Returns whether the coordinates and size of this rectangle are the specified ones. |
boolean |
equals(Object o)
Returns whether this Rectangle object has the same
coordinates and size as this one. |
boolean |
equals(RectangleView rect)
Returns whether the specified rectangle is the same as this one. |
Rectangle |
expandToGrid(int cellWidth,
int cellHeight)
Expands this rectangle so that it lies on the grid with cells of the specified size. |
Rectangle |
expandToGrid(SizeView cellSize)
Expands this rectangle so that it lies on the grid with cells of the specified size. |
int |
getBottom()
Same as getY() + getHeight() . |
PointView |
getBottomLeft()
Returns the location of the bottom-left point. |
Point |
getBottomLeft(Point reusable)
Returns the location of the bottom-left point of the rectangle. |
PointView |
getBottomRight()
Returns the location of the bottom-right point. |
Point |
getBottomRight(Point reusable)
Returns the location of the bottom-right point of the rectangle. |
PointView |
getCenter()
Returns the location of the center of the rectangle. |
Point |
getCenter(Point reusable)
Returns the location of the center of the rectangle, in the same manner as the getCenter() method. |
int |
getHeight()
Returns the height of the rectangle. |
RectangleView |
getIntersection(RectangleView rectangle)
Returns the intersection between this rectangle and the specified one. |
Rectangle |
getIntersection(RectangleView rectangle,
Rectangle reusable)
Returns the intersection between this rectangle and the specified one. |
int |
getLeft()
Same as getX() . |
int |
getRight()
Same as getX() + getWidth() . |
SizeView |
getSize()
Returns the size of the rectangle. |
Size |
getSize(Size reusable)
Returns the size of the rectangle. |
int |
getTop()
Same as getY() . |
PointView |
getTopLeft()
Returns the location of the top-left point. |
Point |
getTopLeft(Point reusable)
Returns the location of the top-left point of the rectangle. |
PointView |
getTopRight()
Returns the location of the top-right point. |
Point |
getTopRight(Point reusable)
Returns the location of the top-right point of the rectangle. |
int |
getWidth()
Returns the width of the rectangle. |
int |
getX()
Returns the X coordinate of the top-left point. |
int |
getY()
Returns the Y coordinate of the top-left point. |
Rectangle |
growBy(int dx,
int dy)
Grows the dimensions of the rectangle by the specified values. |
Rectangle |
growBy(PointView point)
Grows the dimensions of the rectangle by the values of the specified point. |
Rectangle |
growBy(SizeView size)
Grows the dimensions of the rectangle by the specified size. |
int |
hashCode()
Returns the hashcode of this object. |
boolean |
intersects(RectangleView rectangle)
Returns whether this rectangle intersects with the specified one. |
static Rectangle |
make(int x,
int y,
int width,
int height,
Rectangle reusable)
Returns a Rectangle with the specified values. |
static Rectangle |
makeCover(PointView point1,
PointView point2)
Returns the smallest rectangle which contains both specified points. |
Rectangle |
moveBy(int dx,
int dy)
Moves the rectangle by the specified offsets. |
Rectangle |
moveBy(PointView point)
Moves the rectangle by the offsets specified by the given point. |
Rectangle |
moveBy(SizeView size)
Moves the rectangle by the offsets specified by the given size. |
Rectangle |
multiplyBy(double coefficient)
Multiplies the coordinates and dimensions of this rectangle by the specified coefficient. |
Rectangle |
set(int x,
int y,
int width,
int height)
Sets the values of this rectangle. |
Rectangle |
set(PointView point,
SizeView size)
Sets the values of this rectangle. |
Rectangle |
set(RectangleView rect)
Sets the values of this rectangle to those of the specified one. |
Rectangle |
setCover(PointView point1,
PointView point2)
Sets this rectangle to the smallest rectangle which contains both specified points. |
Rectangle |
setHeight(int height)
Sets the height of the rectangle. |
Rectangle |
setSize(int width,
int height)
Sets the size of the rectangle. |
Rectangle |
setSize(SizeView size)
Sets the size of the rectangle. |
Rectangle |
setTopLeft(int x,
int y)
Sets the location of the top-left point. |
Rectangle |
setTopLeft(PointView point)
Sets the location of the top-left point. |
Rectangle |
setWidth(int width)
Sets the width of the rectangle. |
Rectangle |
setX(int x)
Sets the X coordinate of the top-left point. |
Rectangle |
setY(int y)
Sets the Y coordinate of the top-left point. |
String |
toString()
Returns a textual representation of this rectangle. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Rectangle(int x, int y, int width, int height)
Rectangle
with the specified arguments.
Note that if width
and/or height
are negative,
the rectangle is normalized (the top-left point is moved accordingly, and
and the width and/or height are set to the absolute values of the
specified ones).
x
- The X coordinate of the top-left point.y
- The Y coordinate of the top-left point.width
- The width of the rectangle.height
- The height of the rectangle.public Rectangle()
Rectangle
of 0x0
size at
0,0
coordinates.
public Rectangle(RectangleView rectangle)
public Rectangle(PointView point, SizeView size)
Method Detail |
---|
public static Rectangle make(int x, int y, int width, int height, Rectangle reusable)
Rectangle
with the specified values. If the given
Rectangle
is not null
, it is reused and
returned.
public static Rectangle makeCover(PointView point1, PointView point2)
public Rectangle set(int x, int y, int width, int height)
this
.public Rectangle set(PointView point, SizeView size)
public Rectangle set(RectangleView rect)
public SizeView getSize()
getSize
in interface RectangleView
public Size getSize(Size reusable)
Size
object is not null
, it is reused and returned.
getSize
in interface RectangleView
public Rectangle setSize(int width, int height)
this
.public Rectangle setSize(SizeView size)
this
.public PointView getTopLeft()
getTopLeft
in interface RectangleView
public Point getTopLeft(Point reusable)
Point
object is not null
, it is
reused and returned.
getTopLeft
in interface RectangleView
public PointView getTopRight()
getTopRight
in interface RectangleView
public Point getTopRight(Point reusable)
Point
object is not null
, it is
reused and returned.
getTopRight
in interface RectangleView
public PointView getBottomLeft()
getBottomLeft
in interface RectangleView
public Point getBottomLeft(Point reusable)
Point
object is not null
, it is
reused and returned.
getBottomLeft
in interface RectangleView
public PointView getBottomRight()
getBottomRight
in interface RectangleView
public Point getBottomRight(Point reusable)
Point
object is not null
, it is
reused and returned.
getBottomRight
in interface RectangleView
public PointView getCenter()
getCenter
in interface RectangleView
public Point getCenter(Point reusable)
Point
object is not null
, it is reused and
returned.
getCenter
in interface RectangleView
public Rectangle setTopLeft(int x, int y)
this
.public Rectangle setTopLeft(PointView point)
this
.public Rectangle moveBy(int dx, int dy)
this
.public Rectangle moveBy(SizeView size)
this
.public Rectangle moveBy(PointView point)
this
.public Rectangle growBy(int dx, int dy)
this
.public Rectangle growBy(SizeView size)
this
.public Rectangle growBy(PointView point)
public Rectangle multiplyBy(double coefficient)
this
.public Rectangle setCover(PointView point1, PointView point2)
this
.public boolean contains(PointView point)
contains
in interface RectangleView
public boolean contains(RectangleView rectangle)
contains
in interface RectangleView
public boolean intersects(RectangleView rectangle)
intersects
in interface RectangleView
public RectangleView getIntersection(RectangleView rectangle)
null
if the two rectangles do not intersect and do
not even "touch". Returns an empty rectangle if the two rectangles
"touch".
getIntersection
in interface RectangleView
public Rectangle getIntersection(RectangleView rectangle, Rectangle reusable)
null
if the two rectangles do not intersect and do
not even "touch". Returns an empty rectangle if the two rectangles
"touch".
If the specified Rectangle
object is not null
,
it is reused and returned (unless, as above, null
is
returned).
getIntersection
in interface RectangleView
public Rectangle expandToGrid(int cellWidth, int cellHeight)
this
.public Rectangle expandToGrid(SizeView cellSize)
this
.public int getX()
getX
in interface RectangleView
public Rectangle setX(int x)
this
.public int getY()
getY
in interface RectangleView
public Rectangle setY(int y)
this
.public int getWidth()
getWidth
in interface RectangleView
public Rectangle setWidth(int width)
this
.public int getHeight()
getHeight
in interface RectangleView
public Rectangle setHeight(int height)
this
.public int getLeft()
getX()
.
getLeft
in interface RectangleView
public int getTop()
getY()
.
getTop
in interface RectangleView
public int getRight()
getX() + getWidth()
.
getRight
in interface RectangleView
public int getBottom()
getY() + getHeight()
.
getBottom
in interface RectangleView
public boolean equals(int x, int y, int width, int height)
public boolean equals(RectangleView rect)
public boolean equals(Object o)
Rectangle
object has the same
coordinates and size as this one.
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |