Interface AgentGraphArc
- All Superinterfaces:
GeometricGraphArc
- All Known Subinterfaces:
LongAgentGraphArc
- All Known Implementing Classes:
AgentGraphArcImpl,LongAgentGraphArcImpl,RailArc
Interface to be implemented by all classes that can be values of graph arcs
of
GraphEnvironment.- Author:
- Andrey Malykhanov
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAgent(GraphAgent<?, ?> graphAgent) Adds the specified agent to this arc, e.g.voidaddCallbackPosition(GeometricGraphPosition<?, ?> position) Adds the specified callback position to this arc.voidafterAgentEntered(GraphAgent<?, ?> graphAgent) Callback method called after an agent enters this arc.voidbeforeAgentExited(GraphAgent<?, ?> graphAgent) Callback method called before an agent exits this arc.voidRemoves all callback positions from this arc, if any.booleancontainsAgent(GraphAgent<?, ?> graphAgent) Checks whether the specified agent is currently on this arc.List<GraphAgent<?, ?>> Returns an unmodifiable list of agents that are currently on this arc.List<GeometricGraphPosition<?, ?>> Returns an unmodifiable list of all callback positions belonging to this arc.Returns the arc that is a reverse to this one, ornullif this is a one-way arc.voidonAgentReachedPosition(GraphAgent<?, ?> graphAgent, GeometricGraphPosition<?, ?> position) Callback method called when an agent reaches the specified callback position belonging to this arc.voidonAgentVelocityChanged(GraphAgent<?, ?> graphAgent) Callback method called immediately after velocity of the specified agent located on this arc changes.voidrecalculateAgents(GraphAgent<?, ?> exceptAgent, boolean recalculateReverseArc) Recalculates the internal events (specifically, events of reaching other agents) for all agents on this arc, except for the specified one.voidremoveAgent(GraphAgent<?, ?> graphAgent) Removes the specified agent from this arc, e.g.voidremoveCallbackPosition(GeometricGraphPosition<?, ?> position) Removes the specified callback position previously added byaddCallbackPosition(GeometricGraphPosition)method from this arc.Methods inherited from interface com.amalgamasimulation.graphagent.GeometricGraphArc
getLength, getPolyline, getReverseOffset, setReverseArc
-
Method Details
-
getReverseArc
AgentGraphArc getReverseArc()Description copied from interface:GeometricGraphArcReturns the arc that is a reverse to this one, ornullif this is a one-way arc.- Specified by:
getReverseArcin interfaceGeometricGraphArc- Returns:
- reverse arc, or
null
-
addAgent
Adds the specified agent to this arc, e.g. when the agent enters this arc or jumps to it.- Parameters:
graphAgent- agent being added
-
removeAgent
Removes the specified agent from this arc, e.g. when the agent leaves this arc or is completely removed from graph environment.- Parameters:
graphAgent- agent being removed
-
onAgentVelocityChanged
Callback method called immediately after velocity of the specified agent located on this arc changes.- Parameters:
graphAgent- agent whose velocity has just been changed
-
recalculateAgents
Recalculates the internal events (specifically, events of reaching other agents) for all agents on this arc, except for the specified one.- Parameters:
exceptAgent- agent for which the recalculation is not performedrecalculateReverseArc- whether or not to recalculate agents on the reverse arc, if any
-
getAgents
List<GraphAgent<?,?>> getAgents()Returns an unmodifiable list of agents that are currently on this arc.- Returns:
- unmodifiable list of agents that are currently on this arc
-
containsAgent
Checks whether the specified agent is currently on this arc.- Parameters:
graphAgent- specified agent- Returns:
trueif the specified agent is currently on this arc,falseotherwise- See Also:
-
addCallbackPosition
Adds the specified callback position to this arc. The callback methodonAgentReachedPosition(GraphAgent, GeometricGraphPosition)will be called every time anGraphAgentreaches the specified position.- Parameters:
position- specified callback position- See Also:
-
removeCallbackPosition
Removes the specified callback position previously added byaddCallbackPosition(GeometricGraphPosition)method from this arc. Does nothing if there is no specified callback position on this arc.- Parameters:
position- specified callback position- See Also:
-
clearCallbackPositions
void clearCallbackPositions()Removes all callback positions from this arc, if any.- See Also:
-
getCallbackPositions
List<GeometricGraphPosition<?,?>> getCallbackPositions()Returns an unmodifiable list of all callback positions belonging to this arc.- Returns:
- unmodifiable list of all callback positions belonging to this arc
-
afterAgentEntered
Callback method called after an agent enters this arc.- Parameters:
graphAgent- agent that have just entered this arc- See Also:
-
beforeAgentExited
Callback method called before an agent exits this arc.- Parameters:
graphAgent- agent that is about to exit this arc- See Also:
-
onAgentReachedPosition
Callback method called when an agent reaches the specified callback position belonging to this arc.- Parameters:
graphAgent- agent that have reached the specified callback positionposition- specified callback position
-