1 package org.opentrafficsim.animation.data;
2
3 import org.djutils.draw.bounds.Bounds2d;
4 import org.djutils.draw.line.Polygon2d;
5 import org.djutils.draw.point.DirectedPoint2d;
6 import org.opentrafficsim.base.geometry.OtsShape;
7 import org.opentrafficsim.draw.road.PriorityAnimation.PriorityData;
8 import org.opentrafficsim.road.network.lane.CrossSectionLink;
9
10
11
12
13
14
15
16
17
18 public class AnimationPriorityData implements PriorityData
19 {
20
21
22 private final CrossSectionLink link;
23
24
25 private final Bounds2d bounds = new Bounds2d(2.0, 2.0);
26
27
28 private final Polygon2d relativeContour;
29
30
31 private final Polygon2d absoluteContour;
32
33
34
35
36
37 public AnimationPriorityData(final CrossSectionLink link)
38 {
39 this.link = link;
40 this.absoluteContour = OtsShape.boundsAsAbsoluteContour(this);
41 this.relativeContour =
42 new Polygon2d(OtsShape.toRelativeTransform(getLocation()).transform(this.absoluteContour.iterator()));
43 }
44
45 @Override
46 public DirectedPoint2d getLocation()
47 {
48 return this.link.getDesignLine().getLocationFractionExtended(0.5);
49 }
50
51 @Override
52 public Polygon2d getAbsoluteContour()
53 {
54 return this.absoluteContour;
55 }
56
57 @Override
58 public Polygon2d getRelativeContour()
59 {
60 return this.relativeContour;
61 }
62
63 @Override
64 public Bounds2d getRelativeBounds()
65 {
66 return this.bounds;
67 }
68
69 @Override
70 public boolean isAllStop()
71 {
72 return this.link.getPriority().isAllStop();
73 }
74
75 @Override
76 public boolean isBusStop()
77 {
78 return this.link.getPriority().isBusStop();
79 }
80
81 @Override
82 public boolean isNone()
83 {
84 return this.link.getPriority().isNone();
85 }
86
87 @Override
88 public boolean isPriority()
89 {
90 return this.link.getPriority().isPriority();
91 }
92
93 @Override
94 public boolean isStop()
95 {
96 return this.link.getPriority().isStop();
97 }
98
99 @Override
100 public boolean isYield()
101 {
102 return this.link.getPriority().isYield();
103 }
104
105 @Override
106 public String toString()
107 {
108 return "Priority " + this.link.getId();
109 }
110
111 }