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.Point2d;
6 import org.opentrafficsim.base.geometry.OtsLocatable;
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 contour;
29
30
31
32
33
34 public AnimationPriorityData(final CrossSectionLink link)
35 {
36 this.link = link;
37 this.contour = OtsLocatable.boundsAsContour(this);
38 }
39
40 @Override
41 public Point2d getLocation()
42 {
43 return this.link.getDesignLine().getLocationFractionExtended(0.5);
44 }
45
46 @Override
47 public Polygon2d getContour()
48 {
49 return this.contour;
50 }
51
52 @Override
53 public Bounds2d getBounds()
54 {
55 return this.bounds;
56 }
57
58 @Override
59 public boolean isAllStop()
60 {
61 return this.link.getPriority().isAllStop();
62 }
63
64 @Override
65 public boolean isBusStop()
66 {
67 return this.link.getPriority().isBusStop();
68 }
69
70 @Override
71 public boolean isNone()
72 {
73 return this.link.getPriority().isNone();
74 }
75
76 @Override
77 public boolean isPriority()
78 {
79 return this.link.getPriority().isPriority();
80 }
81
82 @Override
83 public boolean isStop()
84 {
85 return this.link.getPriority().isStop();
86 }
87
88 @Override
89 public boolean isYield()
90 {
91 return this.link.getPriority().isYield();
92 }
93
94 @Override
95 public String toString()
96 {
97 return "Priority " + this.link.getId();
98 }
99
100 }