X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbits%2FColor.java;h=120ff64a1c75f3dc7aeaf9da81aeb716c8787ff2;hb=d36057dfab8def933a64be042b039d76708ac5ba;hp=0f4e6b32bf35229f3d018084eee52287f1dd5c52;hpb=eb29bbb5ec70c43895dd0f053630c7e3cd402cba;p=nikiroo-utils.git diff --git a/src/jexer/bits/Color.java b/src/jexer/bits/Color.java index 0f4e6b3..120ff64 100644 --- a/src/jexer/bits/Color.java +++ b/src/jexer/bits/Color.java @@ -33,62 +33,9 @@ package jexer.bits; */ public final class Color { - /** - * The color value. Default is SGRWHITE. - */ - private int value = SGRWHITE; - - /** - * Get color value. Note that these deliberately match the color values - * of the ECMA-48 / ANSI X3.64 / VT100-ish SGR function ("ANSI colors"). - * - * @return the value - */ - public int getValue() { - return value; - } - - /** - * 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) { - String str = colorName.toLowerCase(); - - if (str.equals("black")) { - return Color.BLACK; - } else if (str.equals("white")) { - return Color.WHITE; - } else if (str.equals("red")) { - return Color.RED; - } else if (str.equals("cyan")) { - return Color.CYAN; - } else if (str.equals("green")) { - return Color.GREEN; - } else if (str.equals("magenta")) { - return Color.MAGENTA; - } else if (str.equals("blue")) { - return Color.BLUE; - } else if (str.equals("yellow")) { - return Color.YELLOW; - } else if (str.equals("brown")) { - return Color.YELLOW; - } else { - // Let unknown strings become white - return Color.WHITE; - } - } + // ------------------------------------------------------------------------ + // Constants -------------------------------------------------------------- + // ------------------------------------------------------------------------ /** * SGR black value = 0. @@ -170,6 +117,75 @@ public final class Color { */ public static final Color WHITE = new Color(SGRWHITE); + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * The color value. Default is SGRWHITE. + */ + private int value = SGRWHITE; + + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * Private constructor used to make the static Color instances. + * + * @param value the integer Color value + */ + private Color(final int value) { + this.value = value; + } + + // ------------------------------------------------------------------------ + // Color ------------------------------------------------------------------ + // ------------------------------------------------------------------------ + + /** + * Get color value. Note that these deliberately match the color values + * of the ECMA-48 / ANSI X3.64 / VT100-ish SGR function ("ANSI colors"). + * + * @return the value + */ + public int getValue() { + return 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) { + String str = colorName.toLowerCase(); + + if (str.equals("black")) { + return Color.BLACK; + } else if (str.equals("white")) { + return Color.WHITE; + } else if (str.equals("red")) { + return Color.RED; + } else if (str.equals("cyan")) { + return Color.CYAN; + } else if (str.equals("green")) { + return Color.GREEN; + } else if (str.equals("magenta")) { + return Color.MAGENTA; + } else if (str.equals("blue")) { + return Color.BLUE; + } else if (str.equals("yellow")) { + return Color.YELLOW; + } else if (str.equals("brown")) { + return Color.YELLOW; + } else { + // Let unknown strings become white + return Color.WHITE; + } + } + /** * Invert a color in the same way as (CGA/VGA color XOR 0x7). *