Class BufferedGridValueLayer

java.lang.Object
repast.simphony.valueLayer.BufferedGridValueLayer
All Implemented Interfaces:
IGridValueLayer, ValueLayer

public class BufferedGridValueLayer extends Object implements IGridValueLayer
Implements a grid value layer with read and write buffers. All setting is done on the write buffer and all reading is done on the read buffer. The swap method swaps the read and write buffers.
Author:
Nick Collier
  • Constructor Details

    • BufferedGridValueLayer

      public BufferedGridValueLayer(String name, boolean dense, int... dimensions)
      Creates a BufferedGridValueLayer with the specified name, density, and dimensions. The default value of every cell in the grid will be 0. The default border behavior is strict.
      Parameters:
      name - the name of the value layer
      dense - if value layer will be densely populated
      dimensions - the dimension of the value layer
    • BufferedGridValueLayer

      public BufferedGridValueLayer(String name, double defaultValue, boolean dense, int... dimensions)
      Creates a BufferedGridValueLayer with the specified name, density, defaultValue and dimensions. The default border behavior is strict.
      Parameters:
      name - the name of the value layer
      defaultValue - the default value that each grid cell will contain if it has not been set yet
      dense - if the value layer will be densely populated
      dimensions - the dimension of the grid value layer
    • BufferedGridValueLayer

      public BufferedGridValueLayer(String name, boolean dense, GridPointTranslator translator, int... dimensions)
      Creates a BufferedGridValueLayer with the specified name, density, translator, and dimensions. The default border behavior is strict. The default value of every cell in the grid will be 0.
      Parameters:
      name - the name of the value layer
      defaultValue - the default value that each grid cell will contain if it has not been set yet
      dense - if the value layer will be densely populated
      translator - the translator used
      dimensions - the dimension of the value layer
    • BufferedGridValueLayer

      public BufferedGridValueLayer(String name, double defaultValue, boolean dense, GridPointTranslator translator, int... dimensions)
      Creates a BufferedGridValueLayer with the specified name, defaultValue, density, translator and dimensions.
      Parameters:
      name - the name of the value layer
      defaultValue - the default value that each grid cell will contain if it has not been set yet
      dense - if value layer will be densely populated
      translator - the translator used
      dimensions - the dimension of the value layer
    • BufferedGridValueLayer

      public BufferedGridValueLayer(String name, double defaultValue, boolean dense, GridPointTranslator translator, int[] dimensions, int[] origin)
      Creates a BufferedGridValueLayer with the specified name, defaultValue, density, translator and dimensions.
      Parameters:
      name - the name of the value layer
      defaultValue - the default value that each grid cell will contain if it has not been set yet
      dense - if value layer will be densely populated
      translator - the translator used
      dimensions - the dimension of the value layer
  • Method Details

    • get

      public double get(double... coordinate)
      Description copied from interface: ValueLayer
      Gets a value given the specified coordinates.
      Specified by:
      get in interface ValueLayer
      Parameters:
      coordinate - the coordinates used to return the value.
      Returns:
      a value given the specified coordinates.
    • forEach

      public void forEach(GridFunction function, GridPoint origin, BufferedGridValueLayer.Buffer buffer, int... extent)
      Apply the specified function to each cell in the extent around the origin. This includes the origin itself.
      Parameters:
      function -
      origin -
      buffer - specifies which buffer the function operates on
      extent -
    • getDimensions

      public Dimensions getDimensions()
      Description copied from interface: ValueLayer
      Gets the dimensions of this ValueLayer.
      Specified by:
      getDimensions in interface ValueLayer
      Returns:
      the dimensions of this ValueLayer.
    • getName

      public String getName()
      Description copied from interface: ValueLayer
      Gets the name of this ValueLayer.
      Specified by:
      getName in interface ValueLayer
      Returns:
      the name of this ValueLayer.
    • set

      public void set(double value, int... coordinate)
      Sets the specified cell to the specified value.
      Specified by:
      set in interface IGridValueLayer
      Parameters:
      value - the new value of the cell
      coordinate - the coordinate of the cell whose value we want to set
    • swap

      public void swap()
      Swaps the read and write buffers.