- // The color integer values. NOT EXPOSED.
- static private final int black = 0;
- static private final int red = 1;
- static private final int green = 2;
- static private final int yellow = 3;
- static private final int blue = 4;
- static private final int magenta = 5;
- static private final int cyan = 6;
- static private final int white = 7;
+ /**
+ * Private constructor used to make the static Color instances.
+ *
+ * @param value the integer Color value
+ */
+ private Color(final int value) {
+ this.value = value;
+ }
+
+ /**
+ * Public constructor returns one of the static Color instances.
+ *
+ * @param colorName "red", "blue", etc.
+ * @return Color.RED, Color.BLUE, etc.
+ */
+ static Color getColor(final String colorName) {
+ switch (colorName.toLowerCase()) {
+ case "black":
+ return Color.BLACK;
+ case "white":
+ return Color.WHITE;
+ case "red":
+ return Color.RED;
+ case "cyan":
+ return Color.CYAN;
+ case "green":
+ return Color.GREEN;
+ case "magenta":
+ return Color.MAGENTA;
+ case "blue":
+ return Color.BLUE;
+ case "yellow":
+ return Color.YELLOW;
+ case "brown":
+ return Color.YELLOW;
+ default:
+ // Let unknown strings become white
+ return Color.WHITE;
+ }
+ }
+
+ /**
+ * SGR black value = 0.
+ */
+ private static final int SGRBLACK = 0;
+
+ /**
+ * SGR red value = 1.
+ */
+ private static final int SGRRED = 1;
+
+ /**
+ * SGR green value = 2.
+ */
+ private static final int SGRGREEN = 2;
+
+ /**
+ * SGR yellow value = 3.
+ */
+ private static final int SGRYELLOW = 3;
+
+ /**
+ * SGR blue value = 4.
+ */
+ private static final int SGRBLUE = 4;
+
+ /**
+ * SGR magenta value = 5.
+ */
+ private static final int SGRMAGENTA = 5;
+
+ /**
+ * SGR cyan value = 6.
+ */
+ private static final int SGRCYAN = 6;
+
+ /**
+ * SGR white value = 7.
+ */
+ private static final int SGRWHITE = 7;