1 package org.opentrafficsim.web.animation;
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.CrossSectionElementData;
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.LaneData;
18 import org.opentrafficsim.draw.road.StripeAnimation.StripeData;
19 import org.opentrafficsim.draw.road.TrafficLightAnimation;
20 import org.opentrafficsim.draw.road.TrafficLightAnimation.TrafficLightData;
21
22 import nl.tudelft.simulation.dsol.animation.Locatable;
23 import nl.tudelft.simulation.dsol.web.animation.d2.HtmlAnimationPanel;
24
25
26
27
28
29
30
31
32
33
34
35 public final class WebAnimationToggles
36 {
37
38
39
40 private WebAnimationToggles()
41 {
42
43 }
44
45
46
47
48
49 public static void setTextAnimationTogglesFull(final HtmlAnimationPanel panel)
50 {
51 panel.addToggleAnimationButtonText("Node", NodeData.class, "Show/hide nodes", true);
52 panel.addToggleAnimationButtonText("NodeId", NodeAnimation.Text.class, "Show/hide node Ids", false);
53 panel.addToggleAnimationButtonText("Link", LinkData.class, "Show/hide links", true);
54 panel.addToggleAnimationButtonText("LinkId", LinkAnimation.Text.class, "Show/hide link Ids", false);
55 panel.addToggleAnimationButtonText("Lane", LaneData.class, "Show/hide lanes", true);
56 panel.addToggleAnimationButtonText("LaneId", LaneAnimation.Text.class, "Show/hide lane Ids", false);
57 panel.addToggleAnimationButtonText("LaneCenter", LaneAnimation.CenterLine.class, "Show/hide lane center lines", false);
58 panel.addToggleAnimationButtonText("Stripe", StripeData.class, "Show/hide stripes", true);
59 panel.addToggleAnimationButtonText("Shoulder", CrossSectionElementData.class, "Show/hide shoulders", true);
60 panel.addToggleAnimationButtonText("GTU", GtuData.class, "Show/hide GTUs", true);
61 panel.addToggleAnimationButtonText("GTUId", DefaultCarAnimation.Text.class, "Show/hide GTU Ids", false);
62 panel.addToggleAnimationButtonText("Detector", DetectorData.class, "Show/hide detector", true);
63 panel.addToggleAnimationButtonText("DetectorId", DetectorData.Text.class, "Show/hide detector Ids", false);
64 panel.addToggleAnimationButtonText("Light", TrafficLightData.class, "Show/hide traffic lights", true);
65 panel.addToggleAnimationButtonText("LightId", TrafficLightAnimation.Text.class, "Show/hide traffic light Ids", false);
66 panel.addToggleAnimationButtonText("Conflict", ConflictData.class, "Show/hide conflicts", false);
67 panel.addToggleAnimationButtonText("Generator", GtuGeneratorPositionData.class, "Show/hide generators", false);
68 panel.addToggleAnimationButtonText("GeneratorQ", GtuGeneratorPositionAnimation.Queue.class,
69 "Show/hide generator queues", false);
70 panel.addToggleAnimationButtonText("Bus", BusStopData.class, "Show/hide bus stops", false);
71 panel.addToggleAnimationButtonText("BusId", BusStopAnimation.Text.class, "Show/hide bus stop Ids", false);
72 }
73
74
75
76
77
78 public static void setTextAnimationTogglesStandard(final HtmlAnimationPanel panel)
79 {
80 panel.addToggleAnimationButtonText("Node", NodeData.class, "Show/hide nodes", false);
81 panel.addToggleAnimationButtonText("NodeId", NodeAnimation.Text.class, "Show/hide node Ids", false);
82 panel.addToggleAnimationButtonText("Link", LinkData.class, "Show/hide links", false);
83 panel.addToggleAnimationButtonText("LinkId", LinkAnimation.Text.class, "Show/hide link Ids", false);
84 panel.addToggleAnimationButtonText("Lane", LaneData.class, "Show/hide lanes", true);
85 panel.addToggleAnimationButtonText("LaneId", LaneAnimation.Text.class, "Show/hide lane Ids", false);
86 panel.addToggleAnimationButtonText("LaneCenter", LaneAnimation.CenterLine.class, "Show/hide lane center lines", false);
87 panel.addToggleAnimationButtonText("Stripe", StripeData.class, "Show/hide stripes", true);
88 panel.addToggleAnimationButtonText("Shoulder", CrossSectionElementData.class, "Show/hide shoulders", true);
89 panel.addToggleAnimationButtonText("GTU", GtuData.class, "Show/hide GTUs", true);
90 panel.addToggleAnimationButtonText("GTUId", DefaultCarAnimation.Text.class, "Show/hide GTU Ids", false);
91 panel.addToggleAnimationButtonText("Detector", DetectorData.class, "Show/hide detector", false);
92 panel.addToggleAnimationButtonText("DetectorId", DetectorData.Text.class, "Show/hide detector Ids", false);
93 panel.addToggleAnimationButtonText("Light", TrafficLightData.class, "Show/hide traffic lights", true);
94 panel.addToggleAnimationButtonText("LightId", TrafficLightAnimation.Text.class, "Show/hide traffic light Ids", false);
95 panel.addToggleAnimationButtonText("Conflict", ConflictData.class, "Show/hide conflicts", false);
96 panel.addToggleAnimationButtonText("Generator", GtuGeneratorPositionData.class, "Show/hide generators", false);
97 panel.addToggleAnimationButtonText("GeneratorQ", GtuGeneratorPositionAnimation.Queue.class,
98 "Show/hide generator queues", false);
99 panel.addToggleAnimationButtonText("Bus", BusStopData.class, "Show/hide bus stops", false);
100 panel.addToggleAnimationButtonText("BusId", BusStopAnimation.Text.class, "Show/hide bus stop Ids", false);
101 }
102
103
104
105
106
107
108 public final static void showAnimationClass(final HtmlAnimationPanel panel, final Class<? extends Locatable> locatableClass)
109 {
110 panel.showClass(locatableClass);
111 }
112
113
114
115
116
117
118 public final static void hideAnimationClass(final HtmlAnimationPanel panel, final Class<? extends Locatable> locatableClass)
119 {
120 panel.hideClass(locatableClass);
121 }
122
123
124
125
126
127 public static void showAnimationFull(final HtmlAnimationPanel panel)
128 {
129 showAnimationClass(panel, NodeData.class);
130 hideAnimationClass(panel, NodeAnimation.Text.class);
131 showAnimationClass(panel, LinkData.class);
132 hideAnimationClass(panel, LinkAnimation.Text.class);
133 showAnimationClass(panel, LaneData.class);
134 hideAnimationClass(panel, LaneAnimation.Text.class);
135 hideAnimationClass(panel, LaneAnimation.CenterLine.class);
136 showAnimationClass(panel, StripeData.class);
137 showAnimationClass(panel, CrossSectionElementData.class);
138 showAnimationClass(panel, GtuData.class);
139 hideAnimationClass(panel, DefaultCarAnimation.Text.class);
140 showAnimationClass(panel, DetectorData.class);
141 hideAnimationClass(panel, DetectorData.Text.class);
142 showAnimationClass(panel, TrafficLightData.class);
143 hideAnimationClass(panel, TrafficLightAnimation.Text.class);
144 showAnimationClass(panel, ConflictData.class);
145 showAnimationClass(panel, GtuGeneratorPositionData.class);
146 hideAnimationClass(panel, GtuGeneratorPositionAnimation.Queue.class);
147 showAnimationClass(panel, BusStopData.class);
148 hideAnimationClass(panel, BusStopAnimation.Text.class);
149 }
150
151
152
153
154
155 public static void showAnimationStandard(final HtmlAnimationPanel panel)
156 {
157 hideAnimationClass(panel, NodeData.class);
158 hideAnimationClass(panel, NodeAnimation.Text.class);
159 hideAnimationClass(panel, LinkData.class);
160 hideAnimationClass(panel, LinkAnimation.Text.class);
161 showAnimationClass(panel, LaneData.class);
162 hideAnimationClass(panel, LaneAnimation.Text.class);
163 hideAnimationClass(panel, LaneAnimation.CenterLine.class);
164 showAnimationClass(panel, StripeData.class);
165 showAnimationClass(panel, CrossSectionElementData.class);
166 showAnimationClass(panel, GtuData.class);
167 hideAnimationClass(panel, DefaultCarAnimation.Text.class);
168 hideAnimationClass(panel, DetectorData.class);
169 hideAnimationClass(panel, DetectorData.Text.class);
170 showAnimationClass(panel, TrafficLightData.class);
171 hideAnimationClass(panel, TrafficLightAnimation.Text.class);
172 hideAnimationClass(panel, ConflictData.class);
173 hideAnimationClass(panel, GtuGeneratorPositionData.class);
174 hideAnimationClass(panel, GtuGeneratorPositionAnimation.Queue.class);
175 hideAnimationClass(panel, BusStopData.class);
176 hideAnimationClass(panel, BusStopAnimation.Text.class);
177 }
178
179 }