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 TypeMethodDescriptionvoid
addAgent
(GraphAgent<?, ?> graphAgent) Adds the specified agent to this arc, e.g.void
addCallbackPosition
(GeometricGraphPosition<?, ?> position) Adds the specified callback position to this arc.void
afterAgentEntered
(GraphAgent<?, ?> graphAgent) Callback method called after an agent enters this arc.void
beforeAgentExited
(GraphAgent<?, ?> graphAgent) Callback method called before an agent exits this arc.void
Removes all callback positions from this arc, if any.boolean
containsAgent
(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, ornull
if this is a one-way arc.void
onAgentReachedPosition
(GraphAgent<?, ?> graphAgent, GeometricGraphPosition<?, ?> position) Callback method called when an agent reaches the specified callback position belonging to this arc.void
onAgentVelocityChanged
(GraphAgent<?, ?> graphAgent) Callback method called immediately after velocity of the specified agent located on this arc changes.void
recalculateAgents
(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.void
removeAgent
(GraphAgent<?, ?> graphAgent) Removes the specified agent from this arc, e.g.void
removeCallbackPosition
(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:GeometricGraphArc
Returns the arc that is a reverse to this one, ornull
if this is a one-way arc.- Specified by:
getReverseArc
in 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:
true
if the specified agent is currently on this arc,false
otherwise- See Also:
-
addCallbackPosition
Adds the specified callback position to this arc. The callback methodonAgentReachedPosition(GraphAgent, GeometricGraphPosition)
will be called every time anGraphAgent
reaches 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
-