+ return;
+ }
+
+ while (token.equals("bold") || token.equals("blink")) {
+ if (token.equals("bold")) {
+ bold = true;
+ token = tokenizer.nextToken();
+ }
+ if (token.equals("blink")) {
+ blink = true;
+ token = tokenizer.nextToken();
+ }
+ }
+
+ // What's left is "blah on blah"
+ foreColor = token.toLowerCase();
+
+ if (!tokenizer.nextToken().toLowerCase().equals("on")) {
+ // Invalid line.
+ return;
+ }
+ backColor = tokenizer.nextToken().toLowerCase();
+
+ CellAttributes color = new CellAttributes();
+ if (bold) {
+ color.setBold(true);
+ }
+ if (blink) {
+ color.setBlink(true);
+ }
+ color.setForeColor(Color.getColor(foreColor));
+ color.setBackColor(Color.getColor(backColor));
+ colors.put(key, color);
+ }
+
+ /**
+ * Read color theme mappings from a Reader. The reader is closed at the
+ * end.
+ *
+ * @param reader the reader to read from
+ * @throws IOException if the I/O fails
+ */
+ public void load(final Reader reader) throws IOException {
+ BufferedReader bufferedReader = new BufferedReader(reader);
+ String line = bufferedReader.readLine();
+ for (; line != null; line = bufferedReader.readLine()) {
+ // Look for lines that resemble:
+ // "key = blah on blah"
+ // "key = bold blah on blah"
+ // "key = blink bold blah on blah"
+ // "key = bold blink blah on blah"
+ // "key = blink blah on blah"
+ if (line.indexOf('=') == -1) {
+ // Invalid line.
+ continue;
+ }
+ String key = line.substring(0, line.indexOf(':')).trim();
+ String text = line.substring(line.indexOf(':') + 1);
+ setColorFromString(key, text);