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