Class TrafficLightImage
- java.lang.Object
-
- org.opentrafficsim.trafficcontrol.trafcod.TrafficLightImage
-
- All Implemented Interfaces:
Serializable,Locatable,EventProducerInterface,org.opentrafficsim.base.Identifiable,org.opentrafficsim.core.object.ObjectInterface,LaneBasedObject,TrafficLight,TrafCODObject
class TrafficLightImage extends Object implements TrafficLight, TrafCODObject
Draws a traffic light.
The implementation of TrafficLight only implements setTrafficLightColor. All other methods are dummies.
-
-
Field Summary
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Fields inherited from interface org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight
TRAFFICLIGHT_CHANGE_EVENT
-
-
Constructor Summary
Constructors Constructor Description TrafficLightImage(TrafCODDisplay display, Point2D center, String description)Create a traffic light image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddListener(EventListenerInterface listener, EventTypeInterface eventType)booleanaddListener(EventListenerInterface listener, EventTypeInterface eventType, int position)booleanaddListener(EventListenerInterface listener, EventTypeInterface eventType, int position, ReferenceType referenceType)booleanaddListener(EventListenerInterface listener, EventTypeInterface eventType, ReferenceType referenceType)voiddraw(Graphics2D g2)Draw yourself at the indicated location.org.opentrafficsim.core.geometry.BoundsgetBounds()org.opentrafficsim.core.network.LongitudinalDirectionalitygetDirection()Set<EventTypeInterface>getEventTypesWithListeners()StringgetFullId()org.opentrafficsim.core.geometry.OTSLine3DgetGeometry()LengthgetHeight()StringgetId()LanegetLane()org.opentrafficsim.core.geometry.DirectedPointgetLocation()LengthgetLongitudinalPosition()SerializablegetSourceId()TrafficLightColorgetTrafficLightColor()booleanhasListeners()intnumberOfListeners(EventTypeInterface eventType)booleanremoveListener(EventListenerInterface listener, EventTypeInterface eventType)voidsetTrafficLightColor(TrafficLightColor trafficLightColor)StringtoolTipHit(int testX, int testY)Check if the given coordinates hit the TrafCODObject.
-
-
-
Constructor Detail
-
TrafficLightImage
TrafficLightImage(TrafCODDisplay display, Point2D center, String description)
Create a traffic light image.- Parameters:
display- TrafCODDisplay; the TrafCOD display on which this traffic light image will be renderedcenter- Point2D; coordinates in the image where this traffic light is centered ondescription- String; tool tip text for the new traffic light image
-
-
Method Detail
-
toolTipHit
public String toolTipHit(int testX, int testY)
Check if the given coordinates hit the TrafCODObject. If it does return a String to be used as a tool tip text. If the coordinates do not hit this TrafCODObject return null.- Specified by:
toolTipHitin interfaceTrafCODObject- Parameters:
testX- int; the x-coordinatetestY- int; the y-coordinate- Returns:
- String; the tool tip text or null if the coordinates do not hit the TrafCodObject
-
getLocation
public org.opentrafficsim.core.geometry.DirectedPoint getLocation()
- Specified by:
getLocationin interfaceLaneBasedObject- Specified by:
getLocationin interfaceLocatable
-
getBounds
public org.opentrafficsim.core.geometry.Bounds getBounds()
- Specified by:
getBoundsin interfaceLaneBasedObject- Specified by:
getBoundsin interfaceLocatable- Specified by:
getBoundsin interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getLane
public Lane getLane()
- Specified by:
getLanein interfaceLaneBasedObject
-
getDirection
public org.opentrafficsim.core.network.LongitudinalDirectionality getDirection()
- Specified by:
getDirectionin interfaceLaneBasedObject
-
getLongitudinalPosition
public Length getLongitudinalPosition()
- Specified by:
getLongitudinalPositionin interfaceLaneBasedObject
-
getGeometry
public org.opentrafficsim.core.geometry.OTSLine3D getGeometry()
- Specified by:
getGeometryin interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getHeight
public Length getHeight()
- Specified by:
getHeightin interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getId
public String getId()
- Specified by:
getIdin interfaceorg.opentrafficsim.base.Identifiable
-
getFullId
public String getFullId()
- Specified by:
getFullIdin interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getSourceId
public Serializable getSourceId() throws RemoteException
- Specified by:
getSourceIdin interfaceEventProducerInterface- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType, ReferenceType referenceType) throws RemoteException
- Specified by:
addListenerin interfaceEventProducerInterface- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType, int position) throws RemoteException
- Specified by:
addListenerin interfaceEventProducerInterface- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType, int position, ReferenceType referenceType) throws RemoteException
- Specified by:
addListenerin interfaceEventProducerInterface- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType) throws RemoteException
- Specified by:
addListenerin interfaceEventProducerInterface- Throws:
RemoteException
-
hasListeners
public boolean hasListeners() throws RemoteException- Specified by:
hasListenersin interfaceEventProducerInterface- Throws:
RemoteException
-
numberOfListeners
public int numberOfListeners(EventTypeInterface eventType) throws RemoteException
- Specified by:
numberOfListenersin interfaceEventProducerInterface- Throws:
RemoteException
-
getEventTypesWithListeners
public Set<EventTypeInterface> getEventTypesWithListeners() throws RemoteException
- Specified by:
getEventTypesWithListenersin interfaceEventProducerInterface- Throws:
RemoteException
-
removeListener
public boolean removeListener(EventListenerInterface listener, EventTypeInterface eventType) throws RemoteException
- Specified by:
removeListenerin interfaceEventProducerInterface- Throws:
RemoteException
-
getTrafficLightColor
public TrafficLightColor getTrafficLightColor()
- Specified by:
getTrafficLightColorin interfaceTrafficLight
-
setTrafficLightColor
public void setTrafficLightColor(TrafficLightColor trafficLightColor)
- Specified by:
setTrafficLightColorin interfaceTrafficLight
-
draw
public void draw(Graphics2D g2)
Draw yourself at the indicated location.- Specified by:
drawin interfaceTrafCODObject- Parameters:
g2- Graphics2D; the graphics context
-
-