View Javadoc
1   package org.opentrafficsim.road.network.animation;
2   
3   import java.awt.Color;
4   import java.awt.Graphics2D;
5   import java.awt.image.ImageObserver;
6   import java.rmi.RemoteException;
7   
8   import javax.naming.NamingException;
9   
10  import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
11  
12  import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
13  import org.opentrafficsim.core.network.animation.PaintPolygons;
14  import org.opentrafficsim.road.network.lane.Shoulder;
15  
16  /**
17   * <p>
18   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
20   * <p>
21   * $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, @version $Revision: 1401 $, by $Author: averbraeck $,
22   * initial version Oct 17, 2014 <br>
23   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
24   */
25  public class ShoulderAnimation extends Renderable2D
26  {
27      /** The animation color. */
28      private final Color color;
29  
30      /**
31       * @param source s
32       * @param simulator s
33       * @param color the color to draw the shoulder with
34       * @throws NamingException ne
35       * @throws RemoteException on communication failure
36       */
37      public ShoulderAnimation(final Shoulder source, final OTSSimulatorInterface simulator, final Color color)
38          throws NamingException, RemoteException
39      {
40          super(source, simulator);
41          this.color = color;
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      public final void paint(final Graphics2D graphics, final ImageObserver observer)
47      {
48          Shoulder shoulder = (Shoulder) getSource();
49          PaintPolygons.paintMultiPolygon(graphics, this.color, shoulder.getLocation(), shoulder.getContour(), true);
50      }
51  }