public class Rectangle
extends java.lang.Object
Constructor and Description |
---|
Rectangle()
Creates an empty rectangle (all its bounds are 0).
|
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 |
decrementSize(int widthDecrement,
int heightDecrement)
Decrements the size of the rectangle.
|
int |
getHeight()
Gets the height.
|
int |
getWidth()
Gets the width.
|
int |
getX()
Gets the x coordinate.
|
int |
getY()
Gets the y coordinate.
|
void |
incrementSize(int widthIncrement,
int heightIncrement)
Increments the size of the rectangle.
|
void |
move(int xShift,
int yShift)
Shifts the location of the rectangle.
|
void |
setBounds(int x,
int y,
int width,
int height)
Sets the bounds of the rectangle.
|
void |
setHeight(int height)
Sets the height.
|
void |
setLocation(int x,
int y)
Sets the location of the rectangle.
|
void |
setSize(int width,
int height)
Sets the size of the rectangle.
|
void |
setWidth(int width)
Sets the width.
|
void |
setX(int x)
Sets the x coordinate.
|
void |
setY(int y)
Sets the y coordinate.
|
void |
update(int xShift,
int yShift,
int widthIncrement,
int heightIncrement)
Updates the rectangle bounds.
|
public Rectangle()
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 int getX()
public void setX(int x)
x
- the x to set.public int getY()
public void setY(int y)
y
- the y to set.public int getWidth()
public void setWidth(int width)
width
- the width to set.public int getHeight()
public void setHeight(int height)
height
- the height to set.public void setLocation(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 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 move(int xShift, int yShift)
xShift
- the x shift.yShift
- the y shift.public void incrementSize(int widthIncrement, int heightIncrement)
widthIncrement
- the width to add.heightIncrement
- the height to add.public void decrementSize(int widthDecrement, int heightDecrement)
widthDecrement
- the width to remove.heightDecrement
- the height to remove.public void update(int xShift, int yShift, int widthIncrement, int heightIncrement)
xShift
- the x shift.yShift
- the y shift.widthIncrement
- the width to add.heightIncrement
- the height to add.