public class Region
extends java.lang.Object
The current implementation is optimized to a level where there is no intersecting rectangles in the set and adjacent rectangles sharing a side are merged into a single one.
Modifier and Type | Field and Description |
---|---|
private boolean |
allInvalidated
tracks the null rectangle case
|
private java.util.ArrayList<Rectangle> |
rct
array of individual non-nesting rectangles
|
Constructor and Description |
---|
Region()
Constructor.
|
Region(Rectangle rect)
Constructor taking an initial rectangle.
|
Modifier and Type | Method and Description |
---|---|
void |
addRectangle(Rectangle rect)
Adds a rectangle to this region.
|
int |
contains(double x,
double y)
Checks whether the region contains the given point.
|
int |
contains(Point p)
Checks whether the region contains the given point.
|
boolean |
isEmpty()
Checks whether the region is empty.
|
java.util.Iterator<Rectangle> |
iterator()
Gets an iterator for the region.
|
void |
resetRegion()
Clears this region entirely.
|
java.lang.String |
toString()
Gets a string representation of this region.
|
private java.util.ArrayList<Rectangle> rct
private boolean allInvalidated
public Region()
public Region(Rectangle rect)
rect
- rectangle that is added initially to the regionpublic void addRectangle(Rectangle rect)
rect
- rectangle that is to be added to the regionpublic void resetRegion()
public boolean isEmpty()
true
when region has no rectanglespublic int contains(Point p)
p
- point to check-1
if nonepublic int contains(double x, double y)
x
- x-coordinate of the point to checky
- y-coordinate of the point to check-1
if nonepublic java.util.Iterator<Rectangle> iterator()
public java.lang.String toString()
toString
in class java.lang.Object