Here you can find the source of colorizeText(String str, String fgc, String bgc)
Parameter | Description |
---|---|
str | String to be colorized. |
fgc | Constant defined color (see constants). Will be textcolor. |
bgc | Constant defined color (see constants). Will be backgroundcolor. |
public static String colorizeText(String str, String fgc, String bgc)
//package com.java2s; /*//from ww w . ja v a2 s . com * @(#)ColorHelper.java * * Copyright 2003 by EkoLiving Pty Ltd. All Rights Reserved. * * This software is the proprietary information of EkoLiving Pty Ltd. * Use is subject to license terms. */ 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 textcolor. * * @param str String to be colorized. * @param color Constant defined color (see constants). * * @return String with internal markup-sequences. */ public static String colorizeText(String str, String color) { return INTERNAL_MARKER + color + str + INTERNAL_MARKER + RESET_ALL; } /** * Creates a string with the given foreground and backgroundcolor. * * @param str String to be colorized. * @param fgc Constant defined color (see constants). Will be textcolor. * @param bgc Constant defined color (see constants). Will be backgroundcolor. * * @return String with internal markup-sequences. */ public static String colorizeText(String str, String fgc, String bgc) { return INTERNAL_MARKER + fgc + INTERNAL_MARKER + bgc.toLowerCase() + str + INTERNAL_MARKER + RESET_ALL; } }