Package ej.mwt.util
Class Rectangle
- java.lang.Object
-
- ej.mwt.util.Rectangle
-
- All Implemented Interfaces:
Outlineable
public class Rectangle extends java.lang.Object implements Outlineable
Represents a rectangle with a position and a size.For heap optimization the position and size are stored as a
shortand therefore are limited between-32768and32767.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOutline(int left, int top, int right, int bottom)Adds the given outline.intgetHeight()Gets the height.intgetWidth()Gets the width.intgetX()Gets the x coordinate.intgetY()Gets the y coordinate.voidremoveOutline(int left, int top, int right, int bottom)Removes the given outline.voidsetBounds(int x, int y, int width, int height)Sets the bounds of this rectangle.voidsetHeight(int height)Sets the height.voidsetPosition(int x, int y)Sets the position of this rectangle.voidsetSize(int width, int height)Sets the size of this rectangle.voidsetWidth(int width)Sets the width.voidsetX(int x)Sets the x coordinate.voidsetY(int y)Sets the y coordinate.
-
-
-
Constructor Detail
-
Rectangle
public Rectangle(int x, int y, int width, int height)Creates a rectangle specifying its bounds.- Parameters:
x- the x.y- the y.width- the width.height- the height.
-
Rectangle
public Rectangle(Rectangle rectangle)
Creates a rectangle from the bounds of another rectangle.- Parameters:
rectangle- the other rectangle.
-
-
Method Detail
-
getX
public int getX()
Gets the x coordinate.- Returns:
- the x.
-
setX
public void setX(int x)
Sets the x coordinate.- Parameters:
x- the x.
-
getY
public int getY()
Gets the y coordinate.- Returns:
- the y.
-
setY
public void setY(int y)
Sets the y coordinate.- Parameters:
y- the y.
-
getWidth
public int getWidth()
Gets the width.- Returns:
- the width.
-
setWidth
public void setWidth(int width)
Sets the width.- Parameters:
width- the width.
-
getHeight
public int getHeight()
Gets the height.- Returns:
- the height.
-
setHeight
public void setHeight(int height)
Sets the height.- Parameters:
height- the height.
-
setPosition
public void setPosition(int x, int y)Sets the position of this rectangle.- Parameters:
x- the x.y- the y.
-
setSize
public void setSize(int width, int height)Sets the size of this rectangle.- Parameters:
width- the width.height- the height.
-
setBounds
public void setBounds(int x, int y, int width, int height)Sets the bounds of this rectangle.- Parameters:
x- the x.y- the y.width- the width.height- the height.
-
addOutline
public void addOutline(int left, int top, int right, int bottom)Description copied from interface:OutlineableAdds the given outline.- Specified by:
addOutlinein interfaceOutlineable- Parameters:
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.
-
removeOutline
public void removeOutline(int left, int top, int right, int bottom)Description copied from interface:OutlineableRemoves the given outline.- Specified by:
removeOutlinein interfaceOutlineable- Parameters:
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.
-
-