Package repast.simphony.valueLayer
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. Theswap
method swaps the read and write buffers.- Author:
- Nick Collier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BufferedGridValueLayer.Buffer
-
Constructor Summary
Constructors Constructor Description BufferedGridValueLayer(String name, boolean dense, int... dimensions)
Creates a BufferedGridValueLayer with the specified name, density, and dimensions.BufferedGridValueLayer(String name, boolean dense, GridPointTranslator translator, int... dimensions)
Creates a BufferedGridValueLayer with the specified name, density, translator, and dimensions.BufferedGridValueLayer(String name, double defaultValue, boolean dense, int... dimensions)
Creates a BufferedGridValueLayer with the specified name, density, defaultValue and dimensions.BufferedGridValueLayer(String name, double defaultValue, boolean dense, GridPointTranslator translator, int... dimensions)
Creates a BufferedGridValueLayer with the specified name, defaultValue, density, translator and dimensions.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
forEach(GridFunction function, GridPoint origin, BufferedGridValueLayer.Buffer buffer, int... extent)
Apply the specified function to each cell in the extent around the origin.double
get(double... coordinate)
Gets a value given the specified coordinates.Dimensions
getDimensions()
Gets the dimensions of this ValueLayer.String
getName()
Gets the name of this ValueLayer.void
set(double value, int... coordinate)
Sets the specified cell to the specified value.void
swap()
Swaps the read and write buffers.
-
-
-
Constructor Detail
-
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 layerdense
- if value layer will be densely populateddimensions
- 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 layerdefaultValue
- the default value that each grid cell will contain if it has not been set yetdense
- if the value layer will be densely populateddimensions
- 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 layerdefaultValue
- the default value that each grid cell will contain if it has not been set yetdense
- if the value layer will be densely populatedtranslator
- the translator useddimensions
- 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 layerdefaultValue
- the default value that each grid cell will contain if it has not been set yetdense
- if value layer will be densely populatedtranslator
- the translator useddimensions
- 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 layerdefaultValue
- the default value that each grid cell will contain if it has not been set yetdense
- if value layer will be densely populatedtranslator
- the translator useddimensions
- the dimension of the value layer
-
-
Method Detail
-
get
public double get(double... coordinate)
Description copied from interface:ValueLayer
Gets a value given the specified coordinates.- Specified by:
get
in interfaceValueLayer
- 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 onextent
-
-
getDimensions
public Dimensions getDimensions()
Description copied from interface:ValueLayer
Gets the dimensions of this ValueLayer.- Specified by:
getDimensions
in interfaceValueLayer
- 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 interfaceValueLayer
- 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 interfaceIGridValueLayer
- Parameters:
value
- the new value of the cellcoordinate
- the coordinate of the cell whose value we want to set
-
swap
public void swap()
Swaps the read and write buffers.
-
-