Class LongAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
- Type Parameters:
N- type of values stored in graph nodesA- type of values stored in graph arcs
- Direct Known Subclasses:
Train
LongAgentsEnvironment. Long agent is modeled with two regular
GraphAgents:
- This agent (as a subclass of
GraphAgent) represents the location of the head of the long agent. - The other agent encapsulated inside this one represents the location of the tail of the long agent.
- Author:
- Andrey Malykhanov
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected GeometricGraphPath<N, A> protected Polylineprotected booleanprotected doubleprotected LongAgentsEnvironment<N, A, ?> protected LongAgentWeightKeyprotected doubleprotected doubleprotected booleanprotected LongAgentTail<N, A> Fields inherited from class com.amalgamasimulation.graphagent.GraphAgent
basis, engine, lastTrajectoryNodeIndex, lastTrajectoryPointIndex -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidafterEnteredArc(Graph<N, A>.Arc arc) Callback method called immediately after entering an arc.voidafterEnteredNode(Graph<N, A>.Node node) Callback method called immediately after entering a node.voidafterHeadEnteredArc(Graph<N, A>.Arc arc) Callback method called immediately after the head of this long agent enters an arc.voidafterHeadEnteredNode(Graph<N, A>.Node node) Callback method called immediately after the head of this long agent enters a node.booleanallowEnterArc(Graph<N, A>.Arc arc) Callback method used to implement advanced functionality like passby or waiting for something specific before entering arcs.voidbeforeExitedArc(Graph<N, A>.Arc arc) Callback method called before exiting entering an arc.voidbeforeExitedNode(Graph<N, A>.Node node) Callback method called before exiting a node.voidbeforeTailExitedArc(Graph<N, A>.Arc arc) Callback method called before the tail of this long agent exits an arc.voidbeforeTailExitedNode(Graph<N, A>.Node node) Callback method called before the tail of this long agent exits a node.voidStops this agent and forgets its moving path and target.protected voidprotected voidprotected voidprotected voidcheckNodeForOccupancy(Graph<N, A>.Node node) protected voidcheckPositionsInsideAgent(List<GeometricGraphPosition<N, A>> destPositions) protected voidprotected voidprotected voidprotected booleancomparePathsLessThan(AgentGraphPath<N, A> firstPath, AgentGraphPath<N, A> secondPath) protected AgentGraphPath<N, A> createPathForTailAgent(GraphPath<N, A> path, GeometricGraphPosition<N, A> destPosition, GeometricGraphPosition<N, A> actualDestPosition) protected voidenterArcFollowingAgent(LongAgent<N, A> newAheadAgent) protected voidenterNodeInternal(Graph<N, A>.Node node) protected voidprotected voidgetAdjacentAgents(Graph<N, A>.Node node) Returns list ofLongAgentwhich collided to this agent in the node and are waiting for it to free the node to continue moving.Returns aLongAgentthat is immediately ahead of this long agent, ornullif there is no such agent.Returns theGeometricGraphPaththat represents the projection of a long agent onto the graph.Returns aLongAgentthat is immediately behind this long agent, ornullif there is no such agent.Returns aPolylinerepresenting the current location of this long agent, ornullif this long agent is not in a graph.doubleReturns the non-negative absolute offset of tail position on arc where this tail is currently located, or-1if tail is not currently located on an arc.Returns aPointwhere the head of this long agent is currently located, ornullif this long agent is not in a graph.Returns aGeometricGraphPositionwhere the head of this long agent is currently located, ornullif this agent is not in a graph.Returns aPointwhere the tail of this long agent is currently located, ornullif this long agent is not in a graph.Returns aGeometricGraphPositionwhere the tail of this long agent is currently located, ornullif this agent is not in a graph.doubleReturns the length of this long agentReturnLongAgentWeightKeywhich is responsible for calculating the weight of arcsReturns the unmodifiable list of arcs currently occupied by this long agent.Returns the unmodifiable list of nodes currently occupied by this long agent.getPositionInsideAgent(List<GeometricGraphPosition<N, A>> destPositions) Returns theGeometricGraphPaththat represents the projection of a long agent onto the graph.protected AgentGraphPath<N, A> getShortestHeadTailPath(Function<GeometricGraphPosition<N, A>, AgentGraphPath<N, A>> pathFunction) protected AgentGraphPath<N, A> getShortestPath(GeometricGraphPosition<N, A> destPosition) protected AgentGraphPath<N, A> protected AgentGraphPath<N, A> getShortestPathToClosest(List<GeometricGraphPosition<N, A>> destPositions) protected booleanbooleanReturnstrueif there is another long agent that is immediately ahead of this long agent and is moving in same direction, or further movement will not have to a non-zero overlay, orfalseotherwise.protected booleanisOtherAgentInNodeHavingSameDirection(GraphAgent<?, ?> otherAgent) booleanReturn the possibility of finding the shortest path from the tail of the agent (defaulttrue).protected booleanisPossibleToStartMoving(double velocity) Jumps this agent to the specified absolute offset of the specified arc of graph of this agent'sGraphEnvironment.voidJumps this agent to the specified arc at the specified absolute offset and places it on the specified list of previous arcs.protected voidjumpTo(Graph<N, A>.Arc arc, double arcAbsOffset, List<Graph<N, A>.Arc> previousArcs, boolean isFirsNodeIncluded, boolean isLastNodeIncluded) Jumps this agent to the specified node of graph of this agent'sGraphEnvironment.jumpTo(GeometricGraphPosition<N, A> position) Jumps this agent to the specified position.voidJumps this agent to the specified position and places it on the specified list of previous arcs.Jumps this agent to the node having the specified value.protected voidprotected voidjumpToSeveralArcs(Graph<N, A>.Arc arc, double arcAbsOffset, List<Graph<N, A>.Arc> previousArcs, boolean isFirsNodeIncluded, boolean isLastNodeIncluded) moveAlongPath(AgentGraphPath<N, A> path, double velocity) Starts moving this agent to the specified node in the graph with the specified velocity along the shortest path from agent's current position.moveTo(GeometricGraphPosition<N, A> destPosition, double velocity) Starts moving this agent to the specified destination position in the graph with the specified velocity along the shortest path from agent's current position.Starts movement of the agent from the current position (node or arc) to the specified graph node along the shortest path.Starts moving this agent to the node in the graph having the specified value with the specified velocity along the shortest path from agent's current position.moveToClosest(List<GeometricGraphPosition<N, A>> destPositions, double velocity) Starts moving this agent to the closest one of the specified destination positions in the graph with the specified velocity along the shortest path from this agent's current position.protected voidvoidonCollidedWithOtherAgent(GraphAgent<N, A> otherAgent, boolean isMovingInSameDirection) Callback method called when this agent сollides another agent and further movement will have to a non-zero overlay, i.e.voidonDestinationReached(GeometricGraphPosition<N, A> destPosition) Callback method called after this agent reaches its destination, i.e.voidonOtherAgentReached(GraphAgent<N, A> otherAgent, boolean isMovingInSameDirection) Callback method called when this agent reaches another agent, i.e.protected voidvoidremoveAdjacentAgent(LongAgent<N, A> agent) Remove specifiedLongAgentfrom all adjacent agents collections.protected voidvoidremoveNodeAdjacentAgents(Graph<N, A>.Node node) Clear adjacent agents collection in specified node and try to continue movement of adjacent agents.protected voidsetAheadAgent(LongAgent<N, A> newAheadAgent) protected voidsetBehindAgent(LongAgent<N, A> behindAgent) protected voidsetCurrentPathInternal(AgentGraphPath<N, A> path) voidsetGraphEnvironment(GraphEnvironment<N, A, ?> graphEnvironment) Sets theGraphEnvironmentto this agent.voidsetGraphEnvironment(LongAgentsEnvironment<N, A, ?> graphEnvironment, double length) Assigns this long agent to the specifiedLongAgentsEnvironmentand specifies its length.voidsetLongAgentWeightKey(LongAgentWeightKey longAgentWeightKey) Set specifiedLongAgentWeightKeywhich is responsible for calculating the weight of arcsvoidsetPossibleStartMoveFromTail(boolean isPossibleStartMoveFromTail) Set the possibility of finding the shortest path from the tail of the agent.voidsetVelocity(double newVelocity) Sets the new velocity to this agent.protected voidsetVelocityInternal(double newVelocity) protected voidstartMovingAlongPath(double velocity) voidTurns this long agent around, i.e.protected voidMethods inherited from class com.amalgamasimulation.graphagent.GraphAgent
addCallbackPosition, cancelMovingInternal, checkEvents, clearCallbackPositions, disableCommandsExecution, enableCommandsExecution, engine, enterArcInternal, enterSegment, getCurrentAnimationArcAbsOffset, getCurrentAnimationHeading, getCurrentAnimationPoint, getCurrentAnimationTrajectoryAbsoluteOffset, getCurrentArc, getCurrentArcAbsOffset, getCurrentNode, getCurrentPoint, getCurrentPosition, getDistanceTraveled, getGraphEnvironment, getGraphPath, getHeading, getName, getTrajectory, getVelocity, hasGraphEnvironment, hasPath, isAtNode, isInGraph, isMoving, isOnArc, jumpToInternal, jumpToInternal, leaveCurrentArcInternal, leaveCurrentNodeInternal, moveToClosestInternal, moveToIndicatorInternal, moveToInternal, onCallbackPositionReached, onPathNotFound, onSegmentExited, removeCallbackPosition, removeFromGraphEnvironment, resetDistanceTraveled, time, tryExecuteCommand, tryUpdateDistanceTraveled, tryUpdatePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.utils.time.Timeable
dateToTime, dateToTime, day, duration, hour, minute, second, timeToDate, week, wholeDays, wholeDays, wholeHours, wholeHours, wholeUnits
-
Field Details
-
length
protected double length -
tail
-
ownVelocity
protected double ownVelocity -
aheadAgent
-
behindAgent
-
adjacentAgents
protected Map<Graph<N extends LongAgentGraphNode,A extends LongAgentGraphArc>.Node, adjacentAgentsList<LongAgent<N extends LongAgentGraphNode, A extends LongAgentGraphArc>>> -
aheadAgentNotBlockingPath
protected boolean aheadAgentNotBlockingPath -
animationPolyline
-
longAgentsEnvironment
protected LongAgentsEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc, longAgentsEnvironment?> -
occupiedArcs
-
occupiedNodes
-
shouldTurnAroundBeforeMovement
protected boolean shouldTurnAroundBeforeMovement -
isPossibleStartMoveFromTail
protected boolean isPossibleStartMoveFromTail -
longAgentWeightKey
-
animatedSelfPath
protected GeometricGraphPath<N extends LongAgentGraphNode,A extends LongAgentGraphArc> animatedSelfPath -
selfPathLastUpdateTime
protected double selfPathLastUpdateTime
-
-
Constructor Details
-
LongAgent
- Parameters:
engine- specified engine
-
-
Method Details
-
setCurrentPathInternal
- Overrides:
setCurrentPathInternalin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
setGraphEnvironment
Assigns this long agent to the specifiedLongAgentsEnvironmentand specifies its length.- Parameters:
graphEnvironment-LongAgentsEnvironmentthat this long agent is assigned tolength- length of this agent
-
setVelocityInternal
protected void setVelocityInternal(double newVelocity) - Overrides:
setVelocityInternalin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
onOtherAgentReached
Description copied from class:GraphAgentCallback method called when this agent reaches another agent, i.e. graph positions of this agent and the other agent become either equal or reverse. To be overridden in subclasses.- Overrides:
onOtherAgentReachedin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
otherAgent- another agentisMovingInSameDirection-trueif both agents are moving in the same direction, falseotherwise
-
getLength
public double getLength()Returns the length of this long agent- Returns:
- length of this long agent
-
onCollidedWithOtherAgent
Callback method called when this agent сollides another agent and further movement will have to a non-zero overlay, i.e. graph positions of this agent and the other agent become either equal or reverse. To be overridden in subclasses.- Parameters:
otherAgent- another agentisMovingInSameDirection-trueif both agents are moving in the same direction, falseotherwise
-
turnAround
public void turnAround()Turns this long agent around, i.e. swaps its head and tail. Occupied arcs and nodes are changed accordingly.If this long agent is at least partially located on a monodirectional graph arc, a
RuntimeExceptionis thrown. -
setVelocity
public void setVelocity(double newVelocity) Description copied from class:GraphAgentSets the new velocity to this agent. If this agent is moving and the specified new velocity does not equal to agent's current velocity, this agent's velocity gets changed immediately.Positive velocity can only be set if this agent has its path (i.e.
). Otherwise, aGraphAgent.hasPath()== trueRuntimeExceptionis thrownNegative and infinite velocities are not allowed. If such value is passed, a
RuntimeExceptionis thrown- Overrides:
setVelocityin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
newVelocity- - specified velocity- See Also:
-
cancelMoving
public void cancelMoving()Description copied from class:GraphAgentStops this agent and forgets its moving path and target. More specifically:- If this agent is moving, stops moving
- If this agent has a path (even if this agent is not moving), erases this path, sets the path to
null- If this agent does not have a path, does nothing
- Overrides:
cancelMovingin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - See Also:
-
moveTo
Description copied from class:GraphAgentStarts moving this agent to the specified destination position in the graph with the specified velocity along the shortest path from agent's current position.The shortest path is calculated with respect to weights of arcs and nodes set in agent's
GraphEnvironment.If this agent is currently moving somewhere else, it forgets its current destination and is assigned a new path.
If zero velocity is specified, the path is set to this agent, but it just does not start moving. It can start moving when
GraphAgent.setVelocity(double)is called with a positive value.If no path is found from agent's current position to the specified position,
GraphAgent.onPathNotFound(List)method is called. The default implementation of this method throws aRuntimeException, but it can be overridden in subclasses.If this agent is not in graph or has not been assigned to a
GraphEnvironment, aRuntimeExceptionis thrown.- Overrides:
moveToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
destPosition- specified destination position in the graph of this agent'sGraphEnvironmentvelocity- specified velocity. Must be finite and non-negative- See Also:
-
moveToClosest
public CompletionStage<Void> moveToClosest(List<GeometricGraphPosition<N, A>> destPositions, double velocity) Description copied from class:GraphAgentStarts moving this agent to the closest one of the specified destination positions in the graph with the specified velocity along the shortest path from this agent's current position.Closeness and shortest path are determined with respect to weights of arcs and nodes set in agent's
GraphEnvironment.If this agent is currently moving somewhere else, it forgets its current destination and is assigned a new path.
If zero velocity is specified, the path is set to this agent, but it just does not start moving. It can start moving when
GraphAgent.setVelocity(double)is called with a positive value.If no path is found from agent's current position to either of the specified positions,
GraphAgent.onPathNotFound(List)method is called. The default implementation of this method throws aRuntimeException, but it can be overridden in subclasses.If this agent is not in graph or has not been assigned to a
GraphEnvironment, aRuntimeExceptionis thrown.- Overrides:
moveToClosestin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
destPositions- list of destination positions in the graph of this agent'sGraphEnvironment, from which the closest one is selectedvelocity- specified velocity. Must be finite and non-negative- See Also:
-
moveTo
Description copied from class:GraphAgentStarts moving this agent to the node in the graph having the specified value with the specified velocity along the shortest path from agent's current position.The shortest path is calculated with respect to weights of arcs and nodes set in agent's
GraphEnvironment.If this agent is currently moving somewhere else, it forgets its current destination and is assigned a new path.
If zero velocity is specified, the path is set to this agent, but it just does not start moving. It can start moving when
GraphAgent.setVelocity(double)is called with a positive value.If no path is found from agent's current position to the specified node,
GraphAgent.onPathNotFound(List<GeometricGraphPosition<N, A>>)method is called. The default implementation of this method throws aRuntimeException, but it can be overridden in subclasses.If this agent is not in graph or has not been assigned to a
GraphEnvironment, aRuntimeExceptionis thrown.- Overrides:
moveToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
nodeValue- value of the node in the graph of this agent'sGraphEnvironmentwhich this agent will be sent tovelocity- specified velocity. Must be finite and non-negative- See Also:
-
moveTo
Description copied from class:GraphAgentStarts movement of the agent from the current position (node or arc) to the specified graph node along the shortest path.
If no path exists between agent's current position (node or arc) to the specified node, function does nothing.
If agent already is in the specified node, function does nothing.
- Overrides:
moveToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
indicator- thePredicatewhich must returntrueto indicate that a node is a valid destination
-
moveTo
Description copied from class:GraphAgentStarts moving this agent to the specified node in the graph with the specified velocity along the shortest path from agent's current position.The shortest path is calculated with respect to weights of arcs and nodes set in agent's
GraphEnvironment.If this agent is currently moving somewhere else, it forgets its current destination and is assigned a new path.
If zero velocity is specified, the path is set to this agent, but it just does not start moving. It can start moving when
GraphAgent.setVelocity(double)is called with a positive value.If no path is found from agent's current position to the specified node,
GraphAgent.onPathNotFound(List)method is called. The default implementation of this method throws aRuntimeException, but it can be overridden in subclasses.If this agent is not in graph or has not been assigned to a
GraphEnvironment, aRuntimeExceptionis thrown.- Overrides:
moveToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
node- node in the graph of this agent'sGraphEnvironmentwhich this agent will be sent tovelocity- specified velocity. Must be finite and non-negative- See Also:
-
getShortestPathToClosest
protected AgentGraphPath<N,A> getShortestPathToClosest(List<GeometricGraphPosition<N, A>> destPositions) - Overrides:
getShortestPathToClosestin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
getShortestPath
- Overrides:
getShortestPathin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
getShortestPath
- Overrides:
getShortestPathin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
getShortestHeadTailPath
protected AgentGraphPath<N,A> getShortestHeadTailPath(Function<GeometricGraphPosition<N, A>, AgentGraphPath<N, A>> pathFunction) -
enterNodeInternal
- Overrides:
enterNodeInternalin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
checkNodeForOccupancy
-
checkArcPositionForOccupancy
protected void checkArcPositionForOccupancy() -
isOtherAgentInNodeHavingSameDirection
- Overrides:
isOtherAgentInNodeHavingSameDirectionin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
getNextPathArc
-
checkPositionsInsideAgent
-
getPositionInsideAgent
public List<GeometricGraphPosition<N,A>> getPositionInsideAgent(List<GeometricGraphPosition<N, A>> destPositions) -
comparePathsLessThan
protected boolean comparePathsLessThan(AgentGraphPath<N, A> firstPath, AgentGraphPath<N, A> secondPath) -
onAheadAgentVelocityChanged
protected void onAheadAgentVelocityChanged() -
setBehindAgent
-
addAdjacentAgent
-
removeNodeAdjacentAgents
Clear adjacent agents collection in specified node and try to continue movement of adjacent agents.- Parameters:
node- specified node- See Also:
-
removeAdjacentAgent
Remove specifiedLongAgentfrom all adjacent agents collections.- Parameters:
agent- specified agent- See Also:
-
getAdjacentAgents
Returns list ofLongAgentwhich collided to this agent in the node and are waiting for it to free the node to continue moving.- Parameters:
node- specified node- Returns:
- list of
LongAgentwhich collided to this agent in the node and are waiting for it to free the node to continue moving
-
getCurrentHeadPosition
Returns aGeometricGraphPositionwhere the head of this long agent is currently located, ornullif this agent is not in a graph.- Returns:
GeometricGraphPositionwhere the head of this long agent is currently located, ornull- See Also:
-
getCurrentTailPosition
Returns aGeometricGraphPositionwhere the tail of this long agent is currently located, ornullif this agent is not in a graph.- Returns:
GeometricGraphPositionwhere the tail of this long agent is currently located, ornull- See Also:
-
getCurrentHeadAnimationPoint
Returns aPointwhere the head of this long agent is currently located, ornullif this long agent is not in a graph.The result of this method is equal to the result of
GraphAgent.getCurrentAnimationPoint()method.- Returns:
Pointwhere the head of this long agent is currently located, ornull- See Also:
-
getCurrentTailAnimationPoint
Returns aPointwhere the tail of this long agent is currently located, ornullif this long agent is not in a graph.- Returns:
Pointwhere the tail of this long agent is currently located, ornull- See Also:
-
getCurrentAnimationPolyline
Returns aPolylinerepresenting the current location of this long agent, ornullif this long agent is not in a graph.- Returns:
Polylinerepresenting the current location of this long agent, ornull- See Also:
-
getAheadAgent
Returns aLongAgentthat is immediately ahead of this long agent, ornullif there is no such agent.Another agent is considered immediately behind ahead of this one if:
- this agent moves in the same direction and head of this agent is at the same position as other agent's tail, or
- another agent moves in the opposite direction along a bidirectional arc
and heads of both agents are at the adjacent positions (see
GeometricGraphPosition.equalsOrAdjacent(GeometricGraphPosition, Graph)).
- Returns:
LongAgentthat is immediately ahead of this long agent, ornull- See Also:
-
isAheadAgentNotBlockingPath
public boolean isAheadAgentNotBlockingPath()Returnstrueif there is another long agent that is immediately ahead of this long agent and is moving in same direction, or further movement will not have to a non-zero overlay, orfalseotherwise.- Returns:
trueif there is another long agent that is immediately ahead of this long agent and is moving in same direction, or further movement will not have to a non-zero overlay, orfalseotherwise- See Also:
-
getBehindAgent
Returns aLongAgentthat is immediately behind this long agent, ornullif there is no such agent.Another agent is considered immediately behind this one if it moves in the same direction and its head is at the same position as this agent's tail.
- Returns:
LongAgentthat is immediately behind this long agent, ornull- See Also:
-
eraseCurrentPathInternal
protected void eraseCurrentPathInternal()- Overrides:
eraseCurrentPathInternalin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
createPathForTailAgent
protected AgentGraphPath<N,A> createPathForTailAgent(GraphPath<N, A> path, GeometricGraphPosition<N, A> destPosition, GeometricGraphPosition<N, A> actualDestPosition) -
jumpTo
Description copied from class:GraphAgentJumps this agent to the specified position. If this agent is moving or has a path, cancels its movement and forgets its path before jumping.- Overrides:
jumpToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
position- position in the graph of this agent'sGraphEnvironmentwhere this agent will be placed
-
jumpTo
Description copied from class:GraphAgentJumps this agent to the specified node of graph of this agent'sGraphEnvironment. If this agent is moving or has a path, cancels its movement and forgets its path before jumping.- Overrides:
jumpToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
node- node of the graph of this agent'sGraphEnvironmentwhere this agent will be placed
-
jumpTo
Description copied from class:GraphAgentJumps this agent to the specified absolute offset of the specified arc of graph of this agent'sGraphEnvironment. If this agent is moving or has a path, cancels its movement and forgets its path before jumping.- Overrides:
jumpToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
arc- arc of the graph of this agent'sGraphEnvironmentwhere this agent will be placedarcAbsOffset- absolute offset of the specified arc where this agent will be placed
-
jumpTo
Description copied from class:GraphAgentJumps this agent to the node having the specified value. If this agent is moving or has a path, cancels its movement and forgets its path before jumping.- Overrides:
jumpToin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
nodeValue- value of the node in the graph of this agent'sGraphEnvironmentwhere this agent will be placed
-
startMovingAlongPath
protected void startMovingAlongPath(double velocity) - Overrides:
startMovingAlongPathin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
setGraphEnvironment
Description copied from class:GraphAgentSets theGraphEnvironmentto this agent. This agent starts to live in the specified graph environment after this call. If this agent has been assigned to some other graph environment, removes it from that graph environment before placing into the specified one.- Overrides:
setGraphEnvironmentin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
graphEnvironment- graph environment to be set to this agent
-
allowEnterArc
Description copied from class:GraphAgentCallback method used to implement advanced functionality like passby or waiting for something specific before entering arcs. The basic implementation is always to returntrue. To be overridden in subclasses.- Overrides:
allowEnterArcin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
arc- arc that this agent attempts to enter- Returns:
trueif this agent should be allowed to enter the specified arc,falseotherwise
-
isPossibleToStartMoving
protected boolean isPossibleToStartMoving(double velocity) - Overrides:
isPossibleToStartMovingin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
isAheadAgentBlockingMovement
protected boolean isAheadAgentBlockingMovement() -
beforeTailExitedArc
Callback method called before the tail of this long agent exits an arc. To be overridden in subclasses. The tail of this long agent is still in the specified arc when this method is called.- Parameters:
arc- arc being exited by the tail of this long agent
-
afterHeadEnteredArc
Callback method called immediately after the head of this long agent enters an arc. To be overridden in subclasses. The head of this long agent is already on the specified arc when this method is called.- Parameters:
arc- arc being entered by the head of this long agent
-
afterHeadEnteredNode
Callback method called immediately after the head of this long agent enters a node. To be overridden in subclasses. The head of this long agent is already in the specified node when this method is called.- Parameters:
node- node being entered by the head of this long agent
-
beforeTailExitedNode
Callback method called before the tail of this long agent exits a node. To be overridden in subclasses. The tail of this long agent is still in the specified node when this method is called- Parameters:
node- node being exited by the tail of this long agent
-
afterEnteredNode
Description copied from class:GraphAgentCallback method called immediately after entering a node. To be overridden in subclasses. This agent is already in the specified node when this method is called- Overrides:
afterEnteredNodein classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
node- node being entered- See Also:
-
beforeExitedNode
Description copied from class:GraphAgentCallback method called before exiting a node. To be overridden in subclasses. This agent is still in the specified node when this method is called- Overrides:
beforeExitedNodein classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
node- node being exited- See Also:
-
afterEnteredArc
Description copied from class:GraphAgentCallback method called immediately after entering an arc. To be overridden in subclasses. This agent is already on the specified arc when this method is calledEvent of entering an arc can happen in 3 cases:
- in process of moving
- after jumping to a position on the specified arc
- after turning to opposite arc
- Overrides:
afterEnteredArcin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
arc- arc being entered- See Also:
-
onDestinationReached
Description copied from class:GraphAgentCallback method called after this agent reaches its destination, i.e. the final position of its path. The destination is determined as final position of any movement initiated by any overload ofmoveToormoveToClosestmethod.Note that
jumpTomethods do not initiate movements and thus do not lead to calling this callback.- Overrides:
onDestinationReachedin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
destPosition- the position that has been reached- See Also:
-
enterArcFollowingAgent
-
getOccupiedArcs
Returns the unmodifiable list of arcs currently occupied by this long agent. Arcs are ordered from head to tail of this long agent. Both fully and partially occupied arcs are included into the list.- Returns:
- list of arcs currently occupied by this long agent
-
getOccupiedNodes
Returns the unmodifiable list of nodes currently occupied by this long agent. Nodes are ordered from head to tail of this long agent.- Returns:
- list of nodes currently occupied by this long agent
-
beforeExitedArc
Description copied from class:GraphAgentCallback method called before exiting entering an arc. To be overridden in subclasses. This agent is still on the specified arc when this method is calledEvent of exiting an arc can happen in 3 cases:
- in process of moving
- before jumping from current position on an arc
- before turning to opposite arc
- Overrides:
beforeExitedArcin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc> - Parameters:
arc- arc being exited- See Also:
-
turnAroundInternal
protected void turnAroundInternal() -
moveAlongPath
- Overrides:
moveAlongPathin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
removeFromGraphInternal
protected void removeFromGraphInternal()- Overrides:
removeFromGraphInternalin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
recalculateCollisions
protected void recalculateCollisions() -
clearInternalCollections
protected void clearInternalCollections() -
jumpTo
Jumps this agent to the specified arc at the specified absolute offset and places it on the specified list of previous arcs. If this agent is moving or has a path, cancels its movement and forgets its path before jumping.- Parameters:
arc- specified arcarcAbsOffset- absolute offset on the specified arcpreviousArcs- list of arcs where to place this long agent
-
jumpTo
-
jumpToSeveralArcs
-
fillOccupiedCollectionAfterSeveralArcsJumping
protected void fillOccupiedCollectionAfterSeveralArcsJumping() -
checkArcsBeforeJumping
-
checkArcsOrder
-
checkReverseArcs
-
checkSelfOverlay
-
jumpToPathDestPosition
protected void jumpToPathDestPosition()- Overrides:
jumpToPathDestPositionin classGraphAgent<N extends LongAgentGraphNode,A extends LongAgentGraphArc>
-
jumpTo
Jumps this agent to the specified position and places it on the specified list of previous arcs. If this agent is moving or has a path, cancels its movement and forgets its path before jumping.- Parameters:
position- position where this agent is jumpedpreviousArcs- list of arcs where to place this long agent
-
setAheadAgent
-
isPossibleStartMoveFromTail
public boolean isPossibleStartMoveFromTail()Return the possibility of finding the shortest path from the tail of the agent (defaulttrue).- Returns:
- the possibility of finding the shortest path from the tail of the
agent (default
true)
-
setPossibleStartMoveFromTail
public void setPossibleStartMoveFromTail(boolean isPossibleStartMoveFromTail) Set the possibility of finding the shortest path from the tail of the agent.- Parameters:
isPossibleStartMoveFromTail- possibility of finding the shortest path from the tail of the agent (defaulttrue)
-
getLongAgentWeightKey
ReturnLongAgentWeightKeywhich is responsible for calculating the weight of arcs- Returns:
LongAgentWeightKeywhich is responsible for calculating the weight of arcs
-
setLongAgentWeightKey
Set specifiedLongAgentWeightKeywhich is responsible for calculating the weight of arcs- Parameters:
longAgentWeightKey-LongAgentWeightKeywhich is responsible for calculating the weight of arcs
-
getCurrentAnimationTailArcAbsOffset
public double getCurrentAnimationTailArcAbsOffset()Returns the non-negative absolute offset of tail position on arc where this tail is currently located, or-1if tail is not currently located on an arc.- Returns:
- absolute offset of position on arc where tail is currently located,
or
-1 - See Also:
-
getAnimationSelfPath
Returns theGeometricGraphPaththat represents the projection of a long agent onto the graph. This method should be called from animation when it is needed to determine where to show this agent. CallinggetSelfPath()from animation might result in non-reproducibility of the model.- Returns:
- Returns the @GeometricGraphPath that represents the projection of a long agent onto the graph.
-
getSelfPath
Returns theGeometricGraphPaththat represents the projection of a long agent onto the graph. This method must not be called from animation. CallinggetSelfPath()from animation might result in non-reproducibility of the model.getAnimationSelfPath()should be called from animation instead of this.- Returns:
- Returns the @GeometricGraphPath that represents the projection of a long agent onto the graph.
-