Class ContextGrid<T>

All Implemented Interfaces:
ContextListener<T>, Grid<T>, Projection<T>

public class ContextGrid<T> extends DefaultGrid<T> implements ContextListener<T>
Default implementation of an n-dimensional grid.
  • Constructor Details

    • ContextGrid

      public ContextGrid(String name, GridAdder<T> adder, GridPointTranslator translator, CellAccessor<T,Map<GridPoint,Object>> accessor, int... size)
      Constructs this space with the specified name, adder, translator, accessor and size. The size is the size of the space meaning [3, 3] is a 3x3 space.
      Parameters:
      name - the name of the space
      size - the dimensions of the space
    • ContextGrid

      public ContextGrid(String name, GridAdder<T> adder, GridPointTranslator translator, CellAccessor<T,Map<GridPoint,Object>> accessor, int[] size, int[] origin)
      Constructs this space with the specified name, adder, translator, accessor, size, and origin. The size is the size of the space meaning [3, 3] is a 3x3 space. The origin is the offset on the space where the [0,0] grid point is.
      Parameters:
      name - the name of the space
      size - the dimensions of the space
      origin - the origin of the space
  • Method Details

    • eventOccured

      public void eventOccured(ContextEvent<T> evt)
      If the event is an add this will put the object at the (0, 0, ..., 0) location. If it is a remove it will remove the object from its location map.
      Specified by:
      eventOccured in interface ContextListener<T>
      Parameters:
      evt - a ContextEvent that occurred to the context this is a part of
    • addFromContext

      protected void addFromContext(T t)
    • addAll

      protected void addAll(Context<T> context)