1
2
3
4
5
6
7
8
9
10
11 package nl.tudelft.simulation.traffic.controlpoint.virtual;
12
13 import java.rmi.RemoteException;
14 import javax.media.j3d.Bounds;
15 import javax.vecmath.Point3d;
16 import nl.tudelft.simulation.dsol.simulators.AnimatorInterface;
17 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
18 import nl.tudelft.simulation.event.EventProducer;
19 import nl.tudelft.simulation.language.d3.BoundingBox;
20 import nl.tudelft.simulation.language.d3.DirectedPoint;
21 import nl.tudelft.simulation.traffic.animation.ControlPointAnimation;
22 import nl.tudelft.simulation.traffic.track.TrackInterface;
23 import nl.tudelft.simulation.traffic.track.util.TrackProgression;
24
25 /***
26 */
27 public abstract class VirtualControlPoint extends EventProducer
28 implements
29 VirtualControlPointInterface
30 {
31 /*** location of the control point in terms of progression */
32 private double progression;
33
34 /*** track on which the control point lies */
35 private TrackInterface track;
36
37 /*** the location of the control point */
38 private DirectedPoint location;
39
40 /***
41 * @param track
42 * @param progression
43 * @param simulator
44 */
45 public VirtualControlPoint(final TrackInterface track,
46 final double progression, final SimulatorInterface simulator)
47 {
48 TrackProgression tp = track
49 .calculateTrackProgressionListActive(progression);
50 this.track = tp.getTrack();
51 this.progression = tp.getProgression();
52 this.location = this.track.getLocationOfProgression(this.progression);
53 this.location.setRotZ(0.0);
54 this.track.addControlPoint(this);
55
56 if (simulator instanceof AnimatorInterface)
57 {
58 new ControlPointAnimation(this, simulator);
59 }
60 }
61
62 /***
63 * @see nl.tudelft.simulation.traffic.controlpoint.ControlPointInterface#getProgression()
64 */
65 public double getProgression()
66 {
67 return this.progression;
68 }
69
70 /***
71 * @see nl.tudelft.simulation.traffic.controlpoint.ControlPointInterface#getTrack()
72 */
73 public TrackInterface getTrack()
74 {
75 return this.track;
76 }
77
78 /***
79 * @see nl.tudelft.simulation.dsol.animation.LocatableInterface#getBounds()
80 */
81 public Bounds getBounds() throws RemoteException
82 {
83 return new BoundingBox(new Point3d(-0.1, -0.1, 0), new Point3d(0.1,
84 0.1, 0));
85 }
86
87 /***
88 * @see nl.tudelft.simulation.dsol.animation.LocatableInterface#getLocation()
89 */
90 public DirectedPoint getLocation() throws RemoteException
91 {
92 return this.location;
93 }
94 }