Package squidpony.squidgrid.mapping
Class Rectangle.Impl
java.lang.Object
squidpony.squidgrid.zone.Zone.Skeleton
squidpony.squidgrid.mapping.Rectangle.Impl
- All Implemented Interfaces:
Serializable
,Iterable<Coord>
,Rectangle
,Zone
- Enclosing interface:
- Rectangle
public static class Rectangle.Impl extends Zone.Skeleton implements Rectangle
- Author:
- smelC
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface squidpony.squidgrid.mapping.Rectangle
Rectangle.Impl, Rectangle.Utils
Nested classes/interfaces inherited from interface squidpony.squidgrid.zone.Zone
Zone.Helper, Zone.Skeleton
-
Field Summary
Fields Modifier and Type Field Description protected Coord
bottomLeft
protected int
height
protected int
width
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
contains(int x, int y)
boolean
contains(Coord c)
boolean
equals(Object obj)
Rectangle
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.List<Coord>
getAll()
Coord
getBottomLeft()
Coord
getCenter()
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()
List<Coord>
getInternalBorder()
int
getWidth()
int
hashCode()
boolean
isEmpty()
Iterator<Coord>
iterator()
int
size()
String
toString()
Zone
translate(int x, int y)
int
xBound(boolean smallestOrBiggest)
int
yBound(boolean smallestOrBiggest)
Methods inherited from class squidpony.squidgrid.zone.Zone.Skeleton
contains, getDiagonal, intersectsWith, translate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface squidpony.squidgrid.zone.Zone
contains, getDiagonal, intersectsWith, translate
-
Field Details
-
Constructor Details
-
Method Details
-
getBottomLeft
- Specified by:
getBottomLeft
in interfaceRectangle
- Returns:
- The bottom left coordinate of the room.
-
getWidth
-
getHeight
-
hashCode
-
equals
-
toString
-
isEmpty
-
size
- Specified by:
size
in interfaceZone
- Overrides:
size
in classZone.Skeleton
- Returns:
- The number of cells that this zone contains (the size
Zone.getAll()
).
-
contains
- Specified by:
contains
in interfaceZone
- Overrides:
contains
in classZone.Skeleton
- Returns:
- Whether this zone contains the coordinate (x,y).
-
contains
- Specified by:
contains
in interfaceZone
- Overrides:
contains
in classZone.Skeleton
- Returns:
- Whether this zone contains
c
.
-
xBound
- Specified by:
xBound
in interfaceZone
- Overrides:
xBound
in classZone.Skeleton
- Parameters:
smallestOrBiggest
- if true, finds the smallest x-coordinate value; if false, finds the biggest.- Returns:
- The x-coordinate of the Coord within
this
that has the smallest (or biggest) x-coordinate. Or -1 if the zone is empty.
-
yBound
- Specified by:
yBound
in interfaceZone
- Overrides:
yBound
in classZone.Skeleton
- Parameters:
smallestOrBiggest
- if true, finds the smallest y-coordinate value; if false, finds the biggest.- Returns:
- The y-coordinate of the Coord within
this
that has the smallest (or biggest) y-coordinate. Or -1 if the zone is empty.
-
getCenter
- Specified by:
getCenter
in interfaceZone
- Overrides:
getCenter
in classZone.Skeleton
- Returns:
- The approximate center of this zone, or null if this zone is empty.
-
getAll
-
translate
- Specified by:
translate
in interfaceZone
- Overrides:
translate
in classZone.Skeleton
- Returns:
this
shifted by(x,y)
-
getInternalBorder
- Specified by:
getInternalBorder
in interfaceZone
- Overrides:
getInternalBorder
in classZone.Skeleton
- 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
- Overrides:
getExternalBorder
in classZone.Skeleton
- 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
- Overrides:
extend
in classZone.Skeleton
- Returns:
- A variant of
this
where cells adjacent tothis
(orthogonally or diagonally) have been added (i.e. it'sthis
plusZone.getExternalBorder()
).
-
iterator
- Specified by:
iterator
in interfaceIterable<Coord>
- Overrides:
iterator
in classZone.Skeleton
-