Package org.opentrafficsim.core.network
Class OTSLink
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.core.network.OTSLink
-
- All Implemented Interfaces:
Serializable,Locatable,EventProducerInterface,Identifiable,Drawable,Link
- Direct Known Subclasses:
CapacityOTSLink
public class OTSLink extends EventProducer implements Link, Serializable, Locatable
A standard implementation of a link between two Nodes.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2020-05-14 13:12:03 +0200 (Thu, 14 May 2020) $, @version $Revision: 6470 $, by $Author: pknoppers $, initial version Aug 19, 2014
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Fields inherited from interface org.opentrafficsim.core.network.Link
GTU_ADD_EVENT, GTU_REMOVE_EVENT
-
-
Constructor Summary
Constructors Modifier Constructor Description OTSLink(Network network, String id, Node startNode, Node endNode, LinkType linkType, PolyLine3d designLine)Construct a new OTSLink and register it in a Network.protectedOTSLink(Network newNetwork, OTSLink link)Clone a link for a new Network.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddGTU(Gtu gtu)Deprecated.OTSLinkclone(OTSNetwork newNetwork)Clone this OTSLink for e.g., copying a network.booleanequals(Object obj)Bounds3dgetBounds()PolyLine3dgetDesignLine()LongitudinalDirectionalitygetDirectionality(GtuType gtuType)This method returns the directionality of the link for a GTU type.NodegetEndNode()intgetGTUCount()Deprecated.Set<Gtu>getGTUs()Deprecated.StringgetId()LengthgetLength()LinkTypegetLinkType()OrientedPoint3dgetLocation()NetworkgetNetwork()Return the network in which this link is registered.OTSSimulatorInterfacegetSimulator()SerializablegetSourceId()NodegetStartNode()inthashCode()voidremoveGTU(Gtu gtu)Deprecated.StringtoString()-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Constructor Detail
-
OTSLink
public OTSLink(Network network, String id, Node startNode, Node endNode, LinkType linkType, PolyLine3d designLine) throws NetworkException
Construct a new OTSLink and register it in a Network. TODO should this method verify that the designLine is credible?- Parameters:
network- Network; the network to which the Link belongsid- String; the link idstartNode- Node; the start NodeendNode- Node; the end NodelinkType- LinkType; the LinkType (stores compatibility with GTU types)designLine- PolyLine3d; the design line of the Link- Throws:
NetworkException- if link already exists in the network, or if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
OTSLink
protected OTSLink(Network newNetwork, OTSLink link) throws NetworkException
Clone a link for a new Network.- Parameters:
newNetwork- Network; the Network to which the clone will belonglink- OTSLink; the link to clone from- Throws:
NetworkException- if link already exists in newNetwork, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
-
Method Detail
-
getDirectionality
public final LongitudinalDirectionality getDirectionality(GtuType gtuType)
This method returns the directionality of the link for a GTU type. It might be that the link is FORWARD (from start node to end node) for the GTU type CAR, but BOTH for the GTU type BICYCLE (i.e., bicycles can also go from end node to start node). If there is no entry for the given GTU Type, the values of GTUType.ALL will be returned. If this entry is not present, LongitudinalDirectionality.NONE will be returned.- Specified by:
getDirectionalityin interfaceLink- Parameters:
gtuType- GtuType; the GTU type to request the directionality for- Returns:
- the longitudinal directionality of the link (FORWARD, BACKWARD, BOTH or NONE) for the given GTU type. NONE will be returned if no directionality is given.
-
addGTU
@Deprecated public final void addGTU(Gtu gtu)
Deprecated.Add a GTU to this link (e.g., for statistical purposes, or for a model on macro level). It is safe to add a GTU again. No warning or error will be given. The GTU_ADD_EVENT will only be fired when the GTU was not already on the link.
-
removeGTU
@Deprecated public final void removeGTU(Gtu gtu)
Deprecated.Remove a GTU from this link. It is safe to try to remove a GTU again. No warning or error will be given. The GTU_REMOVE_EVENT will only be fired when the GTU was on the link.
-
getGTUs
@Deprecated public final Set<Gtu> getGTUs()
Deprecated.Provide a safe copy of the set of GTUs.
-
getGTUCount
@Deprecated public final int getGTUCount()
Deprecated.Provide the number of GTUs on this link.- Specified by:
getGTUCountin interfaceLink- Returns:
- int; the number of GTUs on this link
-
getNetwork
public Network getNetwork()
Return the network in which this link is registered. Cannot be null.- Specified by:
getNetworkin interfaceLink- Returns:
- Network; the network in which this link is registered
-
getId
public final String getId()
- Specified by:
getIdin interfaceIdentifiable- Specified by:
getIdin interfaceLink- Returns:
- id.
-
getStartNode
public final Node getStartNode()
- Specified by:
getStartNodein interfaceLink- Returns:
- start node.
-
getEndNode
public final Node getEndNode()
- Specified by:
getEndNodein interfaceLink- Returns:
- end node.
-
getLinkType
public final LinkType getLinkType()
- Specified by:
getLinkTypein interfaceLink- Returns:
- the link type.
-
getDesignLine
public final PolyLine3d getDesignLine()
- Specified by:
getDesignLinein interfaceLink- Returns:
- the design line.
-
getSimulator
public final OTSSimulatorInterface getSimulator()
- Specified by:
getSimulatorin interfaceLink- Returns:
- the simulator.
-
getLength
public final Length getLength()
-
getLocation
public OrientedPoint3d getLocation()
- Specified by:
getLocationin interfaceLink- Specified by:
getLocationin interfaceLocatable
-
getBounds
public Bounds3d getBounds()
-
clone
public OTSLink clone(OTSNetwork newNetwork) throws NetworkException
Clone this OTSLink for e.g., copying a network.- Parameters:
newNetwork- OTSNetwork; the new network to which the clone belongs- Returns:
- a clone of this object
- Throws:
NetworkException- in case the cloning fails, a Link with the same name exists in newNetwork, etc.
-
getSourceId
public Serializable getSourceId()
- Specified by:
getSourceIdin interfaceEventProducerInterface- Specified by:
getSourceIdin classEventProducer
-
-