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.rmi.RemoteException;
7 import java.util.function.Supplier;
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.TextAlignment;
14 import org.opentrafficsim.draw.TextAnimation;
15 import org.opentrafficsim.draw.road.AbstractLineAnimation.LaneBasedObjectData;
16 import org.opentrafficsim.draw.road.BusStopAnimation.BusStopData;
17
18 import nl.tudelft.simulation.naming.context.Contextualized;
19
20
21
22
23
24
25
26
27
28
29
30
31 public class BusStopAnimation extends AbstractLineAnimation<BusStopData>
32 {
33
34 private static final long serialVersionUID = 20150130L;
35
36
37 private final Text text;
38
39
40
41
42
43
44
45
46 public BusStopAnimation(final BusStopData laneDetector, final Contextualized contextualized)
47 throws NamingException, RemoteException
48 {
49 super(laneDetector, contextualized, .9, new Length(0.5, LengthUnit.SI));
50 this.text = new Text(laneDetector, laneDetector::getId, 0.0f, (float) getHalfLength() + 0.2f, TextAlignment.CENTER,
51 Color.BLACK, contextualized);
52 }
53
54
55
56
57 public final Text getText()
58 {
59 return this.text;
60 }
61
62
63 @Override
64 public final void paint(final Graphics2D graphics, final ImageObserver observer)
65 {
66 graphics.setColor(Color.WHITE);
67 super.paint(graphics, observer);
68 }
69
70
71 @Override
72 public void destroy(final Contextualized contextProvider)
73 {
74 super.destroy(contextProvider);
75 this.text.destroy(contextProvider);
76 }
77
78
79 @Override
80 public final String toString()
81 {
82 return "DetectorAnimation [getSource()=" + this.getSource() + "]";
83 }
84
85
86
87
88
89
90
91
92
93
94
95
96 public class Text extends TextAnimation<BusStopData, Text>
97 {
98
99 private static final long serialVersionUID = 20161211L;
100
101
102
103
104
105
106
107
108
109
110
111
112 public Text(final BusStopData source, final Supplier<String> text, final float dx, final float dy,
113 final TextAlignment textPlacement, final Color color, final Contextualized contextualized)
114 throws RemoteException, NamingException
115 {
116 super(source, text, dx, dy, textPlacement, color, contextualized, TextAnimation.RENDERWHEN10);
117 }
118
119
120 @Override
121 public final String toString()
122 {
123 return "Text []";
124 }
125 }
126
127
128
129
130
131
132
133
134
135
136 public interface BusStopData extends LaneBasedObjectData
137 {
138 }
139
140 }