View Javadoc
1   package org.opentrafficsim.road.gtu.lane.object;
2   
3   import java.rmi.RemoteException;
4   
5   import javax.naming.NamingException;
6   
7   import org.djunits.unit.LengthUnit;
8   import org.djunits.value.vdouble.scalar.Length;
9   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
10  import org.opentrafficsim.core.geometry.OTSGeometryException;
11  import org.opentrafficsim.road.gtu.lane.object.animation.TrafficLightAnimation;
12  import org.opentrafficsim.road.network.lane.Lane;
13  
14  /**
15   * <p>
16   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
18   * </p>
19   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
20   * initial version Dec 1, 2015 <br>
21   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
22   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
23   */
24  public class OldTrafficLight extends TrafficLight
25  {
26  
27      /**
28       * @param id traffic light id
29       * @param lane lane where the traffic light is located
30       * @param position position of the traffic light on the lane, in the design direction
31       * @param simulator simulator on which to schedule color changes
32       * @throws OTSGeometryException on failure to place the object
33       */
34      public OldTrafficLight(final String id, final Lane lane, final Length.Rel position,
35          final OTSDEVSSimulatorInterface simulator) throws OTSGeometryException
36      {
37          super(AbstractCSEObject.createRectangleOnCSE(lane, position, new Length.Rel(0.5, LengthUnit.METER), lane
38              .getWidth(position).multiplyBy(0.8), new Length.Rel(0.5, LengthUnit.METER)), new Length.Rel(0.5,
39              LengthUnit.METER), TrafficLightColor.RED);
40  
41          try
42          {
43              new TrafficLightAnimation(this, simulator);
44          }
45          catch (RemoteException exception)
46          {
47              exception.printStackTrace();
48          }
49          catch (NamingException exception)
50          {
51              exception.printStackTrace();
52          }
53      }
54  }