Class WrapAroundBorders

java.lang.Object
repast.simphony.space.grid.WrapAroundBorders
All Implemented Interfaces:
GridPointTranslator

public class WrapAroundBorders extends Object implements GridPointTranslator
Periodic type border implementation. Translates and transforms beyond the grid's dimensions are wrapped around the borders. Creating a 2D grid with these types of border results in a torus.
Author:
Jerry Vos
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
     
    protected GridDimensions
     
    protected int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    getNewCoord(int dimension, int location)
     
    void
    init(GridDimensions dimensions)
    Initializes this with the given dimensions.
    boolean
    True if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.
    void
    transform(int[] transformedLocation, int... targetLocation)
    Transform the given targetLocation according to periodic "wrapped" semantics.
    void
    transform(GridPoint transformedLocation, int... targetLocation)
    Transform the given targetLocation according to periodic "wrapped" semantics.
    void
    translate(int[] location, int... displacement)
    Translates the specified location by the specified displacement according to periodic "wrapped" semantics.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • spaceDimensions

      protected transient GridDimensions spaceDimensions
    • spaceWidths

      protected transient int[] spaceWidths
    • origin

      protected transient int[] origin
  • Constructor Details

    • WrapAroundBorders

      public WrapAroundBorders()
  • Method Details

    • init

      public void init(GridDimensions dimensions)
      Initializes this with the given dimensions.
      Specified by:
      init in interface GridPointTranslator
      Parameters:
      dimensions - the dimensions of the space
    • translate

      public void translate(int[] location, int... displacement)
      Translates the specified location by the specified displacement according to periodic "wrapped" semantics. Locations outside the grid will be wrapped into the grid's dimensions. The results will be placed into the location array.
      Specified by:
      translate in interface GridPointTranslator
      Parameters:
      location - the current location
      displacement - the amount of displacement
    • transform

      public void transform(int[] transformedLocation, int... targetLocation) throws SpatialException
      Transform the given targetLocation according to periodic "wrapped" semantics. The new transformed coordinates will be placed in the transformedLocation.
      Specified by:
      transform in interface GridPointTranslator
      Parameters:
      transformedLocation - the coordinates once they have been transformed by this GridPointTranslator
      targetLocation - the new target location whose coordinates will be transformed
      Throws:
      SpatialException - if the transform is invalid.
    • transform

      public void transform(GridPoint transformedLocation, int... targetLocation) throws SpatialException
      Transform the given targetLocation according to periodic "wrapped" semantics. The new transformed coordinates will be placed in the transformedLocation.
      Specified by:
      transform in interface GridPointTranslator
      Parameters:
      transformedLocation - the coordinates once they have been transformed by this GridPointTranslator
      targetLocation - the new target location whose coordinates will be transformed
      Throws:
      SpatialException - if the transform is invalid.
    • getNewCoord

      protected int getNewCoord(int dimension, int location)
    • 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.
      Specified by:
      isToroidal in interface GridPointTranslator
      Returns:
      true if this grid is toroidal, otherwise false.