View Javadoc
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.SensorAnimation;
13  import org.opentrafficsim.draw.road.TrafficLightAnimation;
14  import org.opentrafficsim.road.network.lane.Lane;
15  import org.opentrafficsim.road.network.lane.Shoulder;
16  import org.opentrafficsim.road.network.lane.Stripe;
17  import org.opentrafficsim.road.network.lane.conflict.Conflict;
18  import org.opentrafficsim.road.network.lane.object.BusStop;
19  import org.opentrafficsim.road.network.lane.object.sensor.Sensor;
20  import org.opentrafficsim.road.network.lane.object.sensor.SingleSensor;
21  import org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight;
22  
23  import nl.tudelft.simulation.dsol.animation.Locatable;
24  
25  /**
26   * Set the default animation toggles for the animation panel.
27   * <p>
28   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
29   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
30   * </p>
31   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
32   * initial version Dec 11, 2016 <br>
33   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
34   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
35   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
36   */
37  public final class AnimationToggles
38  {
39  
40      /**
41       * Do not instantiate this class.
42       */
43      private AnimationToggles()
44      {
45          // static class.
46      }
47  
48      /**
49       * Set all animation on, and create the toggles on the left hand side.
50       * @param panel OTSAnimationPanel; the WrappableAnimation.
51       */
52      public static void setTextAnimationTogglesFull(final OTSAnimationPanel panel)
53      {
54          panel.addToggleAnimationButtonText("Node", NodeAnimation.ElevatedNode.class, "Show/hide nodes", true);
55          panel.addToggleAnimationButtonText("NodeId", NodeAnimation.Text.class, "Show/hide node Ids", false);
56          panel.addToggleAnimationButtonText("Link", OTSLink.class, "Show/hide links", true);
57          panel.addToggleAnimationButtonText("LinkId", LinkAnimation.Text.class, "Show/hide link Ids", false);
58          panel.addToggleAnimationButtonText("Lane", Lane.class, "Show/hide lanes", true);
59          panel.addToggleAnimationButtonText("LaneId", LaneAnimation.Text.class, "Show/hide lane Ids", false);
60          panel.addToggleAnimationButtonText("Stripe", Stripe.class, "Show/hide stripes", true);
61          panel.addToggleAnimationButtonText("Shoulder", Shoulder.class, "Show/hide shoulders", true);
62          panel.addToggleAnimationButtonText("GTU", GTU.class, "Show/hide GTUs", true);
63          panel.addToggleAnimationButtonText("GTUId", DefaultCarAnimation.Text.class, "Show/hide GTU Ids", false);
64          panel.addToggleAnimationButtonText("Sensor", SingleSensor.class, "Show/hide sensors", true);
65          panel.addToggleAnimationButtonText("SensorId", SensorAnimation.Text.class, "Show/hide sensors Ids", false);
66          panel.addToggleAnimationButtonText("Light", TrafficLight.class, "Show/hide traffic lights", true);
67          panel.addToggleAnimationButtonText("LightId", TrafficLightAnimation.Text.class, "Show/hide sensors Ids", false);
68          panel.addToggleAnimationButtonText("Conflict", Conflict.class, "Show/hide conflicts", false);
69          panel.addToggleAnimationButtonText("Generator", GtuGeneratorQueueAnimation.class, "Show/hide generators", false);
70          panel.addToggleAnimationButtonText("Bus", BusStop.class, "Show/hide bus stops", false);
71          panel.addToggleAnimationButtonText("BusId", BusStopAnimation.Text.class, "Show/hide bus stop Ids", false);
72      }
73  
74      /**
75       * Set the most common animation on, and create the toggles on the left hand side.
76       * @param panel OTSAnimationPanel; the WrappableAnimation.
77       */
78      public static void setTextAnimationTogglesStandard(final OTSAnimationPanel panel)
79      {
80          panel.addToggleAnimationButtonText("Node", NodeAnimation.ElevatedNode.class, "Show/hide nodes", false);
81          panel.addToggleAnimationButtonText("NodeId", NodeAnimation.Text.class, "Show/hide node Ids", false);
82          panel.addToggleAnimationButtonText("Link", OTSLink.class, "Show/hide links", false);
83          panel.addToggleAnimationButtonText("LinkId", LinkAnimation.Text.class, "Show/hide link Ids", false);
84          panel.addToggleAnimationButtonText("Lane", Lane.class, "Show/hide lanes", true);
85          panel.addToggleAnimationButtonText("LaneId", LaneAnimation.Text.class, "Show/hide lane Ids", false);
86          panel.addToggleAnimationButtonText("Stripe", Stripe.class, "Show/hide stripes", true);
87          panel.addToggleAnimationButtonText("Shoulder", Shoulder.class, "Show/hide shoulders", true);
88          panel.addToggleAnimationButtonText("GTU", GTU.class, "Show/hide GTUs", true);
89          panel.addToggleAnimationButtonText("GTUId", DefaultCarAnimation.Text.class, "Show/hide GTU Ids", false);
90          panel.addToggleAnimationButtonText("Sensor", Sensor.class, "Show/hide sensors", false);
91          panel.addToggleAnimationButtonText("SensorId", SensorAnimation.Text.class, "Show/hide sensors Ids", false);
92          panel.addToggleAnimationButtonText("Light", TrafficLight.class, "Show/hide traffic lights", true);
93          panel.addToggleAnimationButtonText("LightId", TrafficLightAnimation.Text.class, "Show/hide sensors Ids", false);
94          panel.addToggleAnimationButtonText("Conflict", Conflict.class, "Show/hide conflicts", false);
95          panel.addToggleAnimationButtonText("Generator", GtuGeneratorQueueAnimation.class, "Show/hide generators", false);
96      }
97  
98      /**
99       * Set all animation on, and create the toggles on the left hand side.
100      * @param panel OTSAnimationPanel; the WrappableAnimation.
101      */
102     public static void setIconAnimationTogglesFull(final OTSAnimationPanel panel)
103     {
104         panel.addToggleAnimationButtonIcon("Node", NodeAnimation.ElevatedNode.class, "/icons/Node24.png", "Show/hide nodes",
105                 true, false);
106         panel.addToggleAnimationButtonIcon("NodeId", NodeAnimation.Text.class, "/icons/Id24.png", "Show/hide node Ids", false,
107                 true);
108         panel.addToggleAnimationButtonIcon("Link", OTSLink.class, "/icons/Link24.png", "Show/hide links", true, false);
109         panel.addToggleAnimationButtonIcon("LinkId", LinkAnimation.Text.class, "/icons/Id24.png", "Show/hide link Ids", false,
110                 true);
111         panel.addToggleAnimationButtonIcon("Lane", Lane.class, "/icons/Lane24.png", "Show/hide lanes", true, false);
112         panel.addToggleAnimationButtonIcon("LaneId", LaneAnimation.Text.class, "/icons/Id24.png", "Show/hide lane Ids", false,
113                 true);
114         panel.addToggleAnimationButtonIcon("Stripe", Stripe.class, "/icons/Stripe24.png", "Show/hide stripes", true, false);
115         panel.addToggleAnimationButtonIcon("Shoulder", Shoulder.class, "/icons/Shoulder24.png", "Show/hide shoulders", true,
116                 false);
117         panel.addToggleAnimationButtonIcon("GTU", GTU.class, "/icons/Gtu24.png", "Show/hide GTUs", true, false);
118         panel.addToggleAnimationButtonIcon("GTUId", DefaultCarAnimation.Text.class, "/icons/Id24.png", "Show/hide GTU Ids",
119                 false, true);
120         panel.addToggleAnimationButtonIcon("Sensor", Sensor.class, "/icons/Sensor24.png", "Show/hide sensors", true, false);
121         panel.addToggleAnimationButtonIcon("SensorId", SensorAnimation.Text.class, "/icons/Id24.png", "Show/hide sensors Ids",
122                 false, true);
123         panel.addToggleAnimationButtonIcon("Light", TrafficLight.class, "/icons/TrafficLight24.png", "Show/hide traffic lights",
124                 true, false);
125         panel.addToggleAnimationButtonIcon("LightId", TrafficLightAnimation.Text.class, "/icons/Id24.png",
126                 "Show/hide sensors Ids", false, true);
127         panel.addToggleAnimationButtonIcon("Conflict", Conflict.class, "/icons/Conflict24.png", "Show/hide conflicts", false,
128                 false);
129         panel.addToggleAnimationButtonIcon("Generator", GtuGeneratorQueueAnimation.class, "/icons/Generator24.png",
130                 "Show/hide generators", false, false);
131         panel.addToggleAnimationButtonIcon("Bus", BusStop.class, "/icons/BusStop24.png", "Show/hide bus stops", true, false);
132         panel.addToggleAnimationButtonIcon("BusId", BusStopAnimation.Text.class, "/icons/Id24.png", "Show/hide bus stops",
133                 false, true);
134     }
135 
136     /**
137      * Set the most common animation on, and create the toggles on the left hand side.
138      * @param panel OTSAnimationPanel; the WrappableAnimation.
139      */
140     public static void setIconAnimationTogglesStandard(final OTSAnimationPanel panel)
141     {
142         panel.addToggleAnimationButtonIcon("Node", NodeAnimation.ElevatedNode.class, "/icons/Node24.png", "Show/hide nodes",
143                 false, false);
144         panel.addToggleAnimationButtonIcon("NodeId", NodeAnimation.Text.class, "/icons/Id24.png", "Show/hide node Ids", false,
145                 true);
146         panel.addToggleAnimationButtonIcon("Link", OTSLink.class, "/icons/Link24.png", "Show/hide links", false, false);
147         panel.addToggleAnimationButtonIcon("LinkId", LinkAnimation.Text.class, "/icons/Id24.png", "Show/hide link Ids", false,
148                 true);
149         panel.addToggleAnimationButtonIcon("Lane", Lane.class, "/icons/Lane24.png", "Show/hide lanes", true, false);
150         panel.addToggleAnimationButtonIcon("LaneId", LaneAnimation.Text.class, "/icons/Id24.png", "Show/hide lane Ids", false,
151                 true);
152         panel.addToggleAnimationButtonIcon("Stripe", Stripe.class, "/icons/Stripe24.png", "Show/hide stripes", true, false);
153         panel.addToggleAnimationButtonIcon("Shoulder", Shoulder.class, "/icons/Shoulder24.png", "Show/hide shoulders", true,
154                 false);
155         panel.addToggleAnimationButtonIcon("GTU", GTU.class, "/icons/Gtu24.png", "Show/hide GTUs", true, false);
156         panel.addToggleAnimationButtonIcon("GTUId", DefaultCarAnimation.Text.class, "/icons/Id24.png", "Show/hide GTU Ids",
157                 false, true);
158         panel.addToggleAnimationButtonIcon("Sensor", Sensor.class, "/icons/Sensor24.png", "Show/hide sensors", false, false);
159         panel.addToggleAnimationButtonIcon("SensorId", SensorAnimation.Text.class, "/icons/Id24.png", "Show/hide sensors Ids",
160                 false, true);
161         panel.addToggleAnimationButtonIcon("Light", TrafficLight.class, "/icons/TrafficLight24.png", "Show/hide traffic lights",
162                 true, false);
163         panel.addToggleAnimationButtonIcon("LightId", TrafficLightAnimation.Text.class, "/icons/Id24.png",
164                 "Show/hide sensors Ids", false, true);
165         panel.addToggleAnimationButtonIcon("Conflict", Conflict.class, "/icons/Conflict24.png", "Show/hide conflicts", false,
166                 false);
167         panel.addToggleAnimationButtonIcon("Generator", GtuGeneratorQueueAnimation.class, "/icons/Generator24.png",
168                 "Show/hide generators", false, false);
169         panel.addToggleAnimationButtonIcon("Bus", BusStop.class, "/icons/BusStop24.png", "Show/hide bus stops", false, false);
170         panel.addToggleAnimationButtonIcon("BusId", BusStopAnimation.Text.class, "/icons/Id24.png", "Show/hide bus stops",
171                 false, true);
172     }
173 
174     /**
175      * Set a class to be shown in the animation to true.
176      * @param panel OTSAnimationPanel; the OTSAnimationPanel where the animation of a class has to be switched off
177      * @param locatableClass Class&lt;? extends Locatable&gt;; the class for which the animation has to be shown.
178      */
179     public final static void showAnimationClass(final OTSAnimationPanel panel, final Class<? extends Locatable> locatableClass)
180     {
181         panel.getAnimationPanel().showClass(locatableClass);
182         panel.updateAnimationClassCheckBox(locatableClass);
183     }
184 
185     /**
186      * Set a class to be shown in the animation to false.
187      * @param panel OTSAnimationPanel; the OTSAnimationPanel where the animation of a class has to be switched off
188      * @param locatableClass Class&lt;? extends Locatable&gt;; the class for which the animation has to be shown.
189      */
190     public final static void hideAnimationClass(final OTSAnimationPanel panel, final Class<? extends Locatable> locatableClass)
191     {
192         panel.getAnimationPanel().hideClass(locatableClass);
193         panel.updateAnimationClassCheckBox(locatableClass);
194     }
195 
196     /**
197      * Set all animation on, and create the toggles on the left hand side.
198      * @param panel OTSAnimationPanel; the WrappableAnimation.
199      */
200     public static void showAnimationFull(final OTSAnimationPanel panel)
201     {
202         showAnimationClass(panel, OTSNode.class);
203         hideAnimationClass(panel, NodeAnimation.Text.class);
204         showAnimationClass(panel, OTSLink.class);
205         hideAnimationClass(panel, LinkAnimation.Text.class);
206         showAnimationClass(panel, Lane.class);
207         hideAnimationClass(panel, LaneAnimation.Text.class);
208         showAnimationClass(panel, Stripe.class);
209         showAnimationClass(panel, Shoulder.class);
210         showAnimationClass(panel, GTU.class);
211         hideAnimationClass(panel, DefaultCarAnimation.Text.class);
212         showAnimationClass(panel, SingleSensor.class);
213         hideAnimationClass(panel, SensorAnimation.Text.class);
214         showAnimationClass(panel, TrafficLight.class);
215         hideAnimationClass(panel, TrafficLightAnimation.Text.class);
216         showAnimationClass(panel, Conflict.class);
217         hideAnimationClass(panel, BusStop.class);
218         hideAnimationClass(panel, BusStopAnimation.Text.class);
219         showAnimationClass(panel, GtuGeneratorQueueAnimation.class);
220     }
221 
222     /**
223      * Set the most common animation on, and create the toggles on the left hand side.
224      * @param panel OTSAnimationPanel; the WrappableAnimation.
225      */
226     public static void showAnimationStandard(final OTSAnimationPanel panel)
227     {
228         hideAnimationClass(panel, OTSNode.class);
229         hideAnimationClass(panel, NodeAnimation.Text.class);
230         hideAnimationClass(panel, OTSLink.class);
231         hideAnimationClass(panel, LinkAnimation.Text.class);
232         showAnimationClass(panel, Lane.class);
233         hideAnimationClass(panel, LaneAnimation.Text.class);
234         showAnimationClass(panel, Stripe.class);
235         showAnimationClass(panel, Shoulder.class);
236         showAnimationClass(panel, GTU.class);
237         hideAnimationClass(panel, DefaultCarAnimation.Text.class);
238         hideAnimationClass(panel, SingleSensor.class);
239         hideAnimationClass(panel, SensorAnimation.Text.class);
240         showAnimationClass(panel, TrafficLight.class);
241         hideAnimationClass(panel, TrafficLightAnimation.Text.class);
242         hideAnimationClass(panel, Conflict.class);
243         hideAnimationClass(panel, BusStop.class);
244         hideAnimationClass(panel, BusStopAnimation.Text.class);
245         hideAnimationClass(panel, GtuGeneratorQueueAnimation.class);
246     }
247 
248 }