Java Utililty Methods Color Encode

List of utility methods to do Color Encode

Description

The list of methods to do Color Encode are organized into topic(s).

Method

Stringencode(Color c)
encode
return "#" + hex(c.getAlpha(), 2) + hex(c.getRed(), 2) + hex(c.getGreen(), 2) + hex(c.getBlue(), 2);
Stringencode(Color color)
encode
return "#" + encode(color.getRed()) + encode(color.getGreen()) + encode(color.getBlue());
Stringencode(Color color)
encode
char[] buf = new char[8];
String s = Integer.toHexString(color.getRed());
if (s.length() == 1) {
    buf[0] = '0';
    buf[1] = s.charAt(0);
} else {
    buf[0] = s.charAt(0);
    buf[1] = s.charAt(1);
...
Stringencode(Color color)
Encodes the specified color to a hexadecimal string representation.
if (color == null) {
    return null;
if (color.getAlpha() == MAX_RGB_VALUE) {
    return "#" + Integer.toHexString(color.getRGB()).substring(2);
} else {
    return "#" + Integer.toHexString(color.getRGB());
Stringencode(Color color)
encode
if (color == null) {
    return null;
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
int a = color.getAlpha();
return String.format("0x%02x%02x%02x%02x", r, g, b, a);
...
Stringencode(java.awt.Color c)
encode
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
StringBuffer sb = new StringBuffer();
sb.append("0x");
String red = Integer.toHexString(r);
if (red.length() < 2) {
    sb.append("0");
...
StringencodeColor(Color color)
Converts a Color to a hex color string.
if (color == null) {
    return "#808080";
return "#" + String.format("%06x", color.getRGB() & 0xffffff);
StringencodeColor(Color color)
encode Color
return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha();
StringencodeColor(Color color)
Encodes a color to a string value equal to the html representation.
return String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue());
StringencodeColor(int r, int g, int b)
encode Color
return "0x" + String.format("%02x%02x%02x", r, g, b).toUpperCase();