From: Nick C. <nic...@ve...> - 2011-06-20 13:35:08
|
Maurilio, What shows up in a grid is determined by the context associated with that grid. If two grids have the same context, then all the agents in that context should show up in both grids. It sounds like you need two subcontexts -- each with its own grid. The agents would move between those subcontexts and show up in the grids appropriately. Nick On Jun 18, 2011, at 4:26 PM, Maurilio Possi wrote: > I have two "worlds" in my project: Grid1 and Grid2. > > I created agents in Grid1 and, after some actions, the agents go to Grid2. > > They do that using this code: > > private void transportToGrid ( String gridName, int x, int y) { > ContextUtils.getContext(this).remove(this) > this.setGrid(gridName); > ContextUtils.getContext(this).add(this); > } > > And my grids has its own gridAdder methods, like follows: > > Grid1Adder: > private class Grid1Adder implements GridAdder<Agent> { > @Override > public void add(Grid<Agent> g, Agent obj) { > if (obj.getGrid().equals("Grid1")){ > obj.getGrid().moveTo(obj, obj.getX(), obj.getY()); > } > } > } > > Grid2Adder: > private class Grid2Adder implements GridAdder<Agent> { > @Override > public void add(Grid<Agent> g, Agent obj) { > if (obj.getGrid().equals("Grid2")){ > obj.getGrid().moveTo(obj, obj.getX(), obj.getY()); > } > } > } > > In the Repast Simphony Scenario Tree, I have two displays (Grid1 and Grid2), and both have the "Agent" in their "Agent Styles". > > The problem is that when a instance of Agent is transported from Grid1 to Grid2 (by calling transportToGrid(...)), all instances of Agent in Grid1 disappear, and the transported agent stay in Grid2 properly. > > Can instances of the same class be shown in different grids? > > What's the best method to transport agents from a grid to another grid? > > Thanks very muck for the help. > And sorry by my English. > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > Repast-interest mailing list > Rep...@li... > https://lists.sourceforge.net/lists/listinfo/repast-interest |