Package com.amalgamasimulation.trains
Class RailArc
java.lang.Object
com.amalgamasimulation.graphagent.AgentGraphArcImpl
com.amalgamasimulation.graphagent.LongAgentGraphArcImpl
com.amalgamasimulation.trains.RailArc
- All Implemented Interfaces:
AgentGraphArc,GeometricGraphArc,LongAgentGraphArc
Rail arc is the element that is contained in arcs of railway graph. Rail arcs
contains polyline representing the trajectory which is used to move the trains.
- Author:
- Andrey Malykhanov, Amalgama LLC
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallbackPosition(GeometricGraphPosition<?, ?> position, BiConsumer<Train, Boolean> callback) getName()Returns the name of this arcgetTrack()Returns the track which this rail arc belongs to.booleanReturnstrueif this arc is the forward arc of the rail track it belongs to andfalseotherwise.voidonAgentReachedPosition(GraphAgent<?, ?> graphAgent, GeometricGraphPosition<?, ?> position) Callback method called when an agent reaches the specified callback position belonging to this arc.toString()Methods inherited from class com.amalgamasimulation.graphagent.LongAgentGraphArcImpl
addOccupyingAgent, getOccupyingAgents, getOccupyingAgents, getReverseLongAgentArc, removeAllOccurrencesOccupyingAgent, removeOccupyingAgent, setReverseArcMethods inherited from class com.amalgamasimulation.graphagent.AgentGraphArcImpl
addAgent, addCallbackPosition, afterAgentEntered, beforeAgentExited, clearCallbackPositions, containsAgent, getAgents, getCallbackPositions, getPolyline, getReverseArc, getReverseOffset, onAgentVelocityChanged, recalculateAgents, removeAgent, removeCallbackPosition, setPolylineMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.amalgamasimulation.graphagent.AgentGraphArc
addAgent, addCallbackPosition, afterAgentEntered, beforeAgentExited, clearCallbackPositions, containsAgent, getAgents, getCallbackPositions, getReverseArc, onAgentVelocityChanged, recalculateAgents, removeAgent, removeCallbackPositionMethods inherited from interface com.amalgamasimulation.graphagent.GeometricGraphArc
getLength, getPolyline, getReverseOffset
-
Field Details
-
name
-
track
-
isForward
protected boolean isForward -
callbacks
-
-
Constructor Details
-
RailArc
Creates a new instance of rail arc with the specified name and polyline.- Parameters:
name- the name of the arcpolyline- the polyline of the arc
-
-
Method Details
-
getTrack
Returns the track which this rail arc belongs to.- Returns:
- track which this rail arc belongs to
-
isForward
public boolean isForward()Returnstrueif this arc is the forward arc of the rail track it belongs to andfalseotherwise.- Returns:
trueif this arc is the forward arc of the rail track it belongs to andfalseotherwise
-
getName
Returns the name of this arc- Returns:
- name of this arc
-
addCallbackPosition
public void addCallbackPosition(GeometricGraphPosition<?, ?> position, BiConsumer<Train, Boolean> callback) -
onAgentReachedPosition
public void onAgentReachedPosition(GraphAgent<?, ?> graphAgent, GeometricGraphPosition<?, ?> position) Description copied from interface:AgentGraphArcCallback method called when an agent reaches the specified callback position belonging to this arc.- Specified by:
onAgentReachedPositionin interfaceAgentGraphArc- Overrides:
onAgentReachedPositionin classAgentGraphArcImpl- Parameters:
graphAgent- agent that have reached the specified callback positionposition- specified callback position
-
toString
- Overrides:
toStringin classAgentGraphArcImpl
-