Package com.iizix
Class Rect
- java.lang.Object
- com.iizix.Rect
- All Implemented Interfaces:
java.lang.Cloneable
public class Rect extends java.lang.Object implements java.lang.Cloneable
Simple rectangle class for multiple use accepting negative width and height.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description Rect()
Constructor for x=y=cx=cy=0.Rect(int x, int y, int cx, int cy)
Constructor.Rect(ReadTransaction trans)
Constructor from a Transaction.Rect(java.lang.String string)
Constructor from a String formatted as "x,y,cx,cy".
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(SendTransaction trans)
Appends the rectangle to a transaction.void
clear()
Reinitializes the contents.Rect
clone()
Clones this instance.boolean
equals(java.lang.Object o)
Checks if two rectangles are equal.int
hashCode()
The hash code.boolean
isInside(Position p)
Checks if a position is inside.java.lang.String
toString()
Formats to a string as "x,y,cx,cy".
Field Detail
EMPTY
public static final Rect[] EMPTY
Empty array of Rect's.
x
public int x
The X position of the rectangle.
y
public int y
The Y position of the rectangle.
cx
public int cx
The width of the rectangle.
cy
public int cy
The height of the rectangle.
Constructor Detail
Rect
public Rect()
Constructor for x=y=cx=cy=0.
Rect
public Rect(java.lang.String string)
Constructor from a String formatted as "x,y,cx,cy".- Parameters:
string
- The string.- Throws:
java.lang.IllegalArgumentException
- If the string is not well formatted.
Rect
public Rect(ReadTransaction trans)
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.
Method Detail
isInside
public boolean isInside(Position p)
Checks if a position is inside.- Parameters:
p
- The position.- Returns:
- true if inside, false otherwise.
clear
public void clear()
Reinitializes the contents.
equals
public boolean equals(java.lang.Object o)
Checks if two rectangles are equal.- Overrides:
equals
in classjava.lang.Object
clone
public Rect clone()
Clones this instance.- Overrides:
clone
in classjava.lang.Object
- Returns:
- As cloned instance of GUnit.
toString
public java.lang.String toString()
Formats to a string as "x,y,cx,cy".- Overrides:
toString
in classjava.lang.Object
hashCode
public int hashCode()
The hash code.- Overrides:
hashCode
in classjava.lang.Object
append
public void append(SendTransaction trans)
Appends the rectangle to a transaction.- Parameters:
trans
- The transaction to append to.