Here you can find the source of colorizeBackground(String str, String color, boolean autoff)
Parameter | Description |
---|---|
str | String to be colorized. |
color | Constant defined color (see constants). |
autoff | boolean that toggles automatical appending of "attributes off" sequence.<code>true<code> if "attributes off" should be appended, false otherwise. |
public static String colorizeBackground(String str, String color, boolean autoff)
//package com.java2s; //License/*from www . j a va2s .c om*/ public class Main { /** * Defines the internal marker string * for style/color markups. */ public static final String INTERNAL_MARKER = "\001"; /** * Defines the markup representation of the graphics rendition * reset.<br> * It will reset all set colors and styles. */ public static final String RESET_ALL = "a"; /** * Creates a string with the given backgroundcolor. * * @param str String to be colorized. * @param color Constant defined color (see constants). * @return String with internal markup-sequences. */ public static String colorizeBackground(String str, String color) { return INTERNAL_MARKER + color.toLowerCase() + str + INTERNAL_MARKER + RESET_ALL; } /** * Creates a string with the given backgroundcolor. * * @param str String to be colorized. * @param color Constant defined color (see constants). * @param autoff boolean that toggles automatical appending of "attributes off" * sequence.<code>true<code> if "attributes off" should be appended, false * otherwise. * @return String with internal markup-sequences. */ public static String colorizeBackground(String str, String color, boolean autoff) { if (autoff) { return colorizeBackground(str, color); } else { return INTERNAL_MARKER + color.toLowerCase() + str; } } }