On Wed, Mar 27, 2013 at 4:07 PM, Luís de Sousa <[log in to unmask]> wrote:
> I noted today that geometries that have been removed using this method
> continue to be drawn in the display. I have an Agent class that
> inherits from MasonGeometry; this particular agent can "die" during
> simulation and its stop() method is invoked. When this happens with an
> agent stored in a Continuous2D, for instance, invoking the remove()
> method is enough to prevent it from being drawn again.
> After invoking removeGeometry() is there anything else referencing the geometry?
More than likely you are not un-scheduling the agent, so the MASON schedule has the lone reference to your agent. I just modified the CampusWorld demo to have a single agent that's deleted after 200 steps, and that appears to work ok.
Essentially, in CampusWorld.java I added a Stoppable, used that when adding the single agent, and then added a new function, removeAgent(), to unschedule same and remove it from its field:
Stoppable agentStoppable; // Used to unschedule agent
* Add agents to the simulation and to the agent GeomVectorField. Note that
* each agent does not have any attributes.
for (int i = 0; i < numAgents; i++)
Agent a = new Agent(this);
// Remember the Stoppable here
agentStoppable = schedule.scheduleRepeating(a);
// first remove the agent from the scheduler
// then remove it from the field; there's only one agent, so just