Constructor and Description |
---|
Rectangle()
Creates a new instance of Rectangle
|
Rectangle(int x,
int y,
Dimension size)
Creates a new instance of Rectangle at position (x, y) and with
predefine dimension
|
Rectangle(int x,
int y,
int w,
int h)
Creates a new instance of Rectangle at position (x, y) and with
predefine width and height
|
Rectangle(Rectangle rect)
A copy Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(int rX,
int rY)
Checks whether or not this Rectangle contains the point at the specified
location (rX, rY).
|
boolean |
contains(int rX,
int rY,
int rWidth,
int rHeight)
Checks whether this Rectangle entirely contains the Rectangle
at the specified location (rX, rY) with the specified
dimensions (rWidth, rHeight).
|
static boolean |
contains(int x1,
int y1,
int w1,
int h1,
int x2,
int y2,
int w2,
int h2)
Checks wheather the 2nd rectangle is contained in the first rectangle
|
boolean |
contains(Rectangle rect)
Checks whether or not this Rectangle entirely contains the specified
Rectangle.
|
static Rectangle |
createFromPool(int x,
int y,
int w,
int h)
Creates a rectangle from a Rectangle object pool.
|
boolean |
equals(Object obj)
{Indicates whether some other object is "equal to" this one.}
|
Rectangle |
getBounds()
{Returns the bounding rectangle for the shape.}
|
float[] |
getBounds2D()
{Gets the bounds of the shape as a 4-element array representing the (x,y,width,height)
tuple.}
|
int |
getHeight()
Convenience method for getSize().getHeight();
|
PathIterator |
getPathIterator()
{Gets an iterator to walk all of the path segments of the shape.}
|
PathIterator |
getPathIterator(Transform m)
{Gets an iterator where all points are transformed by the provided transform.}
|
Dimension |
getSize()
Return the dimension of the rectangle
|
int |
getWidth()
Convenience method for getSize().getWidth();
|
int |
getX()
Return the x coordinate of the rectangle
|
int |
getY()
Return the y coordinate of the rectangle
|
int |
hashCode()
{Returns a hash code value for the object.}
|
Rectangle |
intersection(int rX,
int rY,
int rW,
int rH)
Returns a rectangle that intersects the given rectangle with this rectangle.
|
static void |
intersection(int rrX,
int rrY,
int rrW,
int rrH,
int rtx1,
int rty1,
int rtw2,
int rth2,
Rectangle dest)
Returns a rectangle that intersects the given rectangle with this rectangle
|
Rectangle |
intersection(Rectangle r)
Returns a rectangle that intersects the given rectangle with this rectangle
|
void |
intersection(Rectangle input,
Rectangle output) |
boolean |
intersects(int x,
int y,
int width,
int height)
Determines whether or not this Rectangle and the specified Rectangle
location (x, y) with the specified dimensions (width, height),
intersect.
|
static boolean |
intersects(int tx,
int ty,
int tw,
int th,
int x,
int y,
int width,
int height)
Helper method allowing us to determine if two coordinate sets intersect.
|
boolean |
intersects(Rectangle rect)
Determines whether or not this Rectangle and the specified Rectangle
location (x, y) with the specified dimensions (width, height),
intersect.
|
boolean |
isRectangle()
{Checks if this shape is a rectangle.}
|
static void |
recycle(Rectangle r)
Returns the given rectangle to the object pool.
|
void |
setBounds(int x,
int y,
int w,
int h)
Helper method to set coordinates
|
void |
setBounds(Rectangle bounds)
Sets the bounds of this rectangle.
|
void |
setHeight(int h)
Convenience method for getSize().setHeight();
|
void |
setWidth(int w)
Convenience method for getSize().setWidth();
|
void |
setX(int x)
Sets the x position of the rectangle
|
void |
setY(int y)
Sets the y position of the rectangle
|
String |
toString()
Returns a string representation of the object.
|
public Rectangle()
public Rectangle(int x, int y, Dimension size)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglesize
- the Dimension
of the rectanglepublic Rectangle(int x, int y, int w, int h)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectanglepublic Rectangle(Rectangle rect)
rect
- the Rectangle to copypublic static Rectangle createFromPool(int x, int y, int w, int h)
When you are done with this object you should return it to the pool using
recycle(com.codename1.ui.geom.Rectangle)
.
x
- The x coordinate of the rect.y
- The y coordinate of the rect.w
- The width of the rect.h
- The height of the rect.recycle(com.codename1.ui.geom.Rectangle)
public static void recycle(Rectangle r)
r
- The rectangle to recycle.createFromPool(int, int, int, int)
public void setBounds(int x, int y, int w, int h)
public void setBounds(Rectangle bounds)
bounds
- A rectangle whose bounds will be copied.public int getWidth()
public void setWidth(int w)
w
- the widthpublic void setHeight(int h)
h
- the heightpublic int getHeight()
public Dimension getSize()
public int getX()
public int getY()
public String toString()
public void setX(int x)
x
- the x coordinate of the rectanglepublic void setY(int y)
y
- the y coordinate of the rectanglepublic boolean contains(Rectangle rect)
rect
- the specified Rectanglepublic boolean contains(int rX, int rY, int rWidth, int rHeight)
rX
- the specified x coordinaterY
- the specified y coordinaterWidth
- the width of the RectanglerHeight
- the height of the Rectanglepublic static boolean contains(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
x1
- first rect xy1
- first rect yw1
- first rect wh1
- first rect hx2
- second rect xy2
- second rect yw2
- second rect wh2
- second rect hpublic boolean contains(int rX, int rY)
public Rectangle intersection(int rX, int rY, int rW, int rH)
rX
- rectangle to intersect with this rectanglerY
- rectangle to intersect with this rectanglerW
- rectangle to intersect with this rectanglerH
- rectangle to intersect with this rectanglepublic static void intersection(int rrX, int rrY, int rrW, int rrH, int rtx1, int rty1, int rtw2, int rth2, Rectangle dest)
rrX
- rectangle to intersect with this rectanglerrY
- rectangle to intersect with this rectanglerrW
- rectangle to intersect with this rectanglerrH
- rectangle to intersect with this rectanglertx1
- rectangle to intersect with this rectanglerty1
- rectangle to intersect with this rectanglertw2
- rectangle to intersect with this rectanglerth2
- rectangle to intersect with this rectangledest
- result of the intersection are stored herepublic Rectangle intersection(Rectangle r)
intersection
in interface Shape
r
- rectangle to intersect with this rectanglepublic boolean intersects(int x, int y, int width, int height)
x
- the specified x coordinatey
- the specified y coordinatewidth
- the width of the Rectangleheight
- the height of the Rectanglepublic boolean intersects(Rectangle rect)
rect
- the Rectangle to check intersection withpublic static boolean intersects(int tx, int ty, int tw, int th, int x, int y, int width, int height)
tx
- x of first rectanglety
- y of first rectangletw
- width of first rectangleth
- height of first rectanglex
- x of second rectangley
- y of second rectanglewidth
- width of second rectangleheight
- height of second rectanglepublic PathIterator getPathIterator(Transform m)
Note: If Transform.isSupported()
is false, then using this iterator will throw a Runtime Exception.
getPathIterator
in interface Shape
public PathIterator getPathIterator()
getPathIterator
in interface Shape
public Rectangle getBounds()
public float[] getBounds2D()
getBounds2D
in interface Shape
public boolean isRectangle()
isRectangle
in interface Shape
public boolean equals(Object obj)
public int hashCode()