1
2
3
4
5
6
7
8
9
10
11 package nl.tudelft.simulation.traffic.animation;
12
13 import java.awt.BasicStroke;
14 import java.awt.Color;
15 import java.awt.Font;
16 import java.awt.Graphics2D;
17 import java.awt.geom.Rectangle2D;
18 import java.awt.image.ImageObserver;
19 import java.rmi.RemoteException;
20
21 import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
22 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
23 import nl.tudelft.simulation.traffic.controlpoint.ControlPointInterface;
24
25 /***
26 * This class enables the animation of a control point.
27 * <p>
28 * (c) copyright 2004 <a href="http://www.simulation.tudelft.nl">Delft
29 * University of Technology </a>, the Netherlands.
30 * <p>
31 * See for project information <a href="http://www.simulation.tudelft.nl">
32 * www.simulation.tudelft.nl </a> <br>
33 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
34 * License (GPL) </a>, no warranty <br>
35 *
36 * @version 1.0 Oct 31, 2004 <br>
37 * @author <a
38 * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
39 * Verbraeck </a> <br>
40 */
41 public class ControlPointAnimation extends Renderable2D
42 {
43 /*** the deltax of the place of the comment */
44 private double deltax;
45
46 /*** the deltay of the place of the comment */
47 private double deltay;
48
49 /***
50 * @param cpi
51 * @param simulator
52 */
53 public ControlPointAnimation(final ControlPointInterface cpi,
54 final SimulatorInterface simulator)
55 {
56 this(cpi, simulator, 0.0, 0.0);
57 }
58
59 /***
60 * @param cpi
61 * @param simulator
62 * @param deltax
63 * @param deltay
64 */
65 public ControlPointAnimation(final ControlPointInterface cpi,
66 final SimulatorInterface simulator, final double deltax,
67 final double deltay)
68 {
69 super(new ControlPointLocation(cpi), simulator);
70 this.deltax = deltax;
71 this.deltay = -deltay;
72 }
73
74 /***
75 * @see nl.tudelft.simulation.dsol.animation.D2.Renderable2D#paint(java.awt.Graphics2D,
76 * java.awt.image.ImageObserver)
77 */
78 public void paint(final Graphics2D graphics, final ImageObserver io)
79 throws RemoteException
80 {
81 if (true)
82 {
83 graphics.setColor(Color.ORANGE);
84 graphics.setStroke(new BasicStroke(0.05f));
85 graphics.fill(new Rectangle2D.Double(-0.1, -0.1, 0.2, 0.2));
86 graphics.setColor(Color.BLACK);
87 Font smallFont = new Font("SansSerif", Font.PLAIN, 1);
88 graphics.setFont(smallFont);
89 graphics.drawString(this.source.toString(), (float) (this.deltax),
90 (float) (this.deltay));
91 }
92 }
93
94 }