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