Package net.sf.gridarta.utils
Class Size2D
- java.lang.Object
-
- net.sf.gridarta.utils.Size2D
-
- All Implemented Interfaces:
java.io.Serializable
public class Size2D extends java.lang.Object implements java.io.SerializableThe class Size2D represents a 2d rectangular area. Sizes always are positive. This class doesn't allow zero or negative sizes.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Size2D(int width, int height)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(@Nullable java.lang.Object obj)intgetHeight()Returns the height of the area.intgetWidth()Returns the width of the area.inthashCode()java.lang.StringtoString()
-
-
-
Field Detail
-
ONE
public static final Size2D ONE
One size object.
-
-
Constructor Detail
-
Size2D
public Size2D(int width, int height)Creates a new instance.- Parameters:
width- the width of the area; must be greater than zeroheight- the height of the area; must be greater than zero- Throws:
java.lang.IllegalArgumentException- in casewidthorheightis less than 1.
-
-
Method Detail
-
equals
public boolean equals(@Nullable @Nullable java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getWidth
public int getWidth()
Returns the width of the area. It is always greater than zero.- Returns:
- the width of the area
-
getHeight
public int getHeight()
Returns the height of the area. It is always greater than zero.- Returns:
- the height of the area
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-