Class AgentGraphNodeImpl
java.lang.Object
com.amalgamasimulation.graphagent.AgentGraphNodeImpl
- All Implemented Interfaces:
AgentGraphNode,GeometricGraphNode
- Direct Known Subclasses:
LongAgentGraphNodeImpl
Simple implementation of
AgentGraphNode interface that is suitable in
most simple cases. Contains the generic implementations of all methods of
this interface.- Author:
- Andrey Malykhanov
-
Constructor Summary
ConstructorsConstructorDescriptionAgentGraphNodeImpl(Point point) Creates a new instance ofAgentGraphNodeImplwith the specifiedPoint. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAgent(GraphAgent graphAgent) Adds the specified agent to this node, e.g.voidaddCallbackPosition(GeometricGraphPosition position) Adds the specified callback position to this node.voidafterAgentEntered(GraphAgent graphAgent) Callback method called after an agent enters this node.voidbeforeAgentExited(GraphAgent graphAgent) Callback method called before an agent exits this node.voidRemoves all callback positions from this node.booleancontainsAgent(GraphAgent graphAgent) Checks whether the specified agent is at this node.Returns an unmodifiable list of agents that are currently at this node.Returns an unmodifiable list of all callback positions belonging to this node.getPoint()Returns thePointthat defines the geometric location of this node in a geometric graph.voidonAgentReachedPosition(GraphAgent graphAgent, GeometricGraphPosition position) Callback method called when an agent reaches a callback position belonging to this node.voidremoveAgent(GraphAgent graphAgent) Removes the specified agent from this node, e.g.voidremoveCallbackPosition(GeometricGraphPosition position) Removes the specified callback position previously added byAgentGraphNode.addCallbackPosition(GeometricGraphPosition)method, from this node.voidSets the specified point to this node.toString()
-
Constructor Details
-
AgentGraphNodeImpl
Creates a new instance ofAgentGraphNodeImplwith the specifiedPoint.- Parameters:
point- specified point
-
-
Method Details
-
addAgent
Description copied from interface:AgentGraphNodeAdds the specified agent to this node, e.g. when the agent enters this node or jumps to it.- Specified by:
addAgentin interfaceAgentGraphNode- Parameters:
graphAgent- agent being added
-
removeAgent
Description copied from interface:AgentGraphNodeRemoves the specified agent from this node, e.g. when the agent leaves this node or is completely removed from graph environment.- Specified by:
removeAgentin interfaceAgentGraphNode- Parameters:
graphAgent- agent being removed
-
getAgents
Description copied from interface:AgentGraphNodeReturns an unmodifiable list of agents that are currently at this node.- Specified by:
getAgentsin interfaceAgentGraphNode- Returns:
- unmodifiable list of agents that are currently at this node
-
containsAgent
Description copied from interface:AgentGraphNodeChecks whether the specified agent is at this node.- Specified by:
containsAgentin interfaceAgentGraphNode- Parameters:
graphAgent- specified agent- Returns:
trueif this agent is at this node,falseotherwise
-
getPoint
Description copied from interface:GeometricGraphNodeReturns thePointthat defines the geometric location of this node in a geometric graph.- Specified by:
getPointin interfaceGeometricGraphNode- Returns:
- a
Pointrepresenting this node's location in two-dimensional space
-
setPoint
Sets the specified point to this node. This is a mutating method that must be used with caution only for initialization purposes.- Parameters:
point- specified point
-
addCallbackPosition
Description copied from interface:AgentGraphNodeAdds the specified callback position to this node. AAgentGraphNode.onAgentReachedPosition(GraphAgent, GeometricGraphPosition)will be called every time an agent reaches this node.- Specified by:
addCallbackPositionin interfaceAgentGraphNode- Parameters:
position- specified callback position- See Also:
-
removeCallbackPosition
Description copied from interface:AgentGraphNodeRemoves the specified callback position previously added byAgentGraphNode.addCallbackPosition(GeometricGraphPosition)method, from this node. Does nothing if the specified callback position does not belong to this node.- Specified by:
removeCallbackPositionin interfaceAgentGraphNode- Parameters:
position- callback position being removed- See Also:
-
clearCallbackPositions
public void clearCallbackPositions()Description copied from interface:AgentGraphNodeRemoves all callback positions from this node.- Specified by:
clearCallbackPositionsin interfaceAgentGraphNode- See Also:
-
getCallbackPositions
Description copied from interface:AgentGraphNodeReturns an unmodifiable list of all callback positions belonging to this node.- Specified by:
getCallbackPositionsin interfaceAgentGraphNode- Returns:
- unmodifiable list of all callback positions belonging to this node
-
afterAgentEntered
Description copied from interface:AgentGraphNodeCallback method called after an agent enters this node.- Specified by:
afterAgentEnteredin interfaceAgentGraphNode- Parameters:
graphAgent- agent that have just entered this node
-
beforeAgentExited
Description copied from interface:AgentGraphNodeCallback method called before an agent exits this node.- Specified by:
beforeAgentExitedin interfaceAgentGraphNode- Parameters:
graphAgent- agent that is about to exit this node
-
onAgentReachedPosition
Description copied from interface:AgentGraphNodeCallback method called when an agent reaches a callback position belonging to this node.- Specified by:
onAgentReachedPositionin interfaceAgentGraphNode- Parameters:
graphAgent- agent that have reached the specified callback positionposition- the position that have been reached
-
toString
-