Class GridBuilderParameters<T>


  • public class GridBuilderParameters<T>
    extends Object
    Parameters for creating grids. This class includes static convenience methods for creating some common types of grids.
    Author:
    Nick Collier
    See Also:
    GridAdder, GridPointTranslator
    • Field Detail

      • dims

        protected int[] dims
      • origin

        protected int[] origin
      • isMulti

        protected boolean isMulti
    • Constructor Detail

      • GridBuilderParameters

        public GridBuilderParameters​(GridPointTranslator borderRule,
                                     GridAdder<T> adder,
                                     boolean multi,
                                     int... dims)
        Creates parameters with the specified border rule, adder, multi occupancy and dimensions.
        Parameters:
        borderRule - the rule used to determine border behavior
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        multi - whether or not each cell in the grid is multi-occupancy
        dims - the dimensions of the grid
        See Also:
        GridAdder, GridPointTranslator
      • GridBuilderParameters

        public GridBuilderParameters​(GridPointTranslator borderRule,
                                     GridAdder<T> adder,
                                     boolean multi,
                                     int[] dims,
                                     int[] origin)
        Creates parameters with the specified border rule, adder, multi occupancy, dimensions and origin.
        Parameters:
        borderRule - the rule used to determine border behavior
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        multi - whether or not each cell in the grid is multi-occupancy
        dims - the dimensions of the grid
        origin - the origin of the grid
        See Also:
        GridAdder, GridPointTranslator
    • Method Detail

      • getGridPointTranslator

        public GridPointTranslator getGridPointTranslator()
        Gets the grid point translator used to calculate points when moving by displacement. This can be used to set the translator so that the new point is the result of a bounce off a boundary.
        Returns:
        the
      • getAdder

        public GridAdder<T> getAdder()
        Gets the adder used to add objects entered into the context automatically to the grid.
        Returns:
        the adder used to add objects entered into the context automatically to the grid.
      • getDimensions

        public int[] getDimensions()
        Gets the dimensions of the grid.
        Returns:
        the dimensions of the grid.
      • getOrigin

        public int[] getOrigin()
        Gets the origin of the grid.
        Returns:
        the origin of the grid.
      • isMultOccupancy

        public boolean isMultOccupancy()
        Returns:
        true if each grid cell can hold more than one object
      • singleOccupancy1D

        public static <T> GridBuilderParameters<T> singleOccupancy1D​(GridAdder<T> adder,
                                                                     GridPointTranslator borderRule,
                                                                     int size)
        Returns GridBuilderParameters suitable for creating a single occupancy 1 dimensional grid.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        borderRule - the rule used to determine border behavior
        size - the size of the single dimension
        Returns:
        GridBuilderParameters suitable for creating a single occupancy 1 dimensional grid.
      • singleOccupancy1DTorus

        public static <T> GridBuilderParameters<T> singleOccupancy1DTorus​(GridAdder<T> adder,
                                                                          int size)
        Returns GridBuilderParameters suitable for creating a single occupancy 1 dimensional periodic wrapped grid. That is, the ends of the grid are joined.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        size - the size of the single dimension
        Returns:
        GridBuilderParameters suitable for creating a single occupancy 1 dimensional periodic wrapped grid.
      • singleOccupancy2D

        public static <T> GridBuilderParameters<T> singleOccupancy2D​(GridAdder<T> adder,
                                                                     GridPointTranslator borderRule,
                                                                     int xSize,
                                                                     int ySize)
        Returns GridBuilderParameters suitable for creating a single occupancy 2 dimensional grid.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        borderRule - the rule used to determine border behavior
        xSize - the size of the x dimension
        ySize - the size of the y dimension
        Returns:
        GridBuilderParameters suitable for creating a single occupancy 2 dimensional grid.
      • singleOccupancy2DTorus

        public static <T> GridBuilderParameters<T> singleOccupancy2DTorus​(GridAdder<T> adder,
                                                                          int xSize,
                                                                          int ySize)
        Returns GridBuilderParameters suitable for creating a single occupancy 2 dimensional torus.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        xSize - the size of the x dimension
        ySize - the size of the y dimension
        Returns:
        GridBuilderParameters suitable for creating a single occupancy 2 dimensional torus.
      • singleOccupancyND

        public static <T> GridBuilderParameters<T> singleOccupancyND​(GridAdder<T> adder,
                                                                     GridPointTranslator borderRule,
                                                                     int... dimensions)
        Returns GridBuilderParameters suitable for creating a single occupancy n-dimensional grid.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        borderRule - the rule used to determine border behavior
        dimensions - the dimensions of the grid
        Returns:
        GridBuilderParameters suitable for creating a single occupancy n-dimensional grid.
      • singleOccupancyNDTorus

        public static <T> GridBuilderParameters<T> singleOccupancyNDTorus​(GridAdder<T> adder,
                                                                          int... dimensions)
        Returns GridBuilderParameters suitable for creating a single occupancy n-dimensional torus.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        dimensions - the dimensions of the grid
        Returns:
        GridBuilderParameters suitable for creating a single occupancy n-dimensional torus.
      • multiOccupancy1D

        public static <T> GridBuilderParameters<T> multiOccupancy1D​(GridAdder<T> adder,
                                                                    GridPointTranslator borderRule,
                                                                    int size)
        Returns GridBuilderParameters suitable for creating a multi-occupancy 1 dimensional grid.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        borderRule - the rule used to determine border behavior
        size - the size of the single dimension
        Returns:
        GridBuilderParameters suitable for creating a single occupancy 1 dimensional grid.
      • multiOccupancy1DTorus

        public static <T> GridBuilderParameters<T> multiOccupancy1DTorus​(GridAdder<T> adder,
                                                                         int size)
        Returns GridBuilderParameters suitable for creating a multi occupancy 1 dimensional periodic wrapped grid. That is, the ends of the grid are joined.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        size - the size of the single dimension
        Returns:
        GridBuilderParameters suitable for creating a multi occupancy 1 dimensional periodic wrapped grid.
      • multiOccupancy2D

        public static <T> GridBuilderParameters<T> multiOccupancy2D​(GridAdder<T> adder,
                                                                    GridPointTranslator borderRule,
                                                                    int xSize,
                                                                    int ySize)
        Returns GridBuilderParameters suitable for creating a multi occupancy 2 dimensional grid.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        borderRule - the rule used to determine border behavior
        xSize - the size of the x dimension
        ySize - the size of the y dimension
        Returns:
        GridBuilderParameters suitable for creating a multi occupancy 2 dimensional grid.
      • multiOccupancy2DTorus

        public static <T> GridBuilderParameters<T> multiOccupancy2DTorus​(GridAdder<T> adder,
                                                                         int xSize,
                                                                         int ySize)
        Returns GridBuilderParameters suitable for creating a multi occupancy 2 dimensional torus.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        xSize - the size of the x dimension
        ySize - the size of the y dimension
        Returns:
        GridBuilderParameters suitable for creating a multi occupancy 2 dimensional torus.
      • multiOccupancyND

        public static <T> GridBuilderParameters<T> multiOccupancyND​(GridAdder<T> adder,
                                                                    GridPointTranslator borderRule,
                                                                    int... dimensions)
        Returns GridBuilderParameters suitable for creating a multi occupancy n-dimensional grid.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        borderRule - the rule used to determine border behavior
        dimensions - the dimensions of the grid
        Returns:
        GridBuilderParameters suitable for creating a multi occupancy n-dimensional grid.
      • multiOccupancyNDTorus

        public static <T> GridBuilderParameters<T> multiOccupancyNDTorus​(GridAdder<T> adder,
                                                                         int... dimensions)
        Returns GridBuilderParameters suitable for creating a multi occupancy n-dimensional torus.
        Parameters:
        adder - the adder used to add objects to the grid when those objects are added to the context for which the grid is a projection
        dimensions - the dimensions of the grid
        Returns:
        GridBuilderParameters suitable for creating a multi occupancy n-dimensional torus.