Class CoordArea
- All Implemented Interfaces:
CoordShape
A CoordArea is defined by two corner Coord values and a target floor.
X- and Y-spans are automatically normalized via Range.ordered(int, int),
ensuring minimum() <= maximum() for both axes.
All coordinates are inclusive: an area from (10, 20) to (12, 23) contains 3 × 4 = 12 tiles.
Floor-level handling
By default, the area only matches coordinates on the same floor level. CallingignoreFloorLevel() allows contains(SceneNode) to match
regardless of floor.-
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the given coordinate lies inside this rectangular area.static CoordAreastatic CoordAreaConstructs a rectangular coordinate area from two opposite corner coordinates, using the floor of the coord as the area floorstatic CoordAreaConstructs a rectangular coordinate area from two opposite corner coordinates.getBoundary(boolean outer) Returns all coordinates forming the perimeter of the rectangle.Returns all coordinates contained within this rectangular area.getEast(boolean outer) Returns the coordinates along the east side of this area.intintReturns the height of the area in tiles.getNorth(boolean outer) Returns the coordinates along the north side of this area.getSouth(boolean outer) Returns the coordinates along the south side of this area.Returns the four rectangle corner coordinates in a fixed order: bottom-left, top-left, bottom-right, top-right.getWest(boolean outer) Returns the coordinates along the west side of this area.intgetWidth()Returns the width of the area in tiles.org.rspeer.commons.math.RangegetXs()org.rspeer.commons.math.RangegetYs()Allows the area to match coordinates on any floor level instead of only the configuredfloorLevel.static CoordAreasurrounding(Coord origin, int distance) toArea()Deprecated.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CoordShape
getCenter, getRandomCoord
-
Method Details
-
surrounding
-
from
Constructs a rectangular coordinate area from two opposite corner coordinates.The X and Y ranges are normalized so that the rectangle always spans:
xs.minimum() .. xs.maximum() ys.minimum() .. ys.maximum()
- Parameters:
a- one corner of the rectangleb- the opposite corner of the rectanglefloorLevel- the floor level this area applies to
-
from
Constructs a rectangular coordinate area from two opposite corner coordinates, using the floor of the coord as the area floorThe X and Y ranges are normalized so that the rectangle always spans:
xs.minimum() .. xs.maximum() ys.minimum() .. ys.maximum()
- Parameters:
a- one corner of the rectangleb- the opposite corner of the rectangle
-
from
Creates aCoordArearepresenting exactly one tile — the givenCoord.This is equivalent to constructing an area where both corners are the same coordinate:
new CoordArea(coord, coord, coord.getFloorLevel())
The resulting area has:
- width = 1
- height = 1
- floor level taken from the provided coord
- exactly one tile returned by
getCoords()
- Parameters:
coord- the coordinate defining the single-tile area (must not be null)- Returns:
- a
CoordAreacontaining only the specified coordinate
-
toArea
Deprecated. -
ignoreFloorLevel
Allows the area to match coordinates on any floor level instead of only the configuredfloorLevel.- Returns:
- this area (for chaining)
-
getXs
public org.rspeer.commons.math.Range getXs()- Returns:
- the inclusive X-range for this area
-
getYs
public org.rspeer.commons.math.Range getYs()- Returns:
- the inclusive Y-range for this area
-
getBottomLeft
-
getBottomRight
-
getTopLeft
-
getTopRight
-
getWidth
public int getWidth()Returns the width of the area in tiles.Because the range is inclusive, width is computed as:
maxX - minX + 1
- Returns:
- the number of tiles spanned along the X axis
-
getHeight
public int getHeight()Returns the height of the area in tiles.- Returns:
- the number of tiles spanned along the Y axis
-
contains
Checks whether the given coordinate lies inside this rectangular area.If
ignoreFloorLevel()was called, the floor does not matter.- Specified by:
containsin interfaceCoordShape- Parameters:
node- the node to test- Returns:
trueif inside the rectangle
-
getVertices
Returns the four rectangle corner coordinates in a fixed order: bottom-left, top-left, bottom-right, top-right.- Specified by:
getVerticesin interfaceCoordShape- Returns:
- an immutable set of the rectangle's vertices
-
getBoundary
Returns all coordinates forming the perimeter of the rectangle.- Specified by:
getBoundaryin interfaceCoordShape- Parameters:
outer- iftrue, returns the outer boundary (one tile outside the rectangle);
iffalse, returns the perimeter tiles on the rectangle itself.- Returns:
- a set of perimeter coordinates
-
getEast
-
getWest
-
getSouth
-
getNorth
-
getCoords
Returns all coordinates contained within this rectangular area.For large rectangles, this may be a large set. The set is pre-sized to avoid internal resizing.
- Specified by:
getCoordsin interfaceCoordShape- Returns:
- all coordinates inside the area
-
getFloorLevel
public int getFloorLevel()- Specified by:
getFloorLevelin interfaceCoordShape
-
getAreaView
-