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)
Area
distanceToEdge
in interface Area
location
- the reference locationpublic final int getBottom()
Area
public Location getCenter()
Area
public int getHeight()
Area
public final int getLeft()
Area
public final int getRight()
Area
public int getSize()
Area
public final int getTop()
Area
public int getWidth()
Area
public boolean inBottomRight(Location location)
Area
| / / +-----------------+-----------------+ | area / | | | / | | / | | | / | | / | - - - + - - - - - - - - + - - - - - - - - + - - - x-axis | / | | / | | | / | | / | | | / | +-----------------+-----------------+ / / | y-axis
inBottomRight
in interface Area
location
- the location to considerpublic boolean inBottomLeft(Location location)
Area
\ | \ +-----------------+-----------------+ | \ area | | \ | | | \ | | \ | | | \ | - - - + - - - - - - - - + - - - - - - - - + - - - x-axis | \ | | | \ | | \ | | | \ | | \ | +-----------------+-----------------+ \ | \ y-axis
inBottomLeft
in interface Area
location
- the location to considerpublic boolean intersects(Area targetArea)
Area
intersects
in interface Area
targetArea
- the area to compare topublic boolean intersects(Location location)
Area
intersects
in interface Area
location
- the location to examinepublic void moveTo(Location location)
Area
public java.lang.String toString()
[(left, top) - (right, bottom) ]
.toString
in class java.lang.Object
protected 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