1 package org.opentrafficsim.road.gtu.animation;
2
3 import java.awt.Color;
4 import java.util.ArrayList;
5 import java.util.List;
6
7 import org.opentrafficsim.core.gtu.GTU;
8 import org.opentrafficsim.core.gtu.animation.GTUColorer;
9 import org.opentrafficsim.core.gtu.plan.tactical.TacticalPlanner;
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public class BlockingColorer implements GTUColorer
24 {
25
26
27 private static final Color BLOCKING = Color.RED;
28
29
30 private static final Color NOT_BLOCKING = Color.WHITE;
31
32
33 private static final List<LegendEntry> LEGEND = new ArrayList<>();
34
35 static
36 {
37 LEGEND.add(new LegendEntry(Color.RED, "Not blocking", "Not blocking"));
38 LEGEND.add(new LegendEntry(Color.WHITE, "Blocking", "Blocking"));
39 }
40
41
42 @Override
43 public List<LegendEntry> getLegend()
44 {
45 return LEGEND;
46 }
47
48
49 @Override
50 public Color getColor(final GTU gtu)
51 {
52 TacticalPlanner<?, ?> tact = gtu.getTacticalPlanner();
53 if (tact instanceof Blockable && ((Blockable) tact).isBlocking())
54 {
55 return BLOCKING;
56 }
57 return NOT_BLOCKING;
58 }
59
60
61 @Override
62 public String toString()
63 {
64 return "Blocking";
65 }
66
67 }