Class GridValueLayer

  • All Implemented Interfaces:
    IGridValueLayer, ValueLayer

    public class GridValueLayer
    extends Object
    implements IGridValueLayer
    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
    • Constructor Detail

      • GridValueLayer

        public GridValueLayer​(String name,
                              boolean dense,
                              int... dimensions)
        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 layer
        dense - if value layer will be densely populated
        dimensions - the dimension of the value layer
      • GridValueLayer

        public GridValueLayer​(String name,
                              double defaultValue,
                              boolean dense,
                              int... dimensions)
        Creates a GridValueLayer 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
      • 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 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
      • 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 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
      • 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 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 Detail

      • forEach

        public void forEach​(GridFunction function,
                            GridPoint origin,
                            int... extent)
        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 interface ValueLayer
        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 interface IGridValueLayer
        Parameters:
        value - the new value of the cell
        coordinate - the coordinate of the cell whose value we want to set
      • getName

        public String getName()
        Gets the name of this ValueLayer.
        Specified by:
        getName in interface ValueLayer
        Returns:
        the name of this ValueLayer.
      • getDimensions

        public Dimensions getDimensions()
        Gets the dimensions of this GridValueLayer.
        Specified by:
        getDimensions in interface ValueLayer
        Returns:
        the dimensions of this GridValueLayer.
      • getTransformedLocation

        protected int[] getTransformedLocation​(int... location)
      • getGridPointTranslator

        public GridPointTranslator 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

        public void setGridPointTranslator​(GridPointTranslator rule)
        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: