X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbits%2FColor.java;h=4defed5cfad7b35af25e901f2a165612b037fb71;hb=505be508ae7d3fb48122be548b310a238cfb91eb;hp=0f4e6b32bf35229f3d018084eee52287f1dd5c52;hpb=a2018e9964f6c58742cd1e6dd0a0c63e244a89d6;p=fanfix.git diff --git a/src/jexer/bits/Color.java b/src/jexer/bits/Color.java index 0f4e6b3..4defed5 100644 --- a/src/jexer/bits/Color.java +++ b/src/jexer/bits/Color.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -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). *