TelnetD at SF

net.wimpi.telnetd.io.terminal
Class ColorHelper

java.lang.Object
  extended bynet.wimpi.telnetd.io.terminal.ColorHelper

public class ColorHelper
extends java.lang.Object

Utility class that provides methods and constants for creating and handling colored/styled Strings. The systems internal markup (Ctrl-a sequences) is utilized.

Version:
2.0 (13/03/2005)
Author:
Dieter Wimberger

Field Summary
static java.lang.String BLACK
          Defines the markup representation of the color black.
static java.lang.String BLINK
          Defines the markup representation of the activator for style blinking.
static java.lang.String BLINK_OFF
          Defines the markup representation of the deactivator for style blinking (i.e. steady)
static java.lang.String BLUE
          Defines the markup representation of the color blue.
static java.lang.String BOLD
          Defines the markup representation of the activator for style bold (normally represented by high intensity).
static java.lang.String BOLD_OFF
          Defines the markup representation of the deactivator for style bold.
static java.lang.String CYAN
          Defines the markup representation of the color cyan.
static java.lang.String GREEN
          Defines the markup representation of the color green.
static java.lang.String INTERNAL_MARKER
          Defines the internal marker string for style/color markups.
static java.lang.String ITALIC
          Defines the markup representation of the activator for style italic.
static java.lang.String ITALIC_OFF
          Defines the markup representation of the deactivator for style italic.
static java.lang.String MAGENTA
          Defines the markup representation of the color magenta.
static int MARKER_CODE
          Defines the internal marker character code.
static java.lang.String RED
          Defines the markup representation of the color red.
static java.lang.String RESET_ALL
          Defines the markup representation of the graphics rendition reset.
static java.lang.String UNDERLINED
          Defines the markup representation of the activator for style underlined.
static java.lang.String UNDERLINED_OFF
          Defines the markup representation of the deactivator for style underlined.
static java.lang.String WHITE
          Defines the markup representation of the color white.
static java.lang.String YELLOW
          Defines the markup representation of the color yellow.
 
Constructor Summary
ColorHelper()
           
 
Method Summary
static java.lang.String blinkingText(java.lang.String str)
          Creates a blinking string.
static java.lang.String boldcolorizeText(java.lang.String str, java.lang.String color)
          Creates a string with high intensity (bold) in the given textcolor.
static java.lang.String boldcolorizeText(java.lang.String str, java.lang.String fgc, java.lang.String bgc)
          Creates a string with the given high intensity foregroundcolor and the given backgroundcolor.
static java.lang.String boldText(java.lang.String str)
          Creates a string with high intensity (bold).
static java.lang.String colorizeBackground(java.lang.String str, java.lang.String color)
          Creates a string with the given backgroundcolor.
static java.lang.String colorizeBackground(java.lang.String str, java.lang.String color, boolean autoff)
          Creates a string with the given backgroundcolor.
static java.lang.String colorizeText(java.lang.String str, java.lang.String color)
          Creates a string with the given textcolor.
static java.lang.String colorizeText(java.lang.String str, java.lang.String color, boolean autoff)
          Creates a string with the given textcolor.
static java.lang.String colorizeText(java.lang.String str, java.lang.String fgc, java.lang.String bgc)
          Creates a string with the given foreground and backgroundcolor.
static java.lang.String colorizeText(java.lang.String str, java.lang.String fgc, java.lang.String bgc, boolean autoff)
          Creates a string with the given foreground and backgroundcolor.
static long getVisibleLength(java.lang.String str)
          Returns the length of the visible string calculated from the internal marked-up string passed as parameter.
static java.lang.String italicText(java.lang.String str)
          Creates a string with italic style.
static java.lang.String underlinedText(java.lang.String str)
          Creates an underlined string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL_MARKER

public static final java.lang.String INTERNAL_MARKER
Defines the internal marker string for style/color markups.

See Also:
Constant Field Values

MARKER_CODE

public static final int MARKER_CODE
Defines the internal marker character code.

See Also:
Constant Field Values

BLACK

public static final java.lang.String BLACK
Defines the markup representation of the color black.

See Also:
Constant Field Values

RED

public static final java.lang.String RED
Defines the markup representation of the color red.

See Also:
Constant Field Values

GREEN

public static final java.lang.String GREEN
Defines the markup representation of the color green.

See Also:
Constant Field Values

YELLOW

public static final java.lang.String YELLOW
Defines the markup representation of the color yellow.

See Also:
Constant Field Values

BLUE

public static final java.lang.String BLUE
Defines the markup representation of the color blue.

See Also:
Constant Field Values

MAGENTA

public static final java.lang.String MAGENTA
Defines the markup representation of the color magenta.

See Also:
Constant Field Values

CYAN

public static final java.lang.String CYAN
Defines the markup representation of the color cyan.

See Also:
Constant Field Values

WHITE

public static final java.lang.String WHITE
Defines the markup representation of the color white.

See Also:
Constant Field Values

BOLD

public static final java.lang.String BOLD
Defines the markup representation of the activator for style bold (normally represented by high intensity).

See Also:
Constant Field Values

BOLD_OFF

public static final java.lang.String BOLD_OFF
Defines the markup representation of the deactivator for style bold.

See Also:
Constant Field Values

ITALIC

