1 package org.opentrafficsim.swing.gui;
2
3 import org.opentrafficsim.core.gtu.GTU;
4 import org.opentrafficsim.core.network.OTSLink;
5 import org.opentrafficsim.core.network.OTSNode;
6 import org.opentrafficsim.draw.gtu.DefaultCarAnimation;
7 import org.opentrafficsim.draw.gtu.GtuGeneratorQueueAnimation;
8 import org.opentrafficsim.draw.network.LinkAnimation;
9 import org.opentrafficsim.draw.network.NodeAnimation;
10 import org.opentrafficsim.draw.road.BusStopAnimation;
11 import org.opentrafficsim.draw.road.LaneAnimation;
12 import org.opentrafficsim.draw.road.LaneAnimation.CenterLine;
13 import org.opentrafficsim.draw.road.SensorAnimation;
14 import org.opentrafficsim.draw.road.TrafficLightAnimation;
15 import org.opentrafficsim.road.network.lane.Lane;
16 import org.opentrafficsim.road.network.lane.Shoulder;
17 import org.opentrafficsim.road.network.lane.Stripe;
18 import org.opentrafficsim.road.network.lane.conflict.Conflict;
19 import org.opentrafficsim.road.network.lane.object.BusStop;
20 import org.opentrafficsim.road.network.lane.object.sensor.Sensor;
21 import org.opentrafficsim.road.network.lane.object.sensor.SingleSensor;
22 import org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight;
23
24 import nl.tudelft.simulation.dsol.animation.Locatable;
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public final class AnimationToggles
39 {
40
41
42
43
44 private AnimationToggles()
45 {
46
47 }
48
49
50
51
52
53 public static void setTextAnimationTogglesFull(final OTSAnimationPanel panel)
54 {
55 panel.addToggleAnimationButtonText("Node", NodeAnimation.ElevatedNode.class, "Show/hide nodes", true);
56 panel.addToggleAnimationButtonText("NodeId", NodeAnimation.Text.class, "Show/hide node Ids", false);
57 panel.addToggleAnimationButtonText("Link", OTSLink.class, "Show/hide links", true);
58 panel.addToggleAnimationButtonText("LinkId", LinkAnimation.Text.class, "Show/hide link Ids", false);
59 panel.addToggleAnimationButtonText("Lane", Lane.class, "Show/hide lanes", true);
60 panel.addToggleAnimationButtonText("LaneId", LaneAnimation.Text.class, "Show/hide lane Ids", false);
61 panel.addToggleAnimationButtonText("LaneCenter", LaneAnimation.CenterLine.class, "Show/hide lane center lines", false);
62 panel.addToggleAnimationButtonText("Stripe", Stripe.class, "Show/hide stripes", true);
63 panel.addToggleAnimationButtonText("Shoulder", Shoulder.class, "Show/hide shoulders", true);
64 panel.addToggleAnimationButtonText("GTU", GTU.class, "Show/hide GTUs", true);
65 panel.addToggleAnimationButtonText("GTUId", DefaultCarAnimation.Text.class, "Show/hide GTU Ids", false);
66 panel.addToggleAnimationButtonText("Sensor", SingleSensor.class, "Show/hide sensors", true);
67 panel.addToggleAnimationButtonText("SensorId", SensorAnimation.Text.class, "Show/hide sensors Ids", false);
68 panel.addToggleAnimationButtonText("Light", TrafficLight.class, "Show/hide traffic lights", true);
69 panel.addToggleAnimationButtonText("LightId", TrafficLightAnimation.Text.class, "Show/hide sensors Ids", false);
70 panel.addToggleAnimationButtonText("Conflict", Conflict.class, "Show/hide conflicts", false);
71 panel.addToggleAnimationButtonText("Generator", GtuGeneratorQueueAnimation.class, "Show/hide generators", false);
72 panel.addToggleAnimationButtonText("Bus", BusStop.class, "Show/hide bus stops", false);
73 panel.addToggleAnimationButtonText("BusId", BusStopAnimation.Text.class, "Show/hide bus stop Ids", false);
74 }
75
76
77
78
79
80 public static void setTextAnimationTogglesStandard(final OTSAnimationPanel panel)
81 {
82 panel.addToggleAnimationButtonText("Node", NodeAnimation.ElevatedNode.class, "Show/hide nodes", false);
83 panel.addToggleAnimationButtonText("NodeId", NodeAnimation.Text.class, "Show/hide node Ids", false);
84 panel.addToggleAnimationButtonText("Link", OTSLink.class, "Show/hide links", false);
85 panel.addToggleAnimationButtonText("LinkId", LinkAnimation.Text.class, "Show/hide link Ids", false);
86 panel.addToggleAnimationButtonText("Lane", Lane.class, "Show/hide lanes", true);
87 panel.addToggleAnimationButtonText("LaneId", LaneAnimation.Text.class, "Show/hide lane Ids", false);
88 panel.addToggleAnimationButtonText("LaneCenter", LaneAnimation.CenterLine.class, "Show/hide lane center lines", false);
89 panel.addToggleAnimationButtonText("Stripe", Stripe.class, "Show/hide stripes", true);
90 panel.addToggleAnimationButtonText("Shoulder", Shoulder.class, "Show/hide shoulders", true);
91 panel.addToggleAnimationButtonText("GTU", GTU.class, "Show/hide GTUs", true);
92 panel.addToggleAnimationButtonText("GTUId", DefaultCarAnimation.Text.class, "Show/hide GTU Ids", false);
93 panel.addToggleAnimationButtonText("Sensor", Sensor.class, "Show/hide sensors", false);
94 panel.addToggleAnimationButtonText("SensorId", SensorAnimation.Text.class, "Show/hide sensors Ids", false);
95 panel.addToggleAnimationButtonText("Light", TrafficLight.class, "Show/hide traffic lights", true);
96 panel.addToggleAnimationButtonText("LightId", TrafficLightAnimation.Text.class, "Show/hide sensors Ids", false);
97 panel.addToggleAnimationButtonText("Conflict", Conflict.class, "Show/hide conflicts", false);
98 panel.addToggleAnimationButtonText("Generator", GtuGeneratorQueueAnimation.class, "Show/hide generators", false);
99 }
100
101
102
103
104
105 public static void setIconAnimationTogglesFull(final OTSAnimationPanel panel)
106 {
107 panel.addToggleAnimationButtonIcon("Node", NodeAnimation.ElevatedNode.class, "/icons/Node24.png", "Show/hide nodes",
108 true, false);
109 panel.addToggleAnimationButtonIcon("NodeId", NodeAnimation.Text.class, "/icons/Id24.png", "Show/hide node Ids", false,
110 true);
111 panel.addToggleAnimationButtonIcon("Link", OTSLink.class, "/icons/Link24.png", "Show/hide links", true, false);
112 panel.addToggleAnimationButtonIcon("LinkId", LinkAnimation.Text.class, "/icons/Id24.png", "Show/hide link Ids", false,
113 true);
114 panel.addToggleAnimationButtonIcon("Lane", Lane.class, "/icons/Lane24.png", "Show/hide lanes", true, false);
115 panel.addToggleAnimationButtonIcon("LaneId", LaneAnimation.Text.class, "/icons/Id24.png", "Show/hide lane Ids", false,
116 true);
117 panel.addToggleAnimationButtonIcon("LaneCenter", CenterLine.class, "/icons/CenterLine24.png", "Show/hide lane center lines",
118 false, false);
119 panel.addToggleAnimationButtonIcon("Stripe", Stripe.class, "/icons/Stripe24.png", "Show/hide stripes", true, false);
120 panel.addToggleAnimationButtonIcon("Shoulder", Shoulder.class, "/icons/Shoulder24.png", "Show/hide shoulders", true,
121 false);
122 panel.addToggleAnimationButtonIcon("GTU", GTU.class, "/icons/Gtu24.png", "Show/hide GTUs", true, false);
123 panel.addToggleAnimationButtonIcon("GTUId", DefaultCarAnimation.Text.class, "/icons/Id24.png", "Show/hide GTU Ids",
124 false, true);
125 panel.addToggleAnimationButtonIcon("Sensor", Sensor.class, "/icons/Sensor24.png", "Show/hide sensors", true, false);
126 panel.addToggleAnimationButtonIcon("SensorId", SensorAnimation.Text.class, "/icons/Id24.png", "Show/hide sensors Ids",
127 false, true);
128 panel.addToggleAnimationButtonIcon("Light", TrafficLight.class, "/icons/TrafficLight24.png", "Show/hide traffic lights",
129 true, false);
130 panel.addToggleAnimationButtonIcon("LightId", TrafficLightAnimation.Text.class, "/icons/Id24.png",
131 "Show/hide sensors Ids", false, true);
132 panel.addToggleAnimationButtonIcon("Conflict", Conflict.class, "/icons/Conflict24.png", "Show/hide conflicts", false,
133 false);
134 panel.addToggleAnimationButtonIcon("Generator", GtuGeneratorQueueAnimation.class, "/icons/Generator24.png",
135 "Show/hide generators", false, false);
136 panel.addToggleAnimationButtonIcon("Bus", BusStop.class, "/icons/BusStop24.png", "Show/hide bus stops", true, false);
137 panel.addToggleAnimationButtonIcon("BusId", BusStopAnimation.Text.class, "/icons/Id24.png", "Show/hide bus stops",
138 false, true);
139 }
140
141
142
143
144
145 public static void setIconAnimationTogglesStandard(final OTSAnimationPanel panel)
146 {
147 panel.addToggleAnimationButtonIcon("Node", NodeAnimation.ElevatedNode.class, "/icons/Node24.png", "Show/hide nodes",
148 false, false);
149 panel.addToggleAnimationButtonIcon("NodeId", NodeAnimation.Text.class, "/icons/Id24.png", "Show/hide node Ids", false,
150 true);
151 panel.addToggleAnimationButtonIcon("Link", OTSLink.class, "/icons/Link24.png", "Show/hide links", false, false);
152 panel.addToggleAnimationButtonIcon("LinkId", LinkAnimation.Text.class, "/icons/Id24.png", "Show/hide link Ids", false,
153 true);
154 panel.addToggleAnimationButtonIcon("Lane", Lane.class, "/icons/Lane24.png", "Show/hide lanes", true, false);
155 panel.addToggleAnimationButtonIcon("LaneId", LaneAnimation.Text.class, "/icons/Id24.png", "Show/hide lane Ids", false,
156 true);
157 panel.addToggleAnimationButtonIcon("LaneCenter", CenterLine.class, "/icons/CenterLine24.png", "Show/hide lane center lines",
158 false, false);
159 panel.addToggleAnimationButtonIcon("Stripe", Stripe.class, "/icons/Stripe24.png", "Show/hide stripes", true, false);
160 panel.addToggleAnimationButtonIcon("Shoulder", Shoulder.class, "/icons/Shoulder24.png", "Show/hide shoulders", true,
161 false);
162 panel.addToggleAnimationButtonIcon("GTU", GTU.class, "/icons/Gtu24.png", "Show/hide GTUs", true, false);
163 panel.addToggleAnimationButtonIcon("GTUId", DefaultCarAnimation.Text.class, "/icons/Id24.png", "Show/hide GTU Ids",
164 false, true);
165 panel.addToggleAnimationButtonIcon("Sensor", Sensor.class, "/icons/Sensor24.png", "Show/hide sensors", false, false);
166 panel.addToggleAnimationButtonIcon("SensorId", SensorAnimation.Text.class, "/icons/Id24.png", "Show/hide sensors Ids",
167 false, true);
168 panel.addToggleAnimationButtonIcon("Light", TrafficLight.class, "/icons/TrafficLight24.png", "Show/hide traffic lights",
169 true, false);
170 panel.addToggleAnimationButtonIcon("LightId", TrafficLightAnimation.Text.class, "/icons/Id24.png",
171 "Show/hide sensors Ids", false, true);
172 panel.addToggleAnimationButtonIcon("Conflict", Conflict.class, "/icons/Conflict24.png", "Show/hide conflicts", false,
173 false);
174 panel.addToggleAnimationButtonIcon("Generator", GtuGeneratorQueueAnimation.class, "/icons/Generator24.png",
175 "Show/hide generators", false, false);
176 panel.addToggleAnimationButtonIcon("Bus", BusStop.class, "/icons/BusStop24.png", "Show/hide bus stops", false, false);
177 panel.addToggleAnimationButtonIcon("BusId", BusStopAnimation.Text.class, "/icons/Id24.png", "Show/hide bus stops",
178 false, true);
179 }
180
181
182
183
184
185
186 public static void showAnimationClass(final OTSAnimationPanel panel, final Class<? extends Locatable> locatableClass)
187 {
188 panel.getAnimationPanel().showClass(locatableClass);
189 panel.updateAnimationClassCheckBox(locatableClass);
190 }
191
192
193
194
195
196
197 public static void hideAnimationClass(final OTSAnimationPanel panel, final Class<? extends Locatable> locatableClass)
198 {
199 panel.getAnimationPanel().hideClass(locatableClass);
200 panel.updateAnimationClassCheckBox(locatableClass);
201 }
202
203
204
205
206
207 public static void showAnimationFull(final OTSAnimationPanel panel)
208 {
209 showAnimationClass(panel, OTSNode.class);
210 hideAnimationClass(panel, NodeAnimation.Text.class);
211 showAnimationClass(panel, OTSLink.class);
212 hideAnimationClass(panel, LinkAnimation.Text.class);
213 showAnimationClass(panel, Lane.class);
214 hideAnimationClass(panel, LaneAnimation.Text.class);
215 showAnimationClass(panel, Stripe.class);
216 showAnimationClass(panel, Shoulder.class);
217 showAnimationClass(panel, GTU.class);
218 hideAnimationClass(panel, DefaultCarAnimation.Text.class);
219 showAnimationClass(panel, SingleSensor.class);
220 hideAnimationClass(panel, SensorAnimation.Text.class);
221 showAnimationClass(panel, TrafficLight.class);
222 hideAnimationClass(panel, TrafficLightAnimation.Text.class);
223 showAnimationClass(panel, Conflict.class);
224 hideAnimationClass(panel, BusStop.class);
225 hideAnimationClass(panel, BusStopAnimation.Text.class);
226 showAnimationClass(panel, GtuGeneratorQueueAnimation.class);
227 }
228
229
230
231
232
233 public static void showAnimationStandard(final OTSAnimationPanel panel)
234 {
235 hideAnimationClass(panel, OTSNode.class);
236 hideAnimationClass(panel, NodeAnimation.Text.class);
237 hideAnimationClass(panel, OTSLink.class);
238 hideAnimationClass(panel, LinkAnimation.Text.class);
239 showAnimationClass(panel, Lane.class);
240 hideAnimationClass(panel, LaneAnimation.Text.class);
241 showAnimationClass(panel, Stripe.class);
242 showAnimationClass(panel, Shoulder.class);
243 showAnimationClass(panel, GTU.class);
244 hideAnimationClass(panel, DefaultCarAnimation.Text.class);
245 hideAnimationClass(panel, SingleSensor.class);
246 hideAnimationClass(panel, SensorAnimation.Text.class);
247 showAnimationClass(panel, TrafficLight.class);
248 hideAnimationClass(panel, TrafficLightAnimation.Text.class);
249 hideAnimationClass(panel, Conflict.class);
250 hideAnimationClass(panel, BusStop.class);
251 hideAnimationClass(panel, BusStopAnimation.Text.class);
252 hideAnimationClass(panel, GtuGeneratorQueueAnimation.class);
253 }
254
255 }