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