Class AbstractLaneBasedObject
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.core.object.StaticObject
-
- org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
-
- All Implemented Interfaces:
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.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Sep 10, 2016
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLaneBasedObject(String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry)
Construct a new LaneBasedObject with the required fields.protected
AbstractLaneBasedObject(String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry, Length height)
Construct a new AbstractLanebasedObject with the required fields.protected
AbstractLaneBasedObject(String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry)
Construct a new LaneBasedObject with the required fields.protected
AbstractLaneBasedObject(String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry, Length height)
Construct a new AbstractLanebasedObject with the required fields.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StaticObject
clone(Network newNetwork, boolean animation)
abstract AbstractLaneBasedObject
clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator)
Clone the LaneBasedObject for e.g., copying a network.LongitudinalDirectionality
getDirection()
String
getFullId()
Lane
getLane()
DirectedPoint
getLocation()
Return the location without throwing a RemoteException.Length
getLongitudinalPosition()
protected void
init()
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, 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
-
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.base.Identifiable
getId
-
Methods inherited from interface org.opentrafficsim.road.network.lane.object.LaneBasedObject
getBounds
-
Methods inherited from interface org.opentrafficsim.core.object.ObjectInterface
getGeometry, getHeight
-
-
-
-
Constructor Detail
-
AbstractLaneBasedObject
protected AbstractLaneBasedObject(String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry, Length height) throws NetworkException
Construct 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(String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry, Length height) throws NetworkException
Construct 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(String id, Lane lane, LongitudinalDirectionality direction, Length longitudinalPosition, OTSLine3D geometry) throws NetworkException
Construct 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(String id, Lane lane, Length longitudinalPosition, OTSLine3D geometry) throws NetworkException
Construct 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 Detail
-
init
protected void init() throws NetworkException
- Overrides:
init
in classStaticObject
- Throws:
NetworkException
-
getFullId
public final String getFullId()
- Specified by:
getFullId
in interfaceObjectInterface
- Overrides:
getFullId
in classStaticObject
-
getLane
public final Lane getLane()
- Specified by:
getLane
in interfaceLaneBasedObject
- Returns:
- The lane for which this is a sensor.
-
getDirection
public final LongitudinalDirectionality getDirection()
- Specified by:
getDirection
in interfaceLaneBasedObject
- Returns:
- Longitudinal direction.
-
getLongitudinalPosition
public final Length 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
public DirectedPoint 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, boolean animation) throws NetworkException
- Overrides:
clone
in classStaticObject
- Throws:
NetworkException
-
toString
public String toString()
- Overrides:
toString
in classStaticObject
-
clone
public abstract AbstractLaneBasedObject clone(CrossSectionElement newCSE, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkException
Clone 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
-
-