com.sun.jimi.core.util
Class AreaCoverage
java.lang.Object
|
+--com.sun.jimi.core.util.AreaCoverage
- public class AreaCoverage
- extends java.lang.Object
This class is used to track the area of coverage of a given area
(width x height) of a cartesian coordinate system.
A single point may be represented as a coordinate with a width of 1
and a height of 1 though this class is not likely to be efficient
for point tracking of area coverage
No concurrency of access issues are dealt with in this class.
Method Summary |
void |
add(int row)
|
void |
add(int x,
int y,
int width,
int height)
Add coverage for specified region. |
boolean |
contains(int row)
|
boolean |
contains(int x,
int y,
int w,
int h)
|
java.awt.Rectangle |
getBounds()
|
protected void |
mergeRecords(int idx)
Process the covered rectangles collection and merge records
where it is possible to. |
void |
reset()
Reset the area covered to none. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
AreaCoverage
public AreaCoverage(int w,
int h)
- Parameters:
w
- width of area to track coverage onh
- height of area to track coverage on
reset
public void reset()
- Reset the area covered to none.
add
public void add(int x,
int y,
int width,
int height)
- Add coverage for specified region.
- Parameters:
x
- horizontal coordinate for area to covery
- vertical coordinate for area to coverwidth
- width of area to coverheight
- height of area to cover
add
public void add(int row)
- Parameters:
row
- the row that is being covered
contains
public boolean contains(int row)
- Parameters:
the
- row to check for coverage on- Returns:
- True if row is covered
contains
public boolean contains(int x,
int y,
int w,
int h)
- Parameters:
x
- horizontal coordinate for area to check for coveragey
- vertical coordinate for area to check for coveragewidth
- width of area to check for coverageheight
- height of area to check for coverage- Returns:
- True if area specified is allready covered by rectangles
mergeRecords
protected void mergeRecords(int idx)
- Process the covered rectangles collection and merge records
where it is possible to.
- Parameters:
idx
- is the record that has changed and is the only
rectangle that might be merged with adjacent rectangles.
getBounds
public java.awt.Rectangle getBounds()
- Returns:
- the bounding rectangle representing the area that
has been covered.