1 package org.opentrafficsim.animation.data;
2
3 import java.awt.Color;
4 import java.awt.geom.RectangularShape;
5
6 import org.djunits.value.vdouble.scalar.Length;
7 import org.djutils.draw.bounds.Bounds2d;
8 import org.djutils.draw.line.Polygon2d;
9 import org.djutils.draw.point.OrientedPoint2d;
10 import org.opentrafficsim.animation.gtu.colorer.GtuColorerManager;
11 import org.opentrafficsim.base.geometry.OtsShape;
12 import org.opentrafficsim.draw.gtu.DefaultCarAnimation.GtuData;
13 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
14
15
16
17
18
19
20
21
22
23 public class AnimationGtuData implements GtuData
24 {
25
26
27 private final GtuColorerManager gtuColorerManager;
28
29
30 private final LaneBasedGtu gtu;
31
32
33 private final GtuMarker marker;
34
35
36
37
38
39
40
41 public AnimationGtuData(final GtuColorerManager gtuColorerManager, final LaneBasedGtu gtu, final GtuMarker marker)
42 {
43 this.gtuColorerManager = gtuColorerManager;
44 this.gtu = gtu;
45 this.marker = marker;
46 }
47
48 @Override
49 public OrientedPoint2d getLocation()
50 {
51 return this.gtu.getLocation();
52 }
53
54 @Override
55 public Polygon2d getContour()
56 {
57 return this.gtu.getContour();
58 }
59
60 @Override
61 public Bounds2d getBounds()
62 {
63 return this.gtu.getBounds();
64 }
65
66 @Override
67 public OtsShape getShape()
68 {
69 return this.gtu.getShape();
70 }
71
72 @Override
73 public String getId()
74 {
75 return this.gtu.getId();
76 }
77
78 @Override
79 public Color getColor()
80 {
81 return this.gtuColorerManager.getColor(this.gtu);
82 }
83
84 @Override
85 public Length getLength()
86 {
87 return this.gtu.getLength();
88 }
89
90 @Override
91 public Length getWidth()
92 {
93 return this.gtu.getWidth();
94 }
95
96 @Override
97 public Length getFront()
98 {
99 return this.gtu.getFront().dx();
100 }
101
102 @Override
103 public Length getRear()
104 {
105 return this.gtu.getRear().dx();
106 }
107
108 @Override
109 public boolean leftIndicatorOn()
110 {
111 return this.gtu.getTurnIndicatorStatus().isLeftOrBoth();
112 }
113
114 @Override
115 public boolean rightIndicatorOn()
116 {
117 return this.gtu.getTurnIndicatorStatus().isRightOrBoth();
118 }
119
120 @Override
121 public RectangularShape getMarker()
122 {
123 return this.marker.getShape();
124 }
125
126 @Override
127 public boolean isBrakingLightsOn()
128 {
129 return this.gtu.isBrakingLightsOn();
130 }
131
132
133
134
135
136 public LaneBasedGtu getGtu()
137 {
138 return this.gtu;
139 }
140
141 @Override
142 public String toString()
143 {
144 return "Gtu " + this.gtu.getId();
145 }
146
147 }