1

I am novice in java and repast. I am trying to create a list of Grid cells (grid cells) of type gridcells (valuelayer cells) but I keep getting the error "The type GridCell is not generic; it cannot be parameterized with arguments "

How do I fix this?

package tester;

import java.util.List;

import repast.simphony.context.Context;
import repast.simphony.engine.environment.RunEnvironment;
import repast.simphony.engine.schedule.ScheduledMethod;
import repast.simphony.parameter.Parameters;
//import repast.simphony.query.space.grid.GridCell;
import repast.simphony.query.space.grid.GridCellNgh;
import repast.simphony.space.grid.Grid;
import repast.simphony.space.grid.GridPoint;
import repast.simphony.valueLayer.AbstractGridFunction;
import repast.simphony.valueLayer.BufferedGridValueLayer;
import repast.simphony.valueLayer.BufferedGridValueLayer.Buffer;
import repast.simphony.valueLayer.GridCell;
import repast.simphony.valueLayer.MaxGridFunction;
import repast.simphony.valueLayer.MinGridFunction;

            private void Move() {
                // TODO Auto-generated method stub

                BufferedGridValueLayer heat = (BufferedGridValueLayer) context.getValueLayer("Heat Layer");
                Grid <Object> grid = (Grid <Object>) context.getProjection("Insulation Grid");

                //Get the Grid Location of this insulation unit.
                GridPoint pt = grid.getLocation(this);

                //Use the GridCellNgh to retrieve the list of of Gridcells (grid) contianing Gridcells (valueLayergrid). 
                GridCellNgh <GridCell> nghCreator = new GridCellNgh <GridCell> (grid, pt, GridCell.class, 1, 1);


                List <GridCell <GridCell>> gridCells = nghCreator.getNeighborhood(true);
            }  
Tannay
  • 17
  • 5
  • Does the example require all the imports, can any be trimmed? – James K Sep 03 '16 at 12:37
  • @JamesK I have only copied a part of the code. There are other parts of the code which need the imports in order to work. – Tannay Sep 05 '16 at 09:49
  • See http://stackoverflow.com/help/mcve – James K Sep 05 '16 at 16:46
  • Issue is with the last line. `GridCell` is not generic, so you cannot do `GridCell`. Use just `List` – Xiongbing Jin Sep 05 '16 at 21:10
  • @warmoverflow Many thanks for the suggestion, I had already tried your suggestion before posting this question. It did not help in resolving the issue. I then decided to manually check my neighbourhood which worked. – Tannay Sep 13 '16 at 15:09

1 Answers1

1

There is some confusion because there are two GridCell classes in the Repast API.

GridCellNgh.getNeighborhood(true) returns type repast.simphony.query.space.grid.GridCell<T> which is a container for agents located at a specific grid location. The GridCellNgh class is meant for retrieving these types of grid cells based on the type of agent classes and will not work for ValueLayer repast.simphony.valueLayer.GridCell objects.

GridCellNgh can be used to get the list of GridPoints from which you can get the associated GridCell via GridCell.getPoint(), however this assumes that all of the surrounding grid locations are filled with the agent class passed into GridCellNgh constructor which is only practical when the Grid is completely filled with agents.

I would suggest simply using GridPoint pt = grid.getLocation(this) as you currently do to get the center point and then just access the value layer based on the center x,y at each x+/-1, y+/-1 that makes up the Moore neighborhood.

Eric Tatara
  • 715
  • 3
  • 12