Class AbstractLaneBasedObject
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.core.object.StaticObject
org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
- All Implemented Interfaces:
Serializable
,Remote
,Locatable
,org.djutils.event.EventProducer
,org.opentrafficsim.base.Identifiable
,Drawable
,LocatedObject
,LaneBasedObject
- Direct Known Subclasses:
BusStop
,Conflict
,Conflict.ConflictEnd
,Distraction
,LaneDetector
,SpeedSign
,TrafficLight
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-2023 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:
-
Field Summary
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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. -
Method Summary
Methods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getBounds, getGeometry, getHeight, getId
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, 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.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, 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.LocatedObject
getGeometry, getHeight
-
Constructor Details
-
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, 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 Details
-
init
- Overrides:
init
in classStaticObject
- Throws:
NetworkException
-
getFullId
- Specified by:
getFullId
in interfaceLocatedObject
- Overrides:
getFullId
in classStaticObject
-
getLane
- Specified by:
getLane
in interfaceLaneBasedObject
- Returns:
- The lane for which this is a sensor.
-
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
-
toString
- Overrides:
toString
in classStaticObject
-