Class AbstractLaneBasedObject
java.lang.Object
org.djutils.event.EventProducer
org.opentrafficsim.core.object.StaticObject
org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
- All Implemented Interfaces:
java.io.Serializable
,Locatable
,EventProducerInterface
,Identifiable
,Drawable
,ObjectInterface
,LaneBasedObject
- Direct Known Subclasses:
AbstractSensor
,AbstractTrafficLight
,BusStop
,Conflict
,Conflict.ConflictEnd
,Distraction
,SpeedSign
public abstract class AbstractLaneBasedObject extends StaticObject implements LaneBasedObject
An abstract implementation of the LaneBasedObject interface with the required fields being initialized and getters for those
fields. All StaticObjects are EventProducers, allowing them to provide state changes to subscribers.
Note that extending classes must use a create(...) factory method that calls init() after fully constructing the object to avoid "half constructed" objects to be registered in the network.
Note that extending classes must use a create(...) factory method that calls init() after fully constructing the object to avoid "half constructed" objects to be registered in the network.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLaneBasedObject(java.lang.String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry)
Construct a new LaneBasedObject with the required fields.protected
AbstractLaneBasedObject(java.lang.String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry, Length height)
Construct a new AbstractLanebasedObject with the required fields.protected
AbstractLaneBasedObject(java.lang.String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry)
Construct a new LaneBasedObject with the required fields.protected
AbstractLaneBasedObject(java.lang.String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry, Length height)
Construct a new AbstractLanebasedObject with the required fields. -
Method Summary
Modifier and Type Method Description StaticObject
clone(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator, boolean animation)
abstract AbstractLaneBasedObject
clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator)
Clone the LaneBasedObject for e.g., copying a network.LongitudinalDirectionality
getDirection()
java.lang.String
getFullId()
Lane
getLane()
DirectedPoint
getLocation()
Return the location without throwing a RemoteException.Length
getLongitudinalPosition()
protected void
init()
java.lang.String
toString()
Methods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getBounds, getGeometry, getHeight, getId, getSourceId
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, getSourceId, hasListeners, numberOfListeners, removeListener
Methods inherited from interface org.opentrafficsim.road.network.lane.object.LaneBasedObject
getBounds
Methods inherited from interface org.opentrafficsim.core.object.ObjectInterface
getGeometry, getHeight
-
Constructor Details
-
AbstractLaneBasedObject
protected AbstractLaneBasedObject(java.lang.String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry, Length height) throws NetworkExceptionConstruct a new AbstractLanebasedObject with the required fields.- Parameters:
id
- String; the id of the new objectlane
- Lane; The lane on which the new object resides. If the new object is a Sensor; it is automatically registered on the lanedirection
- LongitudinalDirectionality; the directionality in which this is valid.longitudinalPosition
- Length; The position (between 0.0 and the length of the Lane) of the sensor on the design line of the lanegeometry
- OTSLine3D; the geometry of the object, which provides its location and bounds as wellheight
- Length; the height of the object, in case it is a 3D object- Throws:
NetworkException
- when the position on the lane is out of bounds
-
AbstractLaneBasedObject
protected AbstractLaneBasedObject(java.lang.String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry, Length height) throws NetworkExceptionConstruct a new AbstractLanebasedObject with the required fields.- Parameters:
id
- String; the id of the new objectlane
- Lane; The lane on which the new object resides. If the new object is a Sensor; it is automatically registered on the lanelongitudinalPosition
- Length; The position (between 0.0 and the length of the Lane) of the sensor on the design line of the lanegeometry
- OTSLine3D; the geometry of the object, which provides its location and bounds as wellheight
- Length; the height of the object, in case it is a 3D object- Throws:
NetworkException
- when the position on the lane is out of bounds
-
AbstractLaneBasedObject
protected AbstractLaneBasedObject(java.lang.String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry) throws NetworkExceptionConstruct a new LaneBasedObject with the required fields.- Parameters:
id
- String; the id of the new AbstractLaneBasedObjectlane
- Lane; The lane for which this is a sensordirection
- LongitudinalDirectionality; the directionality in which this is valid.longitudinalPosition
- Length; The position (between 0.0 and the length of the Lane) of the sensor on the design line of the lanegeometry
- OTSLine3D; the geometry of the object, which provides its location and bounds as well- Throws:
NetworkException
- when the position on the lane is out of bounds
-
AbstractLaneBasedObject
protected AbstractLaneBasedObject(java.lang.String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry) throws NetworkExceptionConstruct a new LaneBasedObject with the required fields.- Parameters:
id
- String; the id of the new AbstractLaneBasedObjectlane
- Lane; The lane for which this is a sensorlongitudinalPosition
- Length; The position (between 0.0 and the length of the Lane) of the sensor on the design line of the lanegeometry
- OTSLine3D; the geometry of the object, which provides its location and bounds as well- Throws:
NetworkException
- when the position on the lane is out of bounds
-
-
Method Details
-
init
- Overrides:
init
in classStaticObject
- Throws:
NetworkException
-
getFullId
public final java.lang.String getFullId()- Specified by:
getFullId
in interfaceObjectInterface
- Overrides:
getFullId
in classStaticObject
-
getLane
- Specified by:
getLane
in interfaceLaneBasedObject
- Returns:
- The lane for which this is a sensor.
-
getDirection
- Specified by:
getDirection
in interfaceLaneBasedObject
- Returns:
- Longitudinal direction.
-
getLongitudinalPosition
- Specified by:
getLongitudinalPosition
in interfaceLaneBasedObject
- Returns:
- the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lane.
-
getLocation
Return the location without throwing a RemoteException.- Specified by:
getLocation
in interfaceLaneBasedObject
- Specified by:
getLocation
in interfaceLocatable
- Overrides:
getLocation
in classStaticObject
- Returns:
- DirectedPoint; the location
-
clone
public final StaticObject clone(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator, boolean animation) throws NetworkException- Overrides:
clone
in classStaticObject
- Throws:
NetworkException
-
toString
public java.lang.String toString()- Overrides:
toString
in classStaticObject
-
clone
public abstract AbstractLaneBasedObject clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkExceptionClone the LaneBasedObject for e.g., copying a network.- Parameters:
newCSE
- CrossSectionElement; the new cross section element to which the clone belongsnewSimulator
- SimulatorInterface.TimeDoubleUnit; the new simulator for this network- Returns:
- AbstractLaneBasedObject; a clone of this object
- Throws:
NetworkException
- in case the cloning fails
-