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 boolean
addListener(EventListenerInterface listener, EventTypeInterface eventType)
boolean
addListener(EventListenerInterface listener, EventTypeInterface eventType, int position)
boolean
addListener(EventListenerInterface listener, EventTypeInterface eventType, int position, ReferenceType referenceType)
boolean
addListener(EventListenerInterface listener, EventTypeInterface eventType, ReferenceType referenceType)
void
draw(Graphics2D g2)
Draw yourself at the indicated location.org.opentrafficsim.core.geometry.Bounds
getBounds()
org.opentrafficsim.core.network.LongitudinalDirectionality
getDirection()
Set<EventTypeInterface>
getEventTypesWithListeners()
String
getFullId()
org.opentrafficsim.core.geometry.OTSLine3D
getGeometry()
Length
getHeight()
String
getId()
Lane
getLane()
org.opentrafficsim.core.geometry.DirectedPoint
getLocation()
Length
getLongitudinalPosition()
Serializable
getSourceId()
TrafficLightColor
getTrafficLightColor()
boolean
hasListeners()
int
numberOfListeners(EventTypeInterface eventType)
boolean
removeListener(EventListenerInterface listener, EventTypeInterface eventType)
void
setTrafficLightColor(TrafficLightColor trafficLightColor)
String
toolTipHit(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:
toolTipHit
in 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:
getLocation
in interfaceLaneBasedObject
- Specified by:
getLocation
in interfaceLocatable
-
getBounds
public org.opentrafficsim.core.geometry.Bounds getBounds()
- Specified by:
getBounds
in interfaceLaneBasedObject
- Specified by:
getBounds
in interfaceLocatable
- Specified by:
getBounds
in interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getLane
public Lane getLane()
- Specified by:
getLane
in interfaceLaneBasedObject
-
getDirection
public org.opentrafficsim.core.network.LongitudinalDirectionality getDirection()
- Specified by:
getDirection
in interfaceLaneBasedObject
-
getLongitudinalPosition
public Length getLongitudinalPosition()
- Specified by:
getLongitudinalPosition
in interfaceLaneBasedObject
-
getGeometry
public org.opentrafficsim.core.geometry.OTSLine3D getGeometry()
- Specified by:
getGeometry
in interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getHeight
public Length getHeight()
- Specified by:
getHeight
in interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getId
public String getId()
- Specified by:
getId
in interfaceorg.opentrafficsim.base.Identifiable
-
getFullId
public String getFullId()
- Specified by:
getFullId
in interfaceorg.opentrafficsim.core.object.ObjectInterface
-
getSourceId
public Serializable getSourceId() throws RemoteException
- Specified by:
getSourceId
in interfaceEventProducerInterface
- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType, ReferenceType referenceType) throws RemoteException
- Specified by:
addListener
in interfaceEventProducerInterface
- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType, int position) throws RemoteException
- Specified by:
addListener
in interfaceEventProducerInterface
- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType, int position, ReferenceType referenceType) throws RemoteException
- Specified by:
addListener
in interfaceEventProducerInterface
- Throws:
RemoteException
-
addListener
public boolean addListener(EventListenerInterface listener, EventTypeInterface eventType) throws RemoteException
- Specified by:
addListener
in interfaceEventProducerInterface
- Throws:
RemoteException
-
hasListeners
public boolean hasListeners() throws RemoteException
- Specified by:
hasListeners
in interfaceEventProducerInterface
- Throws:
RemoteException
-
numberOfListeners
public int numberOfListeners(EventTypeInterface eventType) throws RemoteException
- Specified by:
numberOfListeners
in interfaceEventProducerInterface
- Throws:
RemoteException
-
getEventTypesWithListeners
public Set<EventTypeInterface> getEventTypesWithListeners() throws RemoteException
- Specified by:
getEventTypesWithListeners
in interfaceEventProducerInterface
- Throws:
RemoteException
-
removeListener
public boolean removeListener(EventListenerInterface listener, EventTypeInterface eventType) throws RemoteException
- Specified by:
removeListener
in interfaceEventProducerInterface
- Throws:
RemoteException
-
getTrafficLightColor
public TrafficLightColor getTrafficLightColor()
- Specified by:
getTrafficLightColor
in interfaceTrafficLight
-
setTrafficLightColor
public void setTrafficLightColor(TrafficLightColor trafficLightColor)
- Specified by:
setTrafficLightColor
in interfaceTrafficLight
-
draw
public void draw(Graphics2D g2)
Draw yourself at the indicated location.- Specified by:
draw
in interfaceTrafCODObject
- Parameters:
g2
- Graphics2D; the graphics context
-
-