SimulationListenerpublic final class BoxAgentManager<E> extends java.lang.Object implements SimulationListener
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
BoxAgentManager.BoxAgentSource<E> |
Interface for an object that makes an agent to be associated with each box
upon construction.
|
| Constructor | Description |
|---|---|
BoxAgentManager(BoxAgentManager.BoxAgentSource<E> source,
Simulation sim) |
Constructs and sets the Simulation containing Boxes to be tracked.
|
BoxAgentManager(Simulation sim,
java.util.function.Function<Box,? extends E> source) |
|
BoxAgentManager(Simulation sim,
java.util.function.Function<Box,? extends E> source,
java.util.function.Consumer<? super E> releaser) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
dispose() |
Notifies the BoxAgentManager that it should release all agents and
stop listening for events from the simulation.
|
E |
getAgent(Box box) |
|
IndexMap<E> |
getAgents() |
|
void |
setAgent(Box box,
E agent) |
Associates an Agent with a Box.
|
void |
simulationBoxAdded(Simulation sim,
Box box) |
|
void |
simulationBoxRemoved(Simulation sim,
Box box) |
public BoxAgentManager(BoxAgentManager.BoxAgentSource<E> source, Simulation sim)
source - object that makes the agents.sim - the simulation using this BoxAgentManagerpublic BoxAgentManager(Simulation sim, java.util.function.Function<Box,? extends E> source)
public BoxAgentManager(Simulation sim, java.util.function.Function<Box,? extends E> source, java.util.function.Consumer<? super E> releaser)
public void setAgent(Box box, E agent)
box - the Boxagent - the Agentpublic void dispose()
public void simulationBoxAdded(Simulation sim, Box box)
simulationBoxAdded in interface SimulationListenerpublic void simulationBoxRemoved(Simulation sim, Box box)
simulationBoxRemoved in interface SimulationListener