1 package org.opentrafficsim.road.network.animation;
2
3 import java.awt.Color;
4 import java.awt.Graphics2D;
5 import java.awt.geom.Rectangle2D;
6 import java.awt.image.ImageObserver;
7 import java.io.Serializable;
8 import java.rmi.RemoteException;
9
10 import javax.naming.NamingException;
11
12 import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
13 import org.opentrafficsim.road.network.lane.object.sensor.SinkSensor;
14
15 import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public class SinkAnimation extends Renderable2D implements Serializable
30 {
31
32 private static final long serialVersionUID = 20150130L;
33
34
35 private final double halfWidth;
36
37
38
39
40
41
42
43
44 public SinkAnimation(final SinkSensor source, final OTSSimulatorInterface simulator) throws NamingException,
45 RemoteException
46 {
47 super(source, simulator);
48 this.halfWidth = 0.4 * source.getLane().getWidth(0.0).getSI();
49 }
50
51
52 @Override
53 public final void paint(final Graphics2D graphics, final ImageObserver observer)
54 {
55 graphics.setColor(Color.YELLOW);
56 Rectangle2D rectangle = new Rectangle2D.Double(-0.25, -this.halfWidth, 0.5, 2 * this.halfWidth);
57 graphics.fill(rectangle);
58 }
59
60
61 @Override
62 public final String toString()
63 {
64 return "SinkAnimation [getSource()=" + this.getSource() + "]";
65 }
66 }