public static final java.lang.String ITALIC
Defines the markup representation of the activator for style italic.

See Also:
Constant Field Values

ITALIC_OFF

public static final java.lang.String ITALIC_OFF
Defines the markup representation of the deactivator for style italic.

See Also:
Constant Field Values

UNDERLINED

public static final java.lang.String UNDERLINED
Defines the markup representation of the activator for style underlined.

See Also:
Constant Field Values

UNDERLINED_OFF

public static final java.lang.String UNDERLINED_OFF
Defines the markup representation of the deactivator for style underlined.

See Also:
Constant Field Values

BLINK

public static final java.lang.String BLINK
Defines the markup representation of the activator for style blinking.

See Also:
Constant Field Values

BLINK_OFF

public static final java.lang.String BLINK_OFF
Defines the markup representation of the deactivator for style blinking (i.e. steady)

See Also:
Constant Field Values

RESET_ALL

public static final java.lang.String RESET_ALL
Defines the markup representation of the graphics rendition reset.
It will reset all set colors and styles.

See Also:
Constant Field Values
Constructor Detail

ColorHelper

public ColorHelper()
Method Detail

colorizeText

public static java.lang.String colorizeText(java.lang.String str,
                                            java.lang.String color)
Creates a string with the given textcolor.

Parameters:
str - String to be colorized.
color - Constant defined color (see constants).
Returns:
String with internal markup-sequences.

colorizeText

public static java.lang.String colorizeText(java.lang.String str,
                                            java.lang.String color,
                                            boolean autoff)
Creates a string with the given textcolor.

Parameters:
str - String to be colorized.
color - Constant defined color (see constants).
autoff - boolean that toggles automatical appending of "attributes off" sequence.true if "attributes off" should be appended, false otherwise.
Returns:
String with internal markup-sequences.

colorizeBackground

public static java.lang.String colorizeBackground(java.lang.String str,
                                                  java.lang.String color)
Creates a string with the given backgroundcolor.

Parameters:
str - String to be colorized.
color - Constant defined color (see constants).
Returns:
String with internal markup-sequences.

colorizeBackground

public static java.lang.String colorizeBackground(java.lang.String str,
                                                  java.lang.String color,
                                                  boolean autoff)
Creates a string with the given backgroundcolor.

Parameters:
str - String to be colorized.
color - Constant defined color (see constants).
autoff - boolean that toggles automatical appending of "attributes off" sequence.true if "attributes off" should be appended, false otherwise.
Returns:
String with internal markup-sequences.

colorizeText

public static java.lang.String colorizeText(java.lang.String str,
                                            java.lang.String fgc,
                                            java.lang.String bgc)
Creates a string with the given foreground and backgroundcolor.

Parameters:
str - String to be colorized.
fgc - Constant defined color (see constants). Will be textcolor.
bgc - Constant defined color (see constants). Will be backgroundcolor.
Returns:
String with internal markup-sequences.

colorizeText

public static java.lang.String colorizeText(java.lang.String str,
                                            java.lang.String fgc,
                                            java.lang.String bgc,
                                            boolean autoff)
Creates a string with the given foreground and backgroundcolor.

Parameters:
str - String to be colorized.
fgc - Constant defined color (see constants). Will be textcolor.
bgc - Constant defined color (see constants). Will be backgroundcolor.
autoff - boolean that toggles automatical appending of "attributes off" sequence.true if "attributes off" should be appended, false otherwise.
Returns:
String with internal markup-sequences.

boldcolorizeText

public static java.lang.String boldcolorizeText(java.lang.String str,
                                                java.lang.String color)
Creates a string with high intensity (bold) in the given textcolor.

Parameters:
str - String to be boldcolorized.
color - Constant defined color (see constants).
Returns:
String with internal markup-sequences.

boldcolorizeText

public static java.lang.String boldcolorizeText(java.lang.String str,
                                                java.lang.String fgc,
                                                java.lang.String bgc)
Creates a string with the given high intensity foregroundcolor and the given backgroundcolor.

Parameters:
str - String to be colorized.
fgc - Constant defined color (see constants). Will be bold textcolor.
bgc - Constant defined color (see constants). Will be backgroundcolor.
Returns:
String with internal markup-sequences.

boldText

public static java.lang.String boldText(java.lang.String str)
Creates a string with high intensity (bold).

Parameters:
str - String to be styled bold.
Returns:
String with internal markup-sequences.

italicText

public static java.lang.String italicText(java.lang.String str)
Creates a string with italic style.

Parameters:
str - String to be styled italic.
Returns:
String with internal markup-sequences.

underlinedText

public static java.lang.String underlinedText(java.lang.String str)
Creates an underlined string.

Parameters:
str - String to be styled underlined.
Returns:
String with internal markup-sequences.

blinkingText

public static java.lang.String blinkingText(java.lang.String str)
Creates a blinking string.

Parameters:
str - String to be styled blinking.
Returns:
String with internal markup-sequences.

getVisibleLength

public static long getVisibleLength(java.lang.String str)
Returns the length of the visible string calculated from the internal marked-up string passed as parameter.

Parameters:
str - String with internal color/style markups.
Returns:
long Representing the length of the visible string..

TelnetD at SF

Copyright 2000-2005 Dieter Wimberger.