E
- molecule agent classBoxEventListener
public final class MoleculeAgentManager<E> extends java.lang.Object implements BoxEventListener
Modifier and Type | Class | Description |
---|---|---|
static interface |
MoleculeAgentManager.MoleculeAgentSource<E> |
Interface for an object that wants an agent associated with each
IMolecule a Box.
|
Constructor | Description |
---|---|
MoleculeAgentManager(Simulation sim,
Box box,
MoleculeAgentManager.MoleculeAgentSource<E> source) |
|
MoleculeAgentManager(Simulation sim,
Box box,
java.util.function.Function<IMolecule,? extends E> agentSource) |
|
MoleculeAgentManager(Simulation sim,
Box box,
java.util.function.Function<IMolecule,? extends E> agentSource,
java.util.function.BiConsumer<? super E,IMolecule> onRelease) |
Modifier and Type | Method | Description |
---|---|---|
java.util.stream.Stream<E> |
agentStream() |
|
void |
boxMoleculeAdded(BoxMoleculeEvent e) |
Called when a molecule is added to the box.
|
void |
boxMoleculeIndexChanged(BoxMoleculeIndexEvent e) |
Called when an molecule's index has changed.
|
void |
boxMoleculeRemoved(BoxMoleculeEvent e) |
Called when a molecule is removed from the box.
|
void |
dispose() |
Notifies the AtomAgentManager it should disconnect itself as a listener.
|
E |
getAgent(IMolecule a) |
Returns the agent associated with the given IAtom.
|
java.util.Map<ISpecies,IndexMap<E>> |
getAgents() |
|
Box |
getBox() |
Convenience method to return the box the Manager is tracking.
|
void |
setAgent(IMolecule a,
E newAgent) |
Sets the agent associated with the given atom to be the given agent.
|
boxAtomLeafIndexChanged, boxGlobalAtomLeafIndexChanged, boxNumberMolecules
public MoleculeAgentManager(Simulation sim, Box box, MoleculeAgentManager.MoleculeAgentSource<E> source)
public MoleculeAgentManager(Simulation sim, Box box, java.util.function.Function<IMolecule,? extends E> agentSource)
public java.util.stream.Stream<E> agentStream()
public E getAgent(IMolecule a)
public void setAgent(IMolecule a, E newAgent)
public Box getBox()
public void dispose()
public void boxMoleculeAdded(BoxMoleculeEvent e)
BoxEventListener
boxMoleculeAdded
in interface BoxEventListener
e
- the event, which contains the added molecule and the box to
which it was added.public void boxMoleculeRemoved(BoxMoleculeEvent e)
BoxEventListener
boxMoleculeRemoved
in interface BoxEventListener
e
- the event, which contains the removed molecule and the box from
which it was removed.public void boxMoleculeIndexChanged(BoxMoleculeIndexEvent e)
BoxEventListener
boxMoleculeIndexChanged
in interface BoxEventListener
e
- the event, which contains the box, the molecule whose index
changed and the molecule's old index. The molecule's new index
can be obtained from the atom.