public abstract class AbstractArea extends java.lang.Object implements Area
Area calculations.| Constructor and Description |
|---|
AbstractArea() |
| Modifier and Type | Method and Description |
|---|---|
Area |
copyOf()
Clone our area.
|
int |
distanceToEdge(Location location)
Determine the shortest distance from the location to the edge of the area.
|
int |
getBottom()
Get the area's bottom coordinate in pixels.
|
Location |
getCenter()
Get the area's center Location.
|
int |
getHeight()
Get the area's height.
|
int |
getLeft()
Get the area's left coordinate in pixels.
|
int |
getRight()
Get the area's right coordinate in pixels.
|
int |
getSize()
Determine area (width * height).
|
int |
getTop()
Get the area's top coordinate in pixels.
|
int |
getWidth()
Get the area's width.
|
boolean |
inBottomLeft(Location location)
Determine if location is to the bottom-left of the area diagonal.
|
boolean |
inBottomRight(Location location)
Determine if location is to the bottom-right of the area diagonal.
|
boolean |
intersects(Area targetArea)
Determine if the target area intersects our area.
|
boolean |
intersects(Location location)
Determine if the provided location intersects with our area.
|
void |
moveTo(Location location)
Translate our top left position to the new location.
|
protected void |
setBottom(int bottom)
Set bottom coordinate.
|
protected void |
setLeft(int left)
Set left coordinate.
|
protected void |
setRight(int right)
Set right coordinate.
|
protected void |
setTop(int top)
Set top coordinate.
|
java.lang.String |
toString()
Textual representation of this area formatted as
[(left, top) - (right, bottom) ]. |
public int distanceToEdge(Location location)
AreadistanceToEdge in interface Arealocation - the reference locationpublic final int getBottom()
Areapublic Location getCenter()
Areapublic int getHeight()
Areapublic final int getLeft()
Areapublic final int getRight()
Areapublic int getSize()
Areapublic final int getTop()
Areapublic int getWidth()
Areapublic boolean inBottomRight(Location location)
Area
| /
/
+-----------------+-----------------+
| area / |
| | / |
| / |
| | / |
| / |
- - - + - - - - - - - - + - - - - - - - - + - - - x-axis
| / |
| / | |
| / |
| / | |
| / |
+-----------------+-----------------+
/
/ |
y-axis
inBottomRight in interface Arealocation - the location to considerpublic boolean inBottomLeft(Location location)
Area
\ |
\
+-----------------+-----------------+
| \ area |
| \ | |
| \ |
| \ | |
| \ |
- - - + - - - - - - - - + - - - - - - - - + - - - x-axis
| \ |
| | \ |
| \ |
| | \ |
| \ |
+-----------------+-----------------+
\
| \
y-axis
inBottomLeft in interface Arealocation - the location to considerpublic boolean intersects(Area targetArea)
Areaintersects in interface AreatargetArea - the area to compare topublic boolean intersects(Location location)
Areaintersects in interface Arealocation - the location to examinepublic void moveTo(Location location)
Areapublic java.lang.String toString()
[(left, top) - (right, bottom) ].toString in class java.lang.Objectprotected final void setBottom(int bottom)
bottom - the bottom coordinate in pixelsprotected final void setLeft(int left)
left - the left coordinate in pixelsprotected final void setRight(int right)
right - the right coordinate in pixelsprotected final void setTop(int top)
top - the top coordinate in pixels