1 package org.opentrafficsim.road.network.animation;
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.animation.TextAlignment;
14 import org.opentrafficsim.core.animation.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) 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) throws RemoteException
56 {
57 graphics.setColor(Color.white);
58 super.paint(graphics, observer);
59 }
60
61
62 @Override
63 public final void destroy() throws NamingException
64 {
65 super.destroy();
66 this.text.destroy();
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
88
89 public class Text extends TextAnimation
90 {
91
92 private static final long serialVersionUID = 20161211L;
93
94
95
96
97
98
99
100
101
102
103
104
105 public Text(final Locatable source, final String text, final float dx, final float dy,
106 final TextAlignment textPlacement, final Color color, final SimulatorInterface.TimeDoubleUnit simulator)
107 throws RemoteException, NamingException
108 {
109 super(source, text, dx, dy, textPlacement, color, simulator);
110 }
111
112
113 @Override
114 @SuppressWarnings("checkstyle:designforextension")
115 public TextAnimation clone(final Locatable newSource, final SimulatorInterface.TimeDoubleUnit newSimulator)
116 throws RemoteException, NamingException
117 {
118 return new Text(newSource, getText(), getDx(), getDy(), getTextAlignment(), getColor(), newSimulator);
119 }
120
121
122 @Override
123 public final String toString()
124 {
125 return "Text []";
126 }
127 }
128
129 }