public class Rectangle extends Object implements Outlineable
For heap optimization the position and size are stored as a short
and therefore are limited between
-32768
and 32767
.
Constructor and Description |
---|
Rectangle(int x,
int y,
int width,
int height)
Creates a rectangle specifying its bounds.
|
Rectangle(Rectangle rectangle)
Creates a rectangle from the bounds of another rectangle.
|
Modifier and Type | Method and Description |
---|---|
void |
addOutline(int left,
int top,
int right,
int bottom)
Adds the given outline.
|
int |
getHeight()
Gets the height.
|
int |
getWidth()
Gets the width.
|
int |
getX()
Gets the x coordinate.
|
int |
getY()
Gets the y coordinate.
|
void |
removeOutline(int left,
int top,
int right,
int bottom)
Removes the given outline.
|
void |
setBounds(int x,
int y,
int width,
int height)
Sets the bounds of this rectangle.
|
void |
setHeight(int height)
Sets the height.
|
void |
setPosition(int x,
int y)
Sets the position of this rectangle.
|
void |
setSize(int width,
int height)
Sets the size of this rectangle.
|
void |
setWidth(int width)
Sets the width.
|
void |
setX(int x)
Sets the x coordinate.
|
void |
setY(int y)
Sets the y coordinate.
|
public Rectangle(int x, int y, int width, int height)
x
- the x to set.y
- the y to set.width
- the width to set.height
- the height to set.public Rectangle(Rectangle rectangle)
rectangle
- the other rectangle.public void addOutline(int left, int top, int right, int bottom)
Outlineable
addOutline
in interface Outlineable
left
- the left side thickness of the outline.top
- the top side thickness of the outline.right
- the right side thickness of the outline.bottom
- the bottom side thickness of the outline.public int getHeight()
public int getWidth()
public int getX()
public int getY()
public void removeOutline(int left, int top, int right, int bottom)
Outlineable
removeOutline
in interface Outlineable
left
- the left side thickness of the outline.top
- the top side thickness of the outline.right
- the right side thickness of the outline.bottom
- the bottom side thickness of the outline.public void setBounds(int x, int y, int width, int height)
x
- the x to set.y
- the y to set.width
- the width to set.height
- the height to set.public void setHeight(int height)
height
- the height to set.public void setPosition(int x, int y)
x
- the x to set.y
- the y to set.public void setSize(int width, int height)
width
- the width to set.height
- the height to set.public void setWidth(int width)
width
- the width to set.public void setX(int x)
x
- the x to set.public void setY(int y)
y
- the y to set.