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