Class 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
    • Constructor Detail

      • StickyBorders

        public StickyBorders()
    • Method Detail

      • 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 location
        displacement - 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.