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.draw.core.TextAlignment;
14 import org.opentrafficsim.draw.core.TextAnimation;
15 import org.opentrafficsim.road.network.lane.object.BusStop;
16
17 import nl.tudelft.simulation.dsol.animation.Locatable;
18 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
19
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 SimulatorInterface.TimeDoubleUnit simulator)
46 throws NamingException, RemoteException
47 {
48 super(source, simulator, .8, new Length(0.5, LengthUnit.SI));
49
50 this.text = new Text(source, source.getId(), 0.0f, (float) getHalfLength() + 0.2f, TextAlignment.CENTER, Color.BLACK,
51 simulator);
52 }
53
54
55 @Override
56 public final void paint(final Graphics2D graphics, final ImageObserver observer) throws RemoteException
57 {
58 graphics.setColor(Color.white);
59 super.paint(graphics, observer);
60 }
61
62
63 @Override
64 public final void destroy() throws NamingException
65 {
66 super.destroy();
67 this.text.destroy();
68 }
69
70
71 @Override
72 public final String toString()
73 {
74 return "BusStopAnimation [getSource()=" + getSource() + "]";
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 public class Text extends TextAnimation
91 {
92
93 private static final long serialVersionUID = 20161211L;
94
95
96
97
98
99
100
101
102
103
104
105
106 public Text(final Locatable source, final String text, final float dx, final float dy,
107 final TextAlignment textPlacement, final Color color, final SimulatorInterface.TimeDoubleUnit simulator)
108 throws RemoteException, NamingException
109 {
110 super(source, text, dx, dy, textPlacement, color, simulator);
111 }
112
113
114 @Override
115 @SuppressWarnings("checkstyle:designforextension")
116 public TextAnimation clone(final Locatable newSource, final SimulatorInterface.TimeDoubleUnit newSimulator)
117 throws RemoteException, NamingException
118 {
119 return new Text(newSource, getText(), getDx(), getDy(), getTextAlignment(), getColor(), newSimulator);
120 }
121
122
123 @Override
124 public final String toString()
125 {
126 return "Text []";
127 }
128 }
129
130 }