1 package org.opentrafficsim.draw.road;
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.dsol.OtsSimulatorInterface;
12 import org.opentrafficsim.draw.core.PaintPolygons;
13 import org.opentrafficsim.road.network.lane.CrossSectionElement;
14
15 import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
16
17
18
19
20
21
22
23
24 public class CrossSectionElementAnimation extends Renderable2D<CrossSectionElement> implements Serializable
25 {
26
27 private static final long serialVersionUID = 20141017L;
28
29
30 private final Color color;
31
32
33
34
35
36
37
38
39 public CrossSectionElementAnimation(final CrossSectionElement source, final OtsSimulatorInterface simulator,
40 final Color color) throws NamingException, RemoteException
41 {
42 super(source, simulator);
43 this.color = color;
44 }
45
46
47 @Override
48 public final void paint(final Graphics2D graphics, final ImageObserver observer)
49 {
50 CrossSectionElement shoulder = getSource();
51 PaintPolygons.paintMultiPolygon(graphics, this.color, shoulder.getLocation(), shoulder.getContour(), true);
52 }
53
54
55 @Override
56 public final String toString()
57 {
58 return "CrossSectionElementAnimation [source = " + getSource().toString() + ", color=" + this.color + "]";
59 }
60 }