com.planet_ink.coffee_mud.Libraries.interfaces
Interface ColorLibrary

All Superinterfaces:
java.lang.Cloneable, CMLibrary, CMObject, java.lang.Comparable<CMObject>
All Known Implementing Classes:
CMColor

public interface ColorLibrary
extends CMLibrary

The color library does just what it says, provides access to methods to translate colors from words, to ansi codes, to html tags, and combine them all in ways appropriate for their use.


Nested Class Summary
static class ColorLibrary.Color
          These are the straight color codes and character codes such as blink adn so forth.
static interface ColorLibrary.ColorState
          A color state is a class saved for users so the system knows what the current color situation is, which allows it to go back when it changes.
static class ColorLibrary.SpecialColor
          The special color codes are named color codes which are usually renameable by the user to other basic colors.
 
Field Summary
static char COLORCODE_BACKGROUND
          Color code prefix to designate background color (^ for foreground)
static char COLORCODE_BANSI256
          Color code prefix to designate background ansi color
static char COLORCODE_FANSI256
          Color code prefix to designate foreground ansi color
static ColorLibrary.Color[] COLORS_INCARDINALORDER
          The Basic 8 Colors, in their numeric ansi code order.
static java.util.Map<java.lang.String,java.lang.String> MAP_ANSICOLOR_TO_ANSIBGCOLOR
          A mapping of the escape codes for the basic 16 ansi colors to the basic 16 background ansi color codes
 
Method Summary
 void clearLookups()
          Clears the color code lookup tables so that the next translations will come from the properties.
 CMMsg fixSourceFightColor(CMMsg msg)
          Does nothing more impressive than adding the color codes for combat to the source and target messages if possible.
 ColorLibrary.ColorState getNormalColor()
          A ColorState object that represents the basic normal color, typically grey with no background.
 java.lang.String mixColorCodes(java.lang.String code1, java.lang.String code2)
          Given a foreground and background set of ansi escape codes, this method generates a single useable ansi escape code from the two.
 java.lang.String mixHTMLCodes(java.lang.String code1, java.lang.String code2)
          Given a foreground and background set of html tags, this method generates a single useable html tag from the two.
 java.lang.String[] standardColorLookups()
          Returns the standard ansi escape color lookup table, which maps an array indexed by the ^ color codes to an ansi escape color
 java.lang.String[] standardHTMLlookups()
          Returns the standard html tag lookup table, which maps an array indexed by the ^ color codes to an html tag.
 java.lang.String translateANSItoCMCode(java.lang.String code)
          Translates an ansi escape sequence to a basic 16 or special color code, anything that starts with ^ to the .
 java.lang.String translateCMCodeToANSI(java.lang.String code)
          Translates a basic 16 or special color code, anything that starts with ^ to the ansi escape sequence.
 ColorLibrary.ColorState valueOf(char fg, char bg)
          Generates a new ColorState object from the given foreground and background basic 16 ^ color codes.
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, ID, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

COLORS_INCARDINALORDER

static final ColorLibrary.Color[] COLORS_INCARDINALORDER
The Basic 8 Colors, in their numeric ansi code order.


MAP_ANSICOLOR_TO_ANSIBGCOLOR

static final java.util.Map<java.lang.String,java.lang.String> MAP_ANSICOLOR_TO_ANSIBGCOLOR
A mapping of the escape codes for the basic 16 ansi colors to the basic 16 background ansi color codes


COLORCODE_BACKGROUND

static final char COLORCODE_BACKGROUND
Color code prefix to designate background color (^ for foreground)

See Also:
Constant Field Values

COLORCODE_FANSI256

static final char COLORCODE_FANSI256
Color code prefix to designate foreground ansi color

See Also:
Constant Field Values

COLORCODE_BANSI256

static final char COLORCODE_BANSI256
Color code prefix to designate background ansi color

See Also:
Constant Field Values
Method Detail

clearLookups

void clearLookups()
Clears the color code lookup tables so that the next translations will come from the properties.


translateCMCodeToANSI

java.lang.String translateCMCodeToANSI(java.lang.String code)
Translates a basic 16 or special color code, anything that starts with ^ to the ansi escape sequence.

Parameters:
code - the ^ code
Returns:
the ansi escape sequence
See Also:
translateANSItoCMCode(String)

translateANSItoCMCode

java.lang.String translateANSItoCMCode(java.lang.String code)
Translates an ansi escape sequence to a basic 16 or special color code, anything that starts with ^ to the .

Parameters:
code - ansi escape sequence
Returns:
the ^ code
See Also:
translateCMCodeToANSI(String)

mixHTMLCodes

java.lang.String mixHTMLCodes(java.lang.String code1,
                              java.lang.String code2)
Given a foreground and background set of html tags, this method generates a single useable html tag from the two.

Parameters:
code1 - the first html tag
code2 - the other html tag, or null
Returns:
the combined html tag
See Also:
mixColorCodes(String, String)

mixColorCodes

java.lang.String mixColorCodes(java.lang.String code1,
                               java.lang.String code2)
Given a foreground and background set of ansi escape codes, this method generates a single useable ansi escape code from the two.

Parameters:
code1 - the first ansi escape code
code2 - the other ansi escape code, or null
Returns:
the combined ansi escape code
See Also:
mixHTMLCodes(String, String)

fixSourceFightColor

CMMsg fixSourceFightColor(CMMsg msg)
Does nothing more impressive than adding the color codes for combat to the source and target messages if possible.

Parameters:
msg - the message to colorize
Returns:
the same CMMsg sent, returned.

standardHTMLlookups

java.lang.String[] standardHTMLlookups()
Returns the standard html tag lookup table, which maps an array indexed by the ^ color codes to an html tag.

Returns:
the html tag lookup table
See Also:
standardColorLookups()

standardColorLookups

java.lang.String[] standardColorLookups()
Returns the standard ansi escape color lookup table, which maps an array indexed by the ^ color codes to an ansi escape color

Returns:
the ansi escape color lookup table
See Also:
standardHTMLlookups()

valueOf

ColorLibrary.ColorState valueOf(char fg,
                                char bg)
Generates a new ColorState object from the given foreground and background basic 16 ^ color codes.

Parameters:
fg - the foreground color code char
bg - the background color code char
Returns:
the new ColorState object
See Also:
ColorLibrary.ColorState

getNormalColor

ColorLibrary.ColorState getNormalColor()
A ColorState object that represents the basic normal color, typically grey with no background.

Returns:
the normal color ColorState
See Also:
ColorLibrary.ColorState