forked from RoboCup-SPL/GameController
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathTeamColors.java
100 lines (89 loc) · 2.44 KB
/
TeamColors.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package data.values;
import java.awt.*;
/**
* Created by rkessler on 2017-03-25.
*/
public enum TeamColors implements DocumentingMarkdown {
BLUE(0, Color.BLUE),
RED(1, Color.RED),
YELLOW(2, new Color(224, 200, 0)),
BLACK(3, Color.BLACK),
WHITE(4, Color.WHITE),
GREEN(5, new Color(0, 128, 0)),
ORANGE(6, new Color(255, 165, 0)),
PURPLE(7, new Color(128, 0, 128)),
BROWN(8, new Color(165, 42, 42)),
GRAY(9, new Color(128, 128, 128)),
UNKNOWN(255, new Color(0, 255, 255));
private byte byte_value;
private Color color;
TeamColors(int byte_value, Color color) {
this.byte_value = (byte) byte_value;
this.color = color;
}
public byte value() {
return byte_value;
}
public static TeamColors fromValue(byte b) {
for(TeamColors teamColor : TeamColors.values()){
if (teamColor.value() == b){
return teamColor;
}
}
System.out.println("Warning: Could not resolve Team Color byte.");
return UNKNOWN;
}
public String toString(){
switch (this) {
case BLUE:
return "blue";
case RED:
return"red";
case YELLOW:
return "yellow";
case BLACK:
return "black";
case WHITE:
return "white";
case GREEN:
return "green";
case ORANGE:
return "orange";
case PURPLE:
return "purple";
case BROWN:
return "brown";
case GRAY:
return "gray";
default:
return "undefined";
}
}
public static TeamColors fromColorName(final String colorName) {
switch (colorName) {
case "blue":
return BLUE;
case "red":
return RED;
case "yellow":
return YELLOW;
case "black":
return BLACK;
case "green":
return GREEN;
case "orange":
return ORANGE;
case "purple":
return PURPLE;
case "brown":
return BROWN;
case "gray":
return GRAY;
default:
return WHITE;
}
}
public Color colorValue() {
return this.color;
}
}