Package repast.simphony.valueLayer
Class GridValueLayer
java.lang.Object
repast.simphony.valueLayer.GridValueLayer
- All Implemented Interfaces:
IGridValueLayer
,ValueLayer
A grid value layer. Each cell in the grid is accessed via integer x, y, z,
... n coordinates and contains some numeric value. Each cell in the grid will
contain a value regardless of whether or not it has been set yet. This
default value can be set by the user.
- Author:
- Nick Collier, Eric Tatara
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Dimensions
protected String
protected int[]
protected ValueLayerStore
protected int[]
protected GridPointTranslator
-
Constructor Summary
ConstructorDescriptionGridValueLayer
(String name, boolean dense, int... dimensions) Creates a GridValueLayer with the specified name, density, and dimensions.GridValueLayer
(String name, boolean dense, GridPointTranslator translator, int... dimensions) Creates a GridValueLayer with the specified name, density, translator, and dimensions.GridValueLayer
(String name, double defaultValue, boolean dense, int... dimensions) Creates a GridValueLayer with the specified name, density, defaultValue and dimensions.GridValueLayer
(String name, double defaultValue, boolean dense, GridPointTranslator translator, int... dimensions) Creates a GridValueLayer with the specified name, defaultValue, density, translator and dimensions.GridValueLayer
(String name, double defaultValue, boolean dense, GridPointTranslator translator, int[] dimensions, int[] origin) Creates a GridValueLayer with the specified name, defaultValue, density, translator and dimensions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
forEach
(GridFunction function, GridPoint origin, int... extent) Apply the specified function to each cell in the extent around the origin.double
get
(double... coordinates) Gets a value given the specified coordinates.Gets the dimensions of this GridValueLayer.Retrieves the rule being used for controlling what happens at or beyond the borders of the value layer.getName()
Gets the name of this ValueLayer.protected int[]
getTransformedLocation
(int... location) void
set
(double value, int... coordinate) Sets the specified cell to the specified value.void
Sets the rule to use for controlling what happens at or beyond the borders of the value layer.int
size()
Return the number of entries in the value layer.
-
Field Details
-
name
-
store
-
stride
protected int[] stride -
dims
-
origin
protected int[] origin -
dense
protected boolean dense -
translator
-
-
Constructor Details
-
GridValueLayer
Creates a GridValueLayer 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
-
GridValueLayer
Creates a GridValueLayer 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
-
GridValueLayer
public GridValueLayer(String name, boolean dense, GridPointTranslator translator, int... dimensions) Creates a GridValueLayer 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
-
GridValueLayer
public GridValueLayer(String name, double defaultValue, boolean dense, GridPointTranslator translator, int... dimensions) Creates a GridValueLayer 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
-
GridValueLayer
public GridValueLayer(String name, double defaultValue, boolean dense, GridPointTranslator translator, int[] dimensions, int[] origin) Creates a GridValueLayer 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 Details
-
forEach
Apply the specified function to each cell in the extent around the origin. This includes the origin itself.- Parameters:
function
-origin
-extent
-
-
get
public double get(double... coordinates) Gets a value given the specified coordinates. This assumes the coordinates are int x, y, z, n values.- Specified by:
get
in interfaceValueLayer
- Parameters:
coordinates
- the coordinates used to return the value.- Returns:
- a value given the specified coordinates.
-
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
-
getName
Gets the name of this ValueLayer.- Specified by:
getName
in interfaceValueLayer
- Returns:
- the name of this ValueLayer.
-
getDimensions
Gets the dimensions of this GridValueLayer.- Specified by:
getDimensions
in interfaceValueLayer
- Returns:
- the dimensions of this GridValueLayer.
-
getTransformedLocation
protected int[] getTransformedLocation(int... location) -
getGridPointTranslator
Retrieves the rule being used for controlling what happens at or beyond the borders of the value layer.- Returns:
- the rule for handling out of bounds coordinates
-
setGridPointTranslator
Sets the rule to use for controlling what happens at or beyond the borders of the value layer.- Parameters:
rule
- the rule for handling out of bounds coordinates
-
size
public int size()Return the number of entries in the value layer. For dense layers, this is the product of dimensions, eg x * y * z... For sparse layers, this is the number of entries in sparse storage.- Returns:
-