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
31 public class BusStopAnimation extends AbstractLineAnimation<BusStop> implements Serializable
32 {
33
34
35 private static final long serialVersionUID = 20170125L;
36
37
38 private final Text text;
39
40
41
42
43
44
45
46 public BusStopAnimation(final BusStop source, final OTSSimulatorInterface simulator)
47 throws NamingException, RemoteException
48 {
49 super(source, simulator, .8, new Length(0.5, LengthUnit.SI));
50
51 this.text = new Text(source, source.getId(), 0.0f, (float) getHalfLength() + 0.2f, TextAlignment.CENTER, Color.BLACK,
52 simulator);
53 }
54
55
56 @Override
57 public final void paint(final Graphics2D graphics, final ImageObserver observer)
58 {
59 graphics.setColor(Color.white);
60 super.paint(graphics, observer);
61 }
62
63
64 @Override
65 public void destroy(final Contextualized contextProvider)
66 {
67 super.destroy(contextProvider);
68 this.text.destroy(contextProvider);
69 }
70
71
72 @Override
73 public final String toString()
74 {
75 return "BusStopAnimation [getSource()=" + getSource() + "]";
76 }
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 public class Text extends TextAnimation
92 {
93
94 private static final long serialVersionUID = 20161211L;
95
96
97
98
99
100
101
102
103
104
105
106
107 public Text(final Locatable source, final String text, final float dx, final float dy,
108 final TextAlignment textPlacement, final Color color, final OTSSimulatorInterface simulator)
109 throws RemoteException, NamingException
110 {
111 super(source, text, dx, dy, textPlacement, color, simulator, TextAnimation.RENDERALWAYS);
112 }
113
114
115 @Override
116 @SuppressWarnings("checkstyle:designforextension")
117 public TextAnimation clone(final Locatable newSource, final OTSSimulatorInterface newSimulator)
118 throws RemoteException, NamingException
119 {
120 return new Text(newSource, getText(), getDx(), getDy(), getTextAlignment(), getColor(), newSimulator);
121 }
122
123
124 @Override
125 public final String toString()
126 {
127 return "Text []";
128 }
129 }
130
131 }