Class TrafficLightImage
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.trafficcontrol.trafcod.TrafficLightImage
- All Implemented Interfaces:
Serializable
,Remote
,org.djutils.event.EventProducer
,TrafCODObject
Draws a traffic light.
-
Field Summary
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionTrafficLightImage
(TrafCodDisplay display, Point2D center, String description) Create a traffic light image. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Graphics2D g2) Draw yourself at the indicated location.void
setTrafficLightColor
(TrafficLightColor trafficLightColor) Sets the traffic light color.toolTipHit
(int testX, int testY) Check if the given coordinates hit the TrafCODObject.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
-
Constructor Details
-
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 Details
-
toolTipHit
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
-
setTrafficLightColor
Sets the traffic light color.- Parameters:
trafficLightColor
- TrafficLightColor; traffic light color.
-
draw
Draw yourself at the indicated location.- Specified by:
draw
in interfaceTrafCODObject
- Parameters:
g2
- Graphics2D; the graphics context
-