public class Polygonal2DRegion extends AbstractRegion implements FlatRegion
world
Constructor and Description |
---|
Polygonal2DRegion()
Construct the region.
|
Polygonal2DRegion(Polygonal2DRegion region)
Make a copy of another region.
|
Polygonal2DRegion(World world)
Construct the region.
|
Polygonal2DRegion(World world,
java.util.List<BlockVector2> points,
int minY,
int maxY)
Construct the region.
|
Modifier and Type | Method and Description |
---|---|
void |
addPoint(BlockVector2 position)
Add a point to the list.
|
void |
addPoint(BlockVector3 position)
Add a point to the list.
|
java.lang.Iterable<BlockVector2> |
asFlatRegion()
Get this region as an iterable flat region.
|
Polygonal2DRegion |
clone()
Make a clone of the region.
|
boolean |
contains(BlockVector3 position)
Returns true based on whether the region contains the point.
|
static boolean |
contains(java.util.List<BlockVector2> points,
int minY,
int maxY,
BlockVector3 pt)
Checks to see if a point is inside a region.
|
void |
contract(BlockVector3... changes)
Contract the region.
|
void |
expand(BlockVector3... changes)
Expand the region.
|
boolean |
expandY(int y)
Expand the height of the polygon to fit the specified Y.
|
int |
getHeight()
Get Y-size.
|
int |
getLength()
Get Z-size.
|
BlockVector3 |
getMaximumPoint()
Get the upper point of a region.
|
int |
getMaximumY()
Gets the maximum Y value.
|
BlockVector3 |
getMinimumPoint()
Get the lower point of a region.
|
int |
getMinimumY()
Gets the minimum Y value.
|
java.util.List<BlockVector2> |
getPoints()
Get the list of points.
|
long |
getVolume()
Get the number of blocks in the region.
|
int |
getWidth()
Get X-size.
|
java.util.Iterator<BlockVector3> |
iterator()
Get the iterator.
|
java.util.List<BlockVector2> |
polygonize(int maxPoints)
Polygonizes a cross-section or a 2D projection of the region orthogonal to the Y axis.
|
protected void |
recalculate()
Recalculate the bounding box of this polygonal region.
|
void |
setMaximumY(int y)
Set the maximum Y.
|
void |
setMinimumY(int y)
Set the minimum Y.
|
void |
shift(BlockVector3 change)
Shift the region.
|
int |
size()
Return the number of points.
|
java.lang.String |
toString()
Returns string representation in the format
"(x1, z1) - ...
|
getCenter, getChunkCubes, getChunks, getWorld, getWorldMaxY, getWorldMinY, setWorld
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getArea, getBoundingBox, getCenter, getChunkCubes, getChunks, getWorld, setWorld
public Polygonal2DRegion()
public Polygonal2DRegion(World world)
world
- the worldpublic Polygonal2DRegion(World world, java.util.List<BlockVector2> points, int minY, int maxY)
world
- the worldpoints
- list of pointsminY
- minimum YmaxY
- maximum Ypublic Polygonal2DRegion(Polygonal2DRegion region)
region
- the other regionpublic java.util.List<BlockVector2> getPoints()
protected void recalculate()
public void addPoint(BlockVector2 position)
position
- the positionpublic void addPoint(BlockVector3 position)
position
- the positionpublic int getMinimumY()
FlatRegion
getMinimumY
in interface FlatRegion
public void setMinimumY(int y)
y
- the Ypublic int getMaximumY()
FlatRegion
getMaximumY
in interface FlatRegion
public void setMaximumY(int y)
y
- the Ypublic BlockVector3 getMinimumPoint()
Region
getMinimumPoint
in interface Region
public BlockVector3 getMaximumPoint()
Region
getMaximumPoint
in interface Region
public long getVolume()
Region
getVolume
in interface Region
getVolume
in class AbstractRegion
public int getWidth()
AbstractRegion
getWidth
in interface Region
getWidth
in class AbstractRegion
public int getHeight()
AbstractRegion
getHeight
in interface Region
getHeight
in class AbstractRegion
public int getLength()
AbstractRegion
getLength
in interface Region
getLength
in class AbstractRegion
public void expand(BlockVector3... changes) throws RegionOperationException
Region
expand
in interface Region
changes
- array/arguments with multiple related changesRegionOperationException
- if the operation cannot be performedpublic void contract(BlockVector3... changes) throws RegionOperationException
Region
contract
in interface Region
changes
- array/arguments with multiple related changesRegionOperationException
- if the operation cannot be performedpublic void shift(BlockVector3 change) throws RegionOperationException
Region
shift
in interface Region
shift
in class AbstractRegion
change
- the changeRegionOperationException
- if the operation cannot be performedpublic boolean contains(BlockVector3 position)
Region
public static boolean contains(java.util.List<BlockVector2> points, int minY, int maxY, BlockVector3 pt)
points
- a list of pointsminY
- the min YmaxY
- the max Ypt
- the position to checkpublic int size()
public boolean expandY(int y)
y
- the amount to expandpublic java.util.Iterator<BlockVector3> iterator()
AbstractRegion
iterator
in interface java.lang.Iterable<BlockVector3>
iterator
in class AbstractRegion
public java.lang.Iterable<BlockVector2> asFlatRegion()
FlatRegion
asFlatRegion
in interface FlatRegion
public java.lang.String toString()
toString
in class java.lang.Object
public Polygonal2DRegion clone()
Region
clone
in interface Region
clone
in class AbstractRegion
public java.util.List<BlockVector2> polygonize(int maxPoints)
Region
polygonize
in interface Region
polygonize
in class AbstractRegion
maxPoints
- maximum number of points to generate. -1 for no limit.