Package com.sk89q.worldedit.regions
Class Polygonal2DRegion
java.lang.Object
java.util.AbstractCollection<BlockVector3>
java.util.AbstractSet<BlockVector3>
com.sk89q.worldedit.regions.AbstractRegion
com.sk89q.worldedit.regions.Polygonal2DRegion
- All Implemented Interfaces:
IBatchProcessor
,FlatRegion
,Region
,Cloneable
,Iterable<BlockVector3>
,Collection<BlockVector3>
,Set<BlockVector3>
Represents a 2D polygonal region.
-
Field Summary
Fields inherited from class com.sk89q.worldedit.regions.AbstractRegion
world
-
Constructor Summary
ConstructorDescriptionConstruct the region.Polygonal2DRegion
(Polygonal2DRegion region) Make a copy of another region.Polygonal2DRegion
(World world) Construct the region.Polygonal2DRegion
(World world, List<BlockVector2> points, int minY, int maxY) Construct the region. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPoint
(BlockVector2 position) Add a point to the list.void
addPoint
(BlockVector3 position) Add a point to the list.Get this region as an iterable flat region.clone()
Make a clone of the region.boolean
contains
(int targetX, int targetZ) boolean
contains
(BlockVector3 position) Returns true based on whether the region contains the point.static boolean
contains
(List<BlockVector2> points, int minY, int maxY, BlockVector3 pt) Checks to see if a point is inside a region.boolean
containsEntireCuboid
(int bx, int tx, int by, int ty, int bz, int tz) 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
Get Y-size.int
Get Z-size.Get the upper point of a region.int
Gets the maximum Y value.Get the lower point of a region.int
Gets the minimum Y value.Get the list of points.long
Get the number of blocks in the region.int
getWidth()
Get X-size.iterator()
Get the iterator.polygonize
(int maxPoints) Polygonizes a cross-section or a 2D projection of the region orthogonal to the Y axis.protected void
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.toString()
Returns string representation in the format "(x1, z1) - ...Methods inherited from class com.sk89q.worldedit.regions.AbstractRegion
equals, getCenter, getChunkCubes, getChunks, getWorld, getWorldMaxY, getWorldMinY, hashCode, setWorld
Methods inherited from class java.util.AbstractSet
removeAll
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface com.fastasyncworldedit.core.queue.IBatchProcessor
flush, join, joinPost, postProcess, postProcessSet, processGet, remove, trimNBT, trimNBT, trimY
Methods inherited from interface com.sk89q.worldedit.regions.Region
construct, contains, containsChunk, filter, filter, filter, filter, filter, getArea, getBoundingBox, getCenter, getChunkCubes, getChunks, getDimensions, getScope, getWorld, isGlobal, processSet, processSet, setWorld
-
Constructor Details
-
Polygonal2DRegion
public Polygonal2DRegion()Construct the region. -
Polygonal2DRegion
Construct the region.- Parameters:
world
- the world
-
Polygonal2DRegion
Construct the region.- Parameters:
world
- the worldpoints
- list of pointsminY
- minimum YmaxY
- maximum Y
-
Polygonal2DRegion
Make a copy of another region.- Parameters:
region
- the other region
-
-
Method Details
-
getPoints
Get the list of points.- Returns:
- a list of points
-
recalculate
protected void recalculate()Recalculate the bounding box of this polygonal region. This should be called after points have been changed. -
addPoint
Add a point to the list.- Parameters:
position
- the position
-
addPoint
Add a point to the list.- Parameters:
position
- the position
-
getMinimumY
public int getMinimumY()Description copied from interface:FlatRegion
Gets the minimum Y value.- Specified by:
getMinimumY
in interfaceFlatRegion
- Specified by:
getMinimumY
in interfaceRegion
- Returns:
- the Y value
-
setMinimumY
public void setMinimumY(int y) Set the minimum Y.- Parameters:
y
- the Y
-
getMaximumY
public int getMaximumY()Description copied from interface:FlatRegion
Gets the maximum Y value.- Specified by:
getMaximumY
in interfaceFlatRegion
- Specified by:
getMaximumY
in interfaceRegion
- Returns:
- the Y value
-
setMaximumY
public void setMaximumY(int y) Set the maximum Y.- Parameters:
y
- the Y
-
getMinimumPoint
Description copied from interface:Region
Get the lower point of a region.- Specified by:
getMinimumPoint
in interfaceRegion
- Returns:
- min. point
-
getMaximumPoint
Description copied from interface:Region
Get the upper point of a region.- Specified by:
getMaximumPoint
in interfaceRegion
- Returns:
- max. point
-
getVolume
public long getVolume()Description copied from interface:Region
Get the number of blocks in the region.- Specified by:
getVolume
in interfaceRegion
- Overrides:
getVolume
in classAbstractRegion
- Returns:
- number of blocks
-
getWidth
public int getWidth()Description copied from class:AbstractRegion
Get X-size.- Specified by:
getWidth
in interfaceRegion
- Overrides:
getWidth
in classAbstractRegion
- Returns:
- width
-
getHeight
public int getHeight()Description copied from class:AbstractRegion
Get Y-size.- Specified by:
getHeight
in interfaceRegion
- Overrides:
getHeight
in classAbstractRegion
- Returns:
- height
-
getLength
public int getLength()Description copied from class:AbstractRegion
Get Z-size.- Specified by:
getLength
in interfaceRegion
- Overrides:
getLength
in classAbstractRegion
- Returns:
- length
-
expand
Description copied from interface:Region
Expand the region.- Specified by:
expand
in interfaceRegion
- Parameters:
changes
- array/arguments with multiple related changes- Throws:
RegionOperationException
- if the operation cannot be performed
-
contract
Description copied from interface:Region
Contract the region.- Specified by:
contract
in interfaceRegion
- Parameters:
changes
- array/arguments with multiple related changes- Throws:
RegionOperationException
- if the operation cannot be performed
-
shift
Description copied from interface:Region
Shift the region.- Specified by:
shift
in interfaceRegion
- Overrides:
shift
in classAbstractRegion
- Parameters:
change
- the change- Throws:
RegionOperationException
- if the operation cannot be performed
-
contains
public boolean contains(int targetX, int targetZ) -
contains
Description copied from interface:Region
Returns true based on whether the region contains the point. -
contains
Checks to see if a point is inside a region.- Parameters:
points
- a list of pointsminY
- the min YmaxY
- the max Ypt
- the position to check- Returns:
- true if the given polygon contains the given point
-
size
public int size()Return the number of points.- Specified by:
size
in interfaceCollection<BlockVector3>
- Specified by:
size
in interfaceSet<BlockVector3>
- Overrides:
size
in classAbstractRegion
- Returns:
- the number of points
-
expandY
public boolean expandY(int y) Expand the height of the polygon to fit the specified Y.- Parameters:
y
- the amount to expand- Returns:
- true if the area was expanded
-
iterator
Description copied from class:AbstractRegion
Get the iterator.- Specified by:
iterator
in interfaceCollection<BlockVector3>
- Specified by:
iterator
in interfaceIterable<BlockVector3>
- Specified by:
iterator
in interfaceSet<BlockVector3>
- Overrides:
iterator
in classAbstractRegion
- Returns:
- iterator of points inside the region
-
asFlatRegion
Description copied from interface:FlatRegion
Get this region as an iterable flat region.- Specified by:
asFlatRegion
in interfaceFlatRegion
- Returns:
- a flat region iterable
-
toString
Returns string representation in the format "(x1, z1) - ... - (xN, zN) * (minY - maxY)"- Overrides:
toString
in classAbstractCollection<BlockVector3>
- Returns:
- string
-
clone
Description copied from interface:Region
Make a clone of the region.- Specified by:
clone
in interfaceRegion
- Overrides:
clone
in classAbstractRegion
- Returns:
- a cloned version
-
polygonize
Description copied from interface:Region
Polygonizes a cross-section or a 2D projection of the region orthogonal to the Y axis.- Specified by:
polygonize
in interfaceRegion
- Overrides:
polygonize
in classAbstractRegion
- Parameters:
maxPoints
- maximum number of points to generate. -1 for no limit.- Returns:
- the points.
-
containsEntireCuboid
public boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) - Specified by:
containsEntireCuboid
in interfaceRegion
-