public static class Rectangle.Impl extends Zone.Skeleton implements Rectangle
Rectangle.Impl, Rectangle.Utils
Zone.Helper, Zone.Skeleton
Modifier and Type | Field and Description |
---|---|
protected Coord |
bottomLeft |
protected int |
height |
protected int |
width |
Constructor and Description |
---|
Impl(Coord bottomLeft,
int width,
int height) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Coord c) |
boolean |
contains(int x,
int y) |
boolean |
equals(java.lang.Object obj) |
Rectangle |
extend()
Gets a new Zone that contains all the Coords in
this plus all
neighboring Coords, which can be orthogonally or diagonally adjacent
to any Coord this has in it. |
java.util.List<Coord> |
getAll() |
Coord |
getBottomLeft() |
Coord |
getCenter() |
java.util.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() |
java.util.List<Coord> |
getInternalBorder() |
int |
getWidth() |
int |
hashCode() |
boolean |
isEmpty() |
java.util.Iterator<Coord> |
iterator() |
int |
size() |
java.lang.String |
toString() |
Zone |
translate(int x,
int y) |
int |
xBound(boolean smallestBound) |
int |
yBound(boolean smallestBound) |
contains, getDiagonal, intersectsWith, translate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
contains, getDiagonal, intersectsWith, translate
protected final Coord bottomLeft
protected final int width
protected final int height
public Impl(Coord bottomLeft, int width, int height)
public Coord getBottomLeft()
getBottomLeft
in interface Rectangle
public int getWidth()
public int getHeight()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isEmpty()
public int size()
size
in interface Zone
size
in class Zone.Skeleton
Zone.getAll()
).public boolean contains(int x, int y)
contains
in interface Zone
contains
in class Zone.Skeleton
public boolean contains(Coord c)
contains
in interface Zone
contains
in class Zone.Skeleton
c
.public int xBound(boolean smallestBound)
xBound
in interface Zone
xBound
in class Zone.Skeleton
smallestBound
- if true, finds the smallest x-coordinate value;
if false, finds the biggest.this
that has the
smallest (or biggest) x-coordinate. Or -1 if the zone is empty.public int yBound(boolean smallestBound)
yBound
in interface Zone
yBound
in class Zone.Skeleton
smallestBound
- if true, finds the smallest y-coordinate value;
if false, finds the biggest.this
that has the
smallest (or biggest) y-coordinate. Or -1 if the zone is empty.public Coord getCenter()
getCenter
in interface Zone
getCenter
in class Zone.Skeleton
public java.util.List<Coord> getAll()
public Zone translate(int x, int y)
translate
in interface Zone
translate
in class Zone.Skeleton
this
shifted by (x,y)
public java.util.List<Coord> getInternalBorder()
getInternalBorder
in interface Zone
getInternalBorder
in class Zone.Skeleton
this
that are adjacent to a cell not in
this
public java.util.Collection<Coord> getExternalBorder()
Zone
getExternalBorder
in interface Zone
getExternalBorder
in class Zone.Skeleton
this
(orthogonally or diagonally) that
aren't in this
public Rectangle extend()
Zone
this
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.extend
in interface Zone
extend
in class Zone.Skeleton
this
where cells adjacent to this
(orthogonally or diagonally) have been added (i.e. it's this
plus Zone.getExternalBorder()
).public java.util.Iterator<Coord> iterator()
iterator
in interface java.lang.Iterable<Coord>
iterator
in class Zone.Skeleton
Copyright © Eben Howard 2012–2022. All rights reserved.