AnyLogic
Expand
Font size
  • java.lang.Object
    • com.anylogic.engine.LinkToAgentCollectionImpl<T,​A>
All Implemented Interfaces:
AbstractLinkToAgent<T,​A>, AgentDestroyListener, LinkToAgentAnimationSettings, LinkToAgentCollection<T,​A>, java.io.Serializable

public class LinkToAgentCollectionImpl<T extends Agent,​A extends Agent>
extends java.lang.Object
implements LinkToAgentCollection<T,​A>
See Also:
Serialized Form

Constructor Summary

Constructors 
LinkToAgentCollectionImpl​(A owner, LinkToAgentAnimationSettings commonAnimationSettings)  
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods 
boolean connectTo​(T a)
Creates a connection to a given other agent.
void copyFrom_xjal​(LinkToAgentAnimationSettings linkToAgentMyAnimationSettings)  
void deliver​(java.lang.Object msg, T dest)
Delivers a message to a given agent immediately during this method call.
void deliverToAllConnected​(java.lang.Object msg)
Delivers a message to all connected agents.
void deliverToRandomConnected​(java.lang.Object msg)
Delivers a message to a randomly chosen connected agent.
boolean disconnectFrom​(Agent a)
Disconnects this agent from another given agent.
void disconnectFromAll()
Disconnects the agent from all other agents.
void doConnect_xjal​(T a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
void doDisconnect_xjal​(T a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
double getArrowLocation()  
LineArrowStyle getArrowStyle()  
AbstractLinkToAgent<A,​T> getBidirectionalPeer_xjal​(T agent)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
T getConnectedAgent​(int index)
Returns the connected agent with a given index.
java.util.List<T> getConnections()
Returns a collection of agents connected to this agent (bi-directionally), or empty collection if there have not been any connections yet.
int getConnectionsNumber()
Returns the number of agents connected to this agent.
java.awt.Color getLineColor()  
LineStyle getLineStyle()  
double getLineWidth()  
LinkToAgentAnimationSettings getLinkToAgentCommonAnimationSettings()
Returns link animation settings shared by the all the agents having this link.
Changes to these settings apply to drawing of all links of this type
LinkToAgentAnimationSettings getLinkToAgentMyAnimationSettings()
Returns link animation settings for this particular agent.
Changes to these settings apply to drawing of this link only inside its agent
A getOwner()  
T getRandomConnectedAgent()
Returns the randomly chosen connected agent.
boolean isConnectedTo​(Agent a)
Tests if this agent is connected to a given other agent.
boolean isDeliverToAgent_xjal()
Override this function for agent links which should call agent's "On Receive" code (which is defined in a standard 'connections' link).
boolean isVisible()  
void onDestroy()
Discards the link and disconnects it if it is bidirectional.
void onDestroy​(Agent agent)  
void onReceive​(java.lang.Object msg, Agent sender)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Override for custom on receive action
void restoreConnections_xjal​(java.util.List<?> connections)  
void send​(java.lang.Object msg, T dest)
Sends a message to a given agent.
void sendToAllConnected​(java.lang.Object msg)
Sends a message to all connected agents.
void sendToRandomConnected​(java.lang.Object msg)
Sends a message to a randomly chosen connected agent.
void setArrowLocation​(double arrowLocation)  
void setArrowStyle​(LineArrowStyle arrowStyle)  
void setLineColor​(java.awt.Color lineColor)  
void setLineStyle​(LineStyle lineStyle)  
void setLineWidth​(double lineWidth)  
void setVisible​(boolean visible)  
int size()
Returns the number of agents connected to this agent.
The same as LinkToAgentCollection.getConnectionsNumber()
Modifier and Type Method Description

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.AbstractLinkToAgent

getLinkToAgentCommonAnimationSettings, getLinkToAgentMyAnimationSettings, isDeliverToAgent_xjal

Methods inherited from interface com.anylogic.engine.LinkToAgentCollection

disconnectByCondition

Constructor Detail

LinkToAgentCollectionImpl

public LinkToAgentCollectionImpl​(A owner,
                                 LinkToAgentAnimationSettings commonAnimationSettings)

Method Detail

restoreConnections_xjal

@AnyLogicInternalAPI
public void restoreConnections_xjal​(java.util.List<?> connections)

getConnections

public java.util.List<T> getConnections()
Description copied from interface: LinkToAgentCollection
Returns a collection of agents connected to this agent (bi-directionally), or empty collection if there have not been any connections yet. You should not modify this collection.
Specified by:
getConnections in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Returns:
collection of connected agents, may be empty

getConnectionsNumber

public int getConnectionsNumber()
Description copied from interface: LinkToAgentCollection
Returns the number of agents connected to this agent.
Specified by:
getConnectionsNumber in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Returns:
the number of agents connected to this agent

size

public int size()
Description copied from interface: LinkToAgentCollection
Returns the number of agents connected to this agent.
The same as LinkToAgentCollection.getConnectionsNumber()
Specified by:
size in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Returns:
the number of agents connected to this agent

getConnectedAgent

public T getConnectedAgent​(int index)
Description copied from interface: LinkToAgentCollection
Returns the connected agent with a given index.
Specified by:
getConnectedAgent in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
index - the index of connection
Returns:
the connected agent with a given index

getRandomConnectedAgent

public T getRandomConnectedAgent()
Description copied from interface: LinkToAgentCollection
Returns the randomly chosen connected agent.
Specified by:
getRandomConnectedAgent in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Returns:
the connected agent

doConnect_xjal

@AnyLogicInternalAPI
public void doConnect_xjal​(T a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Specified by:
doConnect_xjal in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>

doDisconnect_xjal

@AnyLogicInternalAPI
public void doDisconnect_xjal​(T a)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Specified by:
doDisconnect_xjal in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>

onReceive

@AnyLogicInternalCodegenAPI
public void onReceive​(java.lang.Object msg,
                      Agent sender)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Override for custom on receive action
Specified by:
onReceive in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>

connectTo

public boolean connectTo​(T a)
Description copied from interface: LinkToAgentCollection
Creates a connection to a given other agent. Raises error if you try to connect to itself. Does nothing and returns false if agents are already connected.
Specified by:
connectTo in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
a - another agent
Returns:
true if was not connected before, false if was already connected

isConnectedTo

public boolean isConnectedTo​(Agent a)
Description copied from interface: LinkToAgentCollection
Tests if this agent is connected to a given other agent.
Specified by:
isConnectedTo in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
a - another agent
Returns:
true if the agents are connected, false otherwise

disconnectFrom

public boolean disconnectFrom​(Agent a)
Description copied from interface: LinkToAgentCollection
Disconnects this agent from another given agent.
Specified by:
disconnectFrom in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
a - another agent
Returns:
true if the agents were connected, false otherwise

disconnectFromAll

public void disconnectFromAll()
Description copied from interface: LinkToAgentCollection
Disconnects the agent from all other agents.
Specified by:
disconnectFromAll in interface LinkToAgentCollection<T extends Agent,​A extends Agent>

send

public void send​(java.lang.Object msg,
                 T dest)
Description copied from interface: LinkToAgentCollection
Sends a message to a given agent. The message will be delivered during a separate event scheduled to occur in zero time after the current one. If you are OK with the message delivered immediately during this event, use LinkToAgentCollection.deliver(Object, Agent) method, which has better performance.
Specified by:
send in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
msg - a message
dest - the destination agent

sendToAllConnected

public void sendToAllConnected​(java.lang.Object msg)
Description copied from interface: LinkToAgentCollection
Sends a message to all connected agents. The message will be delivered during a separate event scheduled to occur in zero time after the current one. If you are OK with the message delivered immediately during this event, use LinkToAgentCollection.deliverToAllConnected(Object) method, which has better performance.
Specified by:
sendToAllConnected in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
msg - a message

sendToRandomConnected

public void sendToRandomConnected​(java.lang.Object msg)
Description copied from interface: LinkToAgentCollection
Sends a message to a randomly chosen connected agent. The message will be delivered during a separate event scheduled to occur in zero time after the current one. If you are OK with the message delivered immediately during this event, use LinkToAgentCollection.deliverToRandomConnected(Object) method, which has better performance.
Specified by:
sendToRandomConnected in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
msg - a message

deliver

public void deliver​(java.lang.Object msg,
                    T dest)
Description copied from interface: LinkToAgentCollection
Delivers a message to a given agent immediately during this method call. If you wish this to happen in a separate event, use LinkToAgentCollection.send(Object, Agent) method.
Specified by:
deliver in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
msg - a message
dest - the destination agent

deliverToAllConnected

public void deliverToAllConnected​(java.lang.Object msg)
Description copied from interface: LinkToAgentCollection
Delivers a message to all connected agents. If you wish this to happen in a separate event, use LinkToAgentCollection.sendToAllConnected(Object) method.
Specified by:
deliverToAllConnected in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
msg - the message

deliverToRandomConnected

public void deliverToRandomConnected​(java.lang.Object msg)
Description copied from interface: LinkToAgentCollection
Delivers a message to a randomly chosen connected agent. If you wish this to happen in a separate event, use LinkToAgentCollection.sendToRandomConnected(Object) method.
Specified by:
deliverToRandomConnected in interface LinkToAgentCollection<T extends Agent,​A extends Agent>
Parameters:
msg - a message

getBidirectionalPeer_xjal

@AnyLogicInternalCodegenAPI
public AbstractLinkToAgent<A,​T> getBidirectionalPeer_xjal​(T agent)
Description copied from interface: AbstractLinkToAgent
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. It is public due to technical reasons.
Specified by:
getBidirectionalPeer_xjal in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>

getOwner

public A getOwner()
Specified by:
getOwner in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>

onDestroy

@AnyLogicInternalCodegenAPI
public void onDestroy()
Description copied from interface: AbstractLinkToAgent
Discards the link and disconnects it if it is bidirectional. Must be called when the agent is destroyed.
Specified by:
onDestroy in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>

onDestroy

@AnyLogicInternalAPI
public void onDestroy​(Agent agent)
Specified by:
onDestroy in interface AgentDestroyListener

getLinkToAgentCommonAnimationSettings

public LinkToAgentAnimationSettings getLinkToAgentCommonAnimationSettings()
Description copied from interface: AbstractLinkToAgent
Returns link animation settings shared by the all the agents having this link.
Changes to these settings apply to drawing of all links of this type
Specified by:
getLinkToAgentCommonAnimationSettings in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>
Specified by:
getLinkToAgentCommonAnimationSettings in interface LinkToAgentAnimationSettings
Returns:
shared link animation settings

getLinkToAgentMyAnimationSettings

public LinkToAgentAnimationSettings getLinkToAgentMyAnimationSettings()
Description copied from interface: AbstractLinkToAgent
Returns link animation settings for this particular agent.
Changes to these settings apply to drawing of this link only inside its agent
Specified by:
getLinkToAgentMyAnimationSettings in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>
Returns:
link animation settings for this particular agent

isDeliverToAgent_xjal

@AnyLogicInternalCodegenAPI
public boolean isDeliverToAgent_xjal()
Override this function for agent links which should call agent's "On Receive" code (which is defined in a standard 'connections' link). Default implementation returns false
Specified by:
isDeliverToAgent_xjal in interface AbstractLinkToAgent<T extends Agent,​A extends Agent>
Returns:
call agent's "On Receive" code or not

isVisible

@AnyLogicInternalAPI
public boolean isVisible()
Specified by:
isVisible in interface LinkToAgentAnimationSettings

setVisible

@AnyLogicInternalAPI
public void setVisible​(boolean visible)
Specified by:
setVisible in interface LinkToAgentAnimationSettings

getLineColor

@AnyLogicInternalAPI
public java.awt.Color getLineColor()
Specified by:
getLineColor in interface LinkToAgentAnimationSettings

setLineColor

@AnyLogicInternalAPI
public void setLineColor​(java.awt.Color lineColor)
Specified by:
setLineColor in interface LinkToAgentAnimationSettings

getLineWidth

@AnyLogicInternalAPI
public double getLineWidth()
Specified by:
getLineWidth in interface LinkToAgentAnimationSettings

setLineWidth

@AnyLogicInternalAPI
public void setLineWidth​(double lineWidth)
Specified by:
setLineWidth in interface LinkToAgentAnimationSettings

getLineStyle

@AnyLogicInternalAPI
public LineStyle getLineStyle()
Specified by:
getLineStyle in interface LinkToAgentAnimationSettings

setLineStyle

@AnyLogicInternalAPI
public void setLineStyle​(LineStyle lineStyle)
Specified by:
setLineStyle in interface LinkToAgentAnimationSettings

getArrowStyle

@AnyLogicInternalAPI
public LineArrowStyle getArrowStyle()
Specified by:
getArrowStyle in interface LinkToAgentAnimationSettings

setArrowStyle

@AnyLogicInternalAPI
public void setArrowStyle​(LineArrowStyle arrowStyle)
Specified by:
setArrowStyle in interface LinkToAgentAnimationSettings

getArrowLocation

@AnyLogicInternalAPI
public double getArrowLocation()
Specified by:
getArrowLocation in interface LinkToAgentAnimationSettings

setArrowLocation

@AnyLogicInternalAPI
public void setArrowLocation​(double arrowLocation)
Specified by:
setArrowLocation in interface LinkToAgentAnimationSettings

copyFrom_xjal

@AnyLogicInternalAPI
public void copyFrom_xjal​(LinkToAgentAnimationSettings linkToAgentMyAnimationSettings)
Specified by:
copyFrom_xjal in interface LinkToAgentAnimationSettings
How can we improve this article?