Package xyz.gmitch215.socketmc.util
Class ElementBounds
java.lang.Object
xyz.gmitch215.socketmc.util.ElementBounds
- All Implemented Interfaces:
 Serializable
Utility class for 2D sizeable and placeable objects.
- See Also:
 
- 
Constructor Summary
ConstructorsConstructorDescriptionElementBounds(int width, int height) Constructs new bounds at (0, 0).ElementBounds(int x, int y, int width, int height) Constructs new bounds. - 
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int x, int y) Checks if the object contains the given point.booleanintGets the x-coordinate of the center of the bounds.intGets the y-coordinate of the center of the bounds.intGets the height of the bounds.intgetWidth()Gets the width of the bounds.intgetX()Gets the x-coordinate of the bounds.intgetY()Gets the y-coordinate of the bounds.inthashCode()voidscale(double factor) Scales the object by the given factor.voidscale(int factor) Scales the object by the given factor.voidsetHeight(int height) Sets the height of the bounds.voidsetWidth(int width) Sets the width of the bounds.voidsetX(int x) Sets the x-coordinate of the bounds.voidsetY(int y) Sets the y-coordinate of the bounds.toString()voidtranslate(int x, int y) Translates the object by the given amount. 
- 
Constructor Details
- 
ElementBounds
public ElementBounds(int width, int height) Constructs new bounds at (0, 0).- Parameters:
 width- the widthheight- the height
 - 
ElementBounds
Constructs new bounds.- Parameters:
 x- the x-coordinatey- the y-coordinatewidth- the widthheight- the height- Throws:
 IllegalArgumentException- if coordinates or dimensions are negative
 
 - 
 - 
Method Details
- 
getX
public int getX()Gets the x-coordinate of the bounds.- Returns:
 - the x-coordinate
 
 - 
setX
public void setX(int x) Sets the x-coordinate of the bounds.- Parameters:
 x- the x-coordinate
 - 
getY
public int getY()Gets the y-coordinate of the bounds.- Returns:
 - the y-coordinate
 
 - 
setY
public void setY(int y) Sets the y-coordinate of the bounds.- Parameters:
 y- the y-coordinate
 - 
translate
public void translate(int x, int y) Translates the object by the given amount.- Parameters:
 x- the x-translationy- the y-translation
 - 
getWidth
public int getWidth()Gets the width of the bounds.- Returns:
 - the width
 
 - 
setWidth
public void setWidth(int width) Sets the width of the bounds.- Parameters:
 width- the width
 - 
getHeight
public int getHeight()Gets the height of the bounds.- Returns:
 - the height
 
 - 
setHeight
public void setHeight(int height) Sets the height of the bounds.- Parameters:
 height- the height
 - 
scale
public void scale(double factor) Scales the object by the given factor.- Parameters:
 factor- the scaling factor
 - 
scale
public void scale(int factor) Scales the object by the given factor.- Parameters:
 factor- the scaling factor
 - 
contains
public boolean contains(int x, int y) Checks if the object contains the given point.- Parameters:
 x- the x-coordinatey- the y-coordinate- Returns:
 - true if the point is contained, false otherwise
 
 - 
getCenterX
public int getCenterX()Gets the x-coordinate of the center of the bounds.- Returns:
 - the x-coordinate of the center
 
 - 
getCenterY
public int getCenterY()Gets the y-coordinate of the center of the bounds.- Returns:
 - the y-coordinate of the center
 
 - 
equals
 - 
hashCode
public int hashCode() - 
toString
 
 -