View Javadoc

1   /*
2    * @(#)VehicleType.java Jun 14, 2004
3    * 
4    * Copyright (c) 2003, 2004 Delft University of Technology Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  
11  package nl.tudelft.simulation.traffic.vehicle;
12  
13  import java.awt.Color;
14  import java.util.ArrayList;
15  
16  /***
17   * The data of a vehicle that can be generated or constructed. <br>
18   * <br>
19   * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
20   * University of Technology </a>, the Netherlands. <br>
21   * See for project information <a href="http://www.simulation.tudelft.nl">
22   * www.simulation.tudelft.nl </a> <br>
23   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General
24   * Public License (GPL) </a>, no warranty <br>
25   * 
26   * @version Jun 14, 2004 <br>
27   * @author <a
28   * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
29   * Verbraeck </a>
30   */
31  public class VehicleType
32  {
33      /*** the name of the vehicle */
34      private String name;
35  
36      /*** the total length of the vehicle */
37      private double length;
38  
39      /*** the width of the vehicle */
40      private double width;
41  
42      /*** the color of the vehicle in the animation */
43      private Color color;
44  
45      /*** the segment information */
46      private ArrayList segments = new ArrayList();
47  
48      /*** the sequence number */
49      private int number = 0;
50  
51      /*** vehicle maximum speed */
52      private double vehicleMaximumSpeed;
53  
54      /*** the acceleration profile */
55      private AccelerationProfile accelerationProfile;
56  
57      /*** the deceleration profile */
58      private DecelerationProfile decelerationProfile;
59  
60      /***
61       * Create a new vehicle type
62       */
63      public VehicleType()
64      {
65          super();
66      }
67  
68      /***
69       * @return Returns the color.
70       */
71      public Color getColor()
72      {
73          return this.color;
74      }
75  
76      /***
77       * @param color The color to set.
78       */
79      public void setColor(Color color)
80      {
81          this.color = color;
82      }
83  
84      /***
85       * @return Returns the length.
86       */
87      public double getLength()
88      {
89          return this.length;
90      }
91  
92      /***
93       * @param length The length to set.
94       */
95      public void setLength(double length)
96      {
97          this.length = length;
98      }
99  
100     /***
101      * @return Returns the name.
102      */
103     public String getName()
104     {
105         return this.name;
106     }
107 
108     /***
109      * @param name The name to set.
110      */
111     public void setName(String name)
112     {
113         this.name = name;
114     }
115 
116     /***
117      * @return Returns the width.
118      */
119     public double getWidth()
120     {
121         return this.width;
122     }
123 
124     /***
125      * @param width The width to set.
126      */
127     public void setWidth(double width)
128     {
129         this.width = width;
130     }
131 
132     /***
133      * @param front
134      * @param axle1
135      * @param axle2
136      * @param length
137      */
138     public void addSegment(final double front, final double axle1,
139             final double axle2, final double length)
140     {
141         Segment segment = new Segment(front, axle1, axle2, length);
142         this.segments.add(segment);
143     }
144 
145     /***
146      * @return Returns the segments.
147      */
148     public ArrayList getSegments()
149     {
150         return this.segments;
151     }
152 
153     /***
154      * @return Returns the vehicleMaximumSpeed.
155      */
156     public double getVehicleMaximumSpeed()
157     {
158         return this.vehicleMaximumSpeed;
159     }
160 
161     /***
162      * @param vehicleMaximumSpeed The vehicleMaximumSpeed to set.
163      */
164     public void setVehicleMaximumSpeed(double vehicleMaximumSpeed)
165     {
166         this.vehicleMaximumSpeed = vehicleMaximumSpeed;
167     }
168 
169     /***
170      * @return Returns the accelerationProfile.
171      */
172     public AccelerationProfile getAccelerationProfile()
173     {
174         return this.accelerationProfile;
175     }
176 
177     /***
178      * @param accelerationProfile The accelerationProfile to set.
179      */
180     public void setAccelerationProfile(AccelerationProfile accelerationProfile)
181     {
182         this.accelerationProfile = accelerationProfile;
183         this.accelerationProfile.initializeProfile();
184     }
185 
186     /***
187      * @return Returns the decelerationProfile.
188      */
189     public DecelerationProfile getDecelerationProfile()
190     {
191         return this.decelerationProfile;
192     }
193 
194     /***
195      * @param decelerationProfile The decelerationProfile to set.
196      */
197     public void setDecelerationProfile(DecelerationProfile decelerationProfile)
198     {
199         this.decelerationProfile = decelerationProfile;
200         this.decelerationProfile.initializeProfile();
201     }
202 
203     /***
204      * @return a unique name for this type
205      */
206     public String generateUniqueName()
207     {
208         this.number++;
209         return this.name + "." + this.number;
210     }
211 
212     /***
213      * The segment information for a segmented vehicle.
214      * 
215      * <br>
216      * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
217      * University of Technology </a>, the Netherlands. <br>
218      * See for project information <a href="http://www.simulation.tudelft.nl">
219      * www.simulation.tudelft.nl </a> <br>
220      * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General
221      * Public License (GPL) </a>, no warranty <br>
222      * 
223      * @version Jun 20, 2004 <br>
224      * @author <a
225      * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
226      * Verbraeck </a>
227      */
228     public class Segment
229     {
230         /*** front delta to vehicle front */
231         private double front;
232 
233         /*** axle1 delta to vehicle front */
234         private double axle1;
235 
236         /*** axle2 delta to vehicle front */
237         private double axle2;
238 
239         /*** segment length */
240         private double length;
241 
242         /***
243          * @param front
244          * @param axle1
245          * @param axle2
246          * @param length
247          */
248         public Segment(final double front, final double axle1,
249                 final double axle2, final double length)
250         {
251             this.front = front;
252             this.axle1 = axle1;
253             this.axle2 = axle2;
254             this.length = length;
255         }
256 
257         /***
258          * @return Returns the axle1.
259          */
260         public double getAxle1()
261         {
262             return this.axle1;
263         }
264 
265         /***
266          * @return Returns the axle2.
267          */
268         public double getAxle2()
269         {
270             return this.axle2;
271         }
272 
273         /***
274          * @return Returns the front.
275          */
276         public double getFront()
277         {
278             return this.front;
279         }
280 
281         /***
282          * @return Returns the length.
283          */
284         public double getLength()
285         {
286             return this.length;
287         }
288     }
289 }