Class Rect
java.lang.Object
com.iizix.Rect
- All Implemented Interfaces:
Cloneable
Field Summary
FieldsConstructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionvoidappend(SendTransaction trans) Appends the rectangle to a transaction.voidclear()Reinitializes the contents.clone()Clones this instance.booleanChecks if two rectangles are equal.inthashCode()The hash code.booleanChecks if a position is inside.toString()Formats to a string as "x,y,cx,cy".
Field Details
EMPTY
Empty array of Rect's.x
public int xThe X position of the rectangle.y
public int yThe Y position of the rectangle.cx
public int cxThe width of the rectangle.cy
public int cyThe height of the rectangle.
Constructor Details
Rect
public Rect()Constructor for x=y=cx=cy=0.Rect
Constructor from a String formatted as "x,y,cx,cy".- Parameters:
string- The string.- Throws:
IllegalArgumentException- If the string is not well formatted, holds a token that is not an integer, holds more than four tokens, or holds a value outside the codec range.
Rect
Constructor from a Transaction.- Parameters:
trans- The transaction.
Rect
public Rect(int x, int y, int cx, int cy) Constructor.- Parameters:
x- X position.y- Y position.cx- Width.cy- Height.- Throws:
IllegalArgumentException- If any value is outside the codec range, -0x1FFFFFFF to 0x1FFFFFFF inclusive.
Method Details
isInside
Checks if a position is inside.- Parameters:
p- The position.- Returns:
- true if inside, false otherwise.
clear
public void clear()Reinitializes the contents.equals
Checks if two rectangles are equal.A
GRectwith the same four values is equal to this instance, andGRect.equals(Object)accepts aRectin the same way, so equality is symmetric across the two types. Both classes hash asObjects.hash(x,y,cx,cy), so the hashCode contract holds across them too.clone
toString
hashCode
append
Appends the rectangle to a transaction.- Parameters:
trans- The transaction to append to.