Class TrafficLightImage

java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.trafficcontrol.trafcod.TrafficLightImage
All Implemented Interfaces:
Serializable, Remote, org.djutils.event.EventProducer, TrafCODObject

class TrafficLightImage extends org.djutils.event.LocalEventProducer implements TrafCODObject
Draws a traffic light.
  • Field Summary

    Fields inherited from interface org.djutils.event.EventProducer

    FIRST_POSITION, LAST_POSITION
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrafficLightImage(TrafCodDisplay display, Point2D center, String description)
    Create a traffic light image.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Draw yourself at the indicated location.
    void
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 rendered
      center - Point2D; coordinates in the image where this traffic light is centered on
      description - String; tool tip text for the new traffic light image
  • Method Details

    • 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 interface TrafCODObject
      Parameters:
      testX - int; the x-coordinate
      testY - int; the y-coordinate
      Returns:
      String; the tool tip text or null if the coordinates do not hit the TrafCodObject
    • setTrafficLightColor

      public void setTrafficLightColor(TrafficLightColor trafficLightColor)
      Sets the traffic light color.
      Parameters:
      trafficLightColor - TrafficLightColor; traffic light color.
    • draw

      public void draw(Graphics2D g2)
      Draw yourself at the indicated location.
      Specified by:
      draw in interface TrafCODObject
      Parameters:
      g2 - Graphics2D; the graphics context