Package repast.simphony.space.grid
Class StickyBorders
- java.lang.Object
-
- repast.simphony.space.grid.AbstractGridPointTranslator
-
- repast.simphony.space.grid.StickyBorders
-
- All Implemented Interfaces:
GridPointTranslator
- Direct Known Subclasses:
InfiniteBorders
public class StickyBorders extends AbstractGridPointTranslator
Border implementation where translates across the border limits are clamped to the border coordinates. So, for example, the space goes from 0 to 10 and the translate results in 11 you end up at 10 (when traveling to 11 you get stuck to the wall). Transforms throw a SpatialException if the desired target location is outside of the grid's dimensions.- Author:
- Jerry Vos
-
-
Field Summary
-
Fields inherited from class repast.simphony.space.grid.AbstractGridPointTranslator
dimensions
-
-
Constructor Summary
Constructors Constructor Description StickyBorders()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getNewCoord(int dimension, int coord)
void
init(GridDimensions dimensions)
Initializes this with the given dimensions.boolean
isToroidal()
True if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.void
translate(int[] location, int... displacement)
Translates the specified location by the amount of displacement along each dimensions.-
Methods inherited from class repast.simphony.space.grid.AbstractGridPointTranslator
boundsCheck, transform, transform
-
-
-
-
Method Detail
-
init
public void init(GridDimensions dimensions)
Initializes this with the given dimensions.- Specified by:
init
in interfaceGridPointTranslator
- Overrides:
init
in classAbstractGridPointTranslator
- Parameters:
dimensions
- the dimensions of the space
-
getNewCoord
protected int getNewCoord(int dimension, int coord)
-
translate
public void translate(int[] location, int... displacement)
Translates the specified location by the amount of displacement along each dimensions. The results are clamped to the grid's dimensions. The translated location is returned in the location array.- Parameters:
location
- the current locationdisplacement
- the amount of displacement.
-
isToroidal
public boolean isToroidal()
Description copied from interface:GridPointTranslator
True if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.- Returns:
- true if this grid is toroidal, otherwise false.
-
-