Package squidpony.squidgrid.zone
Class Zone.Skeleton
java.lang.Object
squidpony.squidgrid.zone.Zone.Skeleton
- All Implemented Interfaces:
Serializable
,Iterable<Coord>
,Zone
- Direct Known Subclasses:
CoordPackerZone
,GreasedRegion
,ListZone
,Rectangle.Impl
- Enclosing interface:
- Zone
public abstract static class Zone.Skeleton extends Object implements Zone
A convenience partial implementation. Please try for all new
implementations of
Zone
to be subtypes of this class. It usually
prove handy at some point to have a common superclass.- Author:
- smelC
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface squidpony.squidgrid.zone.Zone
Zone.Helper, Zone.Skeleton
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Skeleton()
-
Method Summary
Modifier and Type Method Description boolean
contains(int x, int y)
boolean
contains(Zone other)
boolean
contains(Coord c)
Zone
extend()
Gets a new Zone that contains all the Coords inthis
plus all neighboring Coords, which can be orthogonally or diagonally adjacent to any Coord this has in it.Coord
getCenter()
double
getDiagonal()
Collection<Coord>
getExternalBorder()
Gets a Collection of Coord values that are not in this Zone, but are adjacent to it, either orthogonally or diagonally.int
getHeight()
Collection<Coord>
getInternalBorder()
int
getWidth()
boolean
intersectsWith(Zone other)
Iterator<Coord>
iterator()
int
size()
Zone
translate(int x, int y)
Zone
translate(Coord c)
int
xBound(boolean smallestOrBiggest)
int
yBound(boolean smallestOrBiggest)
-
Field Details
-
Constructor Details
-
Method Details
-
size
- Specified by:
size
in interfaceZone
- Returns:
- The number of cells that this zone contains (the size
Zone.getAll()
).
-
contains
-
contains
-
contains
-
intersectsWith
- Specified by:
intersectsWith
in interfaceZone
- Returns:
- true if
this
andother
have a common cell.
-
iterator
-
getWidth
-
getHeight
-
getDiagonal
- Specified by:
getDiagonal
in interfaceZone
- Returns:
- The approximation of the zone's diagonal, using
Zone.getWidth()
andZone.getHeight()
.
-
xBound
-
yBound
-
getCenter
-
translate
-
translate
-
getInternalBorder
- Specified by:
getInternalBorder
in interfaceZone
- Returns:
- Cells in
this
that are adjacent to a cell not inthis
-
getExternalBorder
Description copied from interface:Zone
Gets a Collection of Coord values that are not in this Zone, but are adjacent to it, either orthogonally or diagonally. Related to the fringe() methods in CoordPacker and GreasedRegion, but guaranteed to use 8-way adjacency and to return a new Collection of Coord.- Specified by:
getExternalBorder
in interfaceZone
- Returns:
- Cells adjacent to
this
(orthogonally or diagonally) that aren't inthis
-
extend
Description copied from interface:Zone
Gets a new Zone that contains all the Coords inthis
plus all neighboring Coords, which can be orthogonally or diagonally adjacent to any Coord this has in it. Related to the expand() methods in CoordPacker and GreasedRegion, but guaranteed to use 8-way adjacency and to return a new Zone.- Specified by:
extend
in interfaceZone
- Returns:
- A variant of
this
where cells adjacent tothis
(orthogonally or diagonally) have been added (i.e. it'sthis
plusZone.getExternalBorder()
).
-