|
@@ -39,9 +39,9 @@ import static com.dmdirc.util.LogUtils.USER_ERROR;
|
39
|
39
|
* The colour manager manages the colour scheme for the IRC client. It allows other components to
|
40
|
40
|
* use IRC colour codes instead of absolute colours.
|
41
|
41
|
*/
|
42
|
|
-public class ColourManager {
|
|
42
|
+public class ColourManagerImpl implements ColourManager {
|
43
|
43
|
|
44
|
|
- private static final Logger LOG = LoggerFactory.getLogger(ColourManager.class);
|
|
44
|
+ private static final Logger LOG = LoggerFactory.getLogger(ColourManagerImpl.class);
|
45
|
45
|
/** Default colours used for the standard 16 IRC colours. */
|
46
|
46
|
private static final Colour[] DEFAULT_COLOURS = {
|
47
|
47
|
Colour.WHITE, Colour.BLACK, new Colour(0, 0, 127), new Colour(0, 141, 0),
|
|
@@ -56,11 +56,11 @@ public class ColourManager {
|
56
|
56
|
private final Colour[] ircColours = DEFAULT_COLOURS.clone();
|
57
|
57
|
|
58
|
58
|
/**
|
59
|
|
- * Creates a new instance of {@link ColourManager}.
|
|
59
|
+ * Creates a new instance of {@link ColourManagerImpl}.
|
60
|
60
|
*
|
61
|
61
|
* @param configManager The manager to read config settings from.
|
62
|
62
|
*/
|
63
|
|
- public ColourManager(final AggregateConfigProvider configManager) {
|
|
63
|
+ public ColourManagerImpl(final AggregateConfigProvider configManager) {
|
64
|
64
|
this.configManager = configManager;
|
65
|
65
|
|
66
|
66
|
configManager.addChangeListener("colour", (domain, key) -> initColours());
|
|
@@ -85,16 +85,7 @@ public class ColourManager {
|
85
|
85
|
}
|
86
|
86
|
}
|
87
|
87
|
|
88
|
|
- /**
|
89
|
|
- * Parses either a 1-2 digit IRC colour, or a 6 digit hex colour from the target string, and
|
90
|
|
- * returns the corresponding colour. Returns the specified fallback colour if the spec can't be
|
91
|
|
- * parsed.
|
92
|
|
- *
|
93
|
|
- * @param spec The string to parse
|
94
|
|
- * @param fallback The colour to use if the spec isn't valid
|
95
|
|
- *
|
96
|
|
- * @return A colour representation of the specified string
|
97
|
|
- */
|
|
88
|
+ @Override
|
98
|
89
|
public Colour getColourFromString(final String spec, final Colour fallback) {
|
99
|
90
|
if (colourCache.containsKey(spec)) {
|
100
|
91
|
return colourCache.get(spec);
|
|
@@ -130,14 +121,7 @@ public class ColourManager {
|
130
|
121
|
return res;
|
131
|
122
|
}
|
132
|
123
|
|
133
|
|
- /**
|
134
|
|
- * Returns a Colour object that corresponds to the specified 6-digit hex string. If the string
|
135
|
|
- * is invalid, logs a warning and returns white.
|
136
|
|
- *
|
137
|
|
- * @param hex The hex string to convert into a Colour
|
138
|
|
- *
|
139
|
|
- * @return A Colour object corresponding to the hex input
|
140
|
|
- */
|
|
124
|
+ @Override
|
141
|
125
|
public Colour getColourFromHex(final String hex) {
|
142
|
126
|
if (colourCache.containsKey(hex)) {
|
143
|
127
|
return colourCache.get(hex);
|
|
@@ -163,15 +147,7 @@ public class ColourManager {
|
163
|
147
|
return colour;
|
164
|
148
|
}
|
165
|
149
|
|
166
|
|
- /**
|
167
|
|
- * Returns a Colour object that represents the colour associated with the specified IRC colour
|
168
|
|
- * code. If the code is not found, a warning is logged with the client's Logger class, and white
|
169
|
|
- * is returned.
|
170
|
|
- *
|
171
|
|
- * @param number The IRC colour code to look up
|
172
|
|
- *
|
173
|
|
- * @return The corresponding Colour object
|
174
|
|
- */
|
|
150
|
+ @Override
|
175
|
151
|
public Colour getColourFromIrcCode(final int number) {
|
176
|
152
|
if (number >= 0 && number <= 15) {
|
177
|
153
|
return ircColours[number];
|