1 package org.opentrafficsim.road.gtu.generator;
2
3 import java.awt.Color;
4 import java.awt.Font;
5 import java.awt.Graphics2D;
6 import java.awt.image.ImageObserver;
7 import java.rmi.RemoteException;
8 import java.util.Map;
9
10 import javax.naming.NamingException;
11
12 import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
13 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
14 import nl.tudelft.simulation.language.d3.DirectedPoint;
15
16
17
18
19
20
21
22
23
24
25
26
27 public class GTUGeneratorAnimation extends Renderable2D<GTUGenerator>
28 {
29
30
31 private static final Font FONT = new Font("SansSerif", Font.PLAIN, 4);
32
33
34
35
36
37
38
39
40 public GTUGeneratorAnimation(final GTUGenerator source, final SimulatorInterface<?, ?, ?> simulator)
41 throws NamingException, RemoteException
42 {
43 super(source, simulator);
44 }
45
46
47 @Override
48 public void paint(final Graphics2D graphics, final ImageObserver observer) throws RemoteException
49 {
50 graphics.setColor(Color.BLACK);
51 graphics.setFont(FONT);
52 DirectedPoint p = getSource().getLocation();
53 Map<DirectedPoint, Integer> map = getSource().getQueueLengths();
54 for (DirectedPoint lanePosition : map.keySet())
55 {
56 graphics.drawString(map.get(lanePosition) + "", (int) (lanePosition.x - p.x), (int) (-lanePosition.y + p.y));
57 }
58 }
59
60 }