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.djunits.unit.LengthUnit;
12 import org.djunits.value.vdouble.scalar.Length;
13 import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
14 import org.opentrafficsim.draw.core.TextAlignment;
15 import org.opentrafficsim.draw.core.TextAnimation;
16 import org.opentrafficsim.road.network.lane.object.BusStop;
17
18 import nl.tudelft.simulation.dsol.animation.Locatable;
19 import nl.tudelft.simulation.naming.context.Contextualized;
20
21
22
23
24
25
26
27
28
29
30 public class BusStopAnimation extends AbstractLineAnimation<BusStop> implements Serializable
31 {
32
33
34 private static final long serialVersionUID = 20170125L;
35
36
37 private final Text text;
38
39
40
41
42
43
44
45 public BusStopAnimation(final BusStop source, final OtsSimulatorInterface simulator) throws NamingException, RemoteException
46 {
47 super(source, simulator, .8, new Length(0.5, LengthUnit.SI));
48
49 this.text = new Text(source, source.getId(), 0.0f, (float) getHalfLength() + 0.2f, TextAlignment.CENTER, Color.BLACK,
50 simulator);
51 }
52
53
54 @Override
55 public final void paint(final Graphics2D graphics, final ImageObserver observer)
56 {
57 graphics.setColor(Color.white);
58 super.paint(graphics, observer);
59 }
60
61
62 @Override
63 public void destroy(final Contextualized contextProvider)
64 {
65 super.destroy(contextProvider);
66 this.text.destroy(contextProvider);
67 }
68
69
70 @Override
71 public final String toString()
72 {
73 return "BusStopAnimation [getSource()=" + getSource() + "]";
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87 public class Text extends TextAnimation
88 {
89
90 private static final long serialVersionUID = 20161211L;
91
92
93
94
95
96
97
98
99
100
101
102
103 public Text(final Locatable source, final String text, final float dx, final float dy,
104 final TextAlignment textPlacement, final Color color, final OtsSimulatorInterface simulator)
105 throws RemoteException, NamingException
106 {
107 super(source, text, dx, dy, textPlacement, color, simulator, TextAnimation.RENDERALWAYS);
108 }
109
110
111 @Override
112 public final String toString()
113 {
114 return "Text []";
115 }
116 }
117
118 }