public class Rect
extends java.lang.Object
implements java.io.Externalizable
| Modifier and Type | Class and Description |
|---|---|
static class |
Rect.Edge
The Edge class represents an edge of a rectangle defined by its starting and ending coordinates.
|
| Modifier and Type | Field and Description |
|---|---|
private int |
hashCode
Transient cached hash code value.
|
private int |
x1
Represents a rectangle defined by its bottom-left and top-right coordinates.
|
private int |
x2
Represents a rectangle defined by its bottom-left and top-right coordinates.
|
private int |
y1
Represents a rectangle defined by its bottom-left and top-right coordinates.
|
private int |
y2
Represents a rectangle defined by its bottom-left and top-right coordinates.
|
| Constructor and Description |
|---|
Rect()
The Rect class represents a rectangle defined by its bottom-left and top-right coordinates.
|
Rect(int x1,
int y1,
int x2,
int y2)
The Rect class represents a rectangle defined by its bottom-left and top-right coordinates.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Rect r)
Returns
true is specified rectangle is completely inside
this rectangle. |
boolean |
empty()
Returns whether the rectangle is empty.
|
boolean |
equals(java.lang.Object o)
Compares this rectangle with the specified object for equality.
|
int |
getX1()
x1 getter.
|
int |
getX2()
x2 getter.
|
int |
getY1()
y1 getter.
|
int |
getY2()
y2 getter.
|
int |
hashCode()
Returns a hash code value for the rectangle object.
|
Rect |
intersection(Rect rect)
Calculate rectangle which is intersection between this and specified
rectangle.
|
void |
readExternal(java.io.ObjectInput in)
The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays.
|
Rect |
union(Rect rect)
The union method calculates the rectangle that is the union of the current rectangle and the specified
rectangle.
|
void |
writeExternal(java.io.ObjectOutput out)
The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings,
and arrays.
|
private int x1
private int y1
private int x2
private int y2
private transient int hashCode
public Rect()
public Rect(int x1,
int y1,
int x2,
int y2)
x1 - The x-coordinate of the bottom-left corner of the rectangle.y1 - The y-coordinate of the bottom-left corner of the rectangle.x2 - The x-coordinate of the top-right corner of the rectangle.y2 - The y-coordinate of the top-right corner of the rectangle.public int getX1()
public int getY1()
public int getX2()
public int getY2()
public boolean empty()
public Rect intersection(Rect rect)
rect - Source rectangle.null if there is no intersection.public Rect union(Rect rect)
rect - The rectangle to calculate the union with.public boolean contains(Rect r)
true is specified rectangle is completely inside
this rectangle.r - Rectangle to check.true if specified rectangle is inside this
rectangle.public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizableout - the stream to write the object tojava.io.IOException - Includes any I/O exceptions that may occurpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablein - the stream to read data from in order to restore the objectjava.io.IOException - if I/O errors occurjava.lang.ClassNotFoundException - If the class for an object being
restored cannot be found.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - The object to be compared for equality with this rectangle.public int hashCode()
hashCode in class java.lang.Object