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