Convert this color string to the Color object.
@param strColor Name of the color (ie., gray or 0xFFFFCF or #FFFFCF).
@return The java color object (or null).
966070
public static Color nameToColor(String strColor)
    {
        final Object[][] obj = {
            {"black", Color.black},
            {"blue", Color.blue},
            {"cyan", Color.cyan},
            {"darkGray", Color.darkGray},
            {"gray", Color.gray},
            {"green", Color.green},
            {"lightGray", Color.lightGray},
            {"magenta", Color.magenta},
            {"orange", Color.orange},
            {"pink", Color.pink},
            {"red", Color.red},
            {"white", Color.white},
            {"yellow", Color.yellow}
        };      // Not static, because this method is usually not called.
        for (int i = 0; i < obj.length; i++)
        {
            if (strColor.equalsIgnoreCase((String)obj[i][0]))
                return (Color)obj[i][1];
        }
        try {
            return Color.decode(strColor);
        } catch (NumberFormatException ex)  {
        }
        return null;
    }
1278629
public function str($string, $foreground_color = null, $background_color = null) {
		$colored_string = "";
		if (isset($_SERVER['TERM']) && $_SERVER['TERM'] == 'xterm-256color') {
			// Check if given foreground color found
			if (isset($this->foreground_colors[ $foreground_color ])) {
				$colored_string .= "\033[" . $this->foreground_colors[ $foreground_color ] . "m";
			}
			// Check if given background color found
			if (isset($this->background_colors[ $background_color ])) {
				$colored_string .= "\033[" . $this->background_colors[ $background_color ] . "m";
			}

			// Add string and end coloring
			$colored_string .= $string . "\033[0m";
		} else {
			$colored_string = $string;
		}

		return $colored_string;
	}
484720
public static java.awt.Color convertColor(cz.vutbr.web.csskit.Color src)
    {
        return new java.awt.Color(src.getRGB(), true);
    }
739747
protected function getColoredString($string, $foreground_color = null,
                                        $background_color = null)
    {
        $colored_string = "";

        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
        }

        // Add string and end coloring
        $colored_string .= $string . "\033[0m";

        return $colored_string;
    }
716432
function parseColor (str) {
    if (str.substr(0,1) === '#') {
      // Handle color shorthands (like #abc)
      var shorthand = str.length === 4,
          m = str.match(shorthand ? /\w/g : /\w{2}/g);

      if (!m) return;
      m = m.map(function(s) { return parseInt(shorthand ? s+s : s, 16) });
      return new nodes.RGBA(m[0],m[1],m[2],1);
    }
    else if (str.substr(0,3) === 'rgb'){
      var m = str.match(/([0-9]*\.?[0-9]+)/g);
      if (!m) return;
      m = m.map(function(s){return parseFloat(s, 10)});
      return new nodes.RGBA(m[0], m[1], m[2], m[3] || 1);
    }
    else {
      var rgb = colors[str];
      if (!rgb) return;
      return new nodes.RGBA(rgb[0], rgb[1], rgb[2], 1);
    }
  }
1011694
public static ColorUIResource getColor(String strProperty, PropertyOwner propertyOwner, Map<String,Object> properties)
    {
        String strColor = ScreenUtil.getPropery(strProperty, propertyOwner, properties, null);
        if (strColor != null)
            return new ColorUIResource(BaseApplet.nameToColor(strColor));
        return null;    // Error on decode or no such color
    }
978782
public static String toRGB(Color color)
    {
        String rgb = "#";
        rgb += formatAsHex( color.getRed() );
        rgb += formatAsHex( color.getGreen() );
        rgb += formatAsHex( color.getBlue() );
        return rgb;
    }
492754
public static String shorthandHexSingle(String color) {
		validateHexSingle(color);
		if (color.length() > 1
				&& Character.toUpperCase(color.charAt(0)) == Character
						.toUpperCase(color.charAt(1))) {
			color = color.substring(0, 1);
		}
		return color;
	}
301259
public static int getColor(GraphicFactory graphicFactory, String colorString) {
        return getColor(graphicFactory, colorString, null, null);
    }
218188
def get_color(color = nil) # :nodoc:
    if color.respond_to?(:to_int) && color.respond_to?(:+)
      # the default color if arg is outside range,
      if color < 0 || 63 < color
        0x7FFF
      # or an index < 8 mapped into the correct range,
      elsif color < 8
        (color + 8).to_i
      # or an integer in the valid range
      else
        color.to_i
      end
    elsif color.respond_to?(:to_sym)
      color = color.downcase.to_sym if color.respond_to?(:to_str)
      # or the color string converted to an integer,
      if COLORS.has_key?(color)
        COLORS[color]
      # or the default color if string is unrecognised,
      else
        0x7FFF
      end
    else
      0x7FFF
    end
  end
1312347
protected String colorString(PDColor pdcolor)
    {
        String color = null;
        try
        {
            float[] rgb = pdcolor.getColorSpace().toRGB(pdcolor.getComponents());
            color = colorString(rgb[0], rgb[1], rgb[2]);
        } catch (IOException e) {
            log.error("colorString: IOException: {}", e.getMessage());
        } catch (UnsupportedOperationException e) {
            log.error("colorString: UnsupportedOperationException: {}", e.getMessage());
        }
        return color;
    }
843296
public static String colorToHexString(int color) {
        return "#" + intToHex(Color.red(color), 2) + intToHex(Color.green(color), 2) + intToHex(Color.blue(color), 2);
    }
1319105
protected StringBuilder style(StringBuilder b, String line, Color color, Style style){
    if(color != Color.NONE || style != Style.NONE){
      b.append(color.ansiCode);
      b.append(style.ansiCode);
      b.append(line);
      b.append("\033[0m");
    } else {
      b.append(line);
    }
    return b;
  }
1299941
public function color($string = null, $color = null, $background = null) {
		$result = '';
		
		if ($color !== null) {
			$result = sprintf(self::COLOR_PATTERN, $this->_fontColors[$color]);
		}
		
		if ($background !== null) {
			$result .= sprintf(self::COLOR_PATTERN, $this->_backgroundColors[$background]);
		}
		
		return $result . $string . sprintf(self::COLOR_PATTERN, 0);
	}
375506
public static Vector4f fromAWTColor(Color color) {
        return new Vector4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f);
    }
521634
public DataRange color(String... colors) {
        if (colors == null || colors.length == 0) {
            return this;
        }
        this.color().addAll(Arrays.asList(colors));
        return this;
    }
259112
private String morphColor(String str) {
		if (str.equals("")) {
			return "#000000";
		}
		if (str.equals("white")) {
			return "#ffffff";
		}
		if (str.equals("black")) {
			return "#000000";
		}
		
		return str;
	}