Java Utililty Methods Color to Hex

List of utility methods to do Color to Hex

Description

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

Method

StringtoHex(Color c)
to Hex
String r = Integer.toHexString(c.getRed());
String g = Integer.toHexString(c.getGreen());
String b = Integer.toHexString(c.getBlue());
if (r.length() == 1) {
    r = "0" + r;
if (g.length() == 1) {
    g = "0" + g;
...
inttoHex(Color color)
to Hex
return toHex(color.getRed(), color.getGreen(), color.getBlue());
StringtoHex(Color color)
Returns a hex string for the given color in RGB format.
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
return String.format("%02x", r) + String.format("%02x", g) + String.format("%02x", b);
StringtoHex(Color color)
to Hex
return "#" + String.format("%02X", color.getRed()).toLowerCase()
        + String.format("%02X", color.getGreen()).toLowerCase()
        + String.format("%02X", color.getBlue()).toLowerCase();
StringtoHex(Color color)
to Hex
return (toHex(color.getRed()) + toHex(color.getGreen()) + toHex(color.getBlue())).toUpperCase();
StringtoHex(Color color)
to Hex
String alpha = pad(Integer.toHexString(color.getAlpha()));
String red = pad(Integer.toHexString(color.getRed()));
String green = pad(Integer.toHexString(color.getGreen()));
String blue = pad(Integer.toHexString(color.getBlue()));
return "#" + red + green + blue + alpha;
StringtoHex(Color color)
Returns the color as hex string ("#RRGGBB" or "#AARRGGBB").
String result;
if (color.getAlpha() < 255)
    result = "#" + toHex(color.getAlpha()) + toHex(color.getRed()) + toHex(color.getGreen())
            + toHex(color.getBlue());
else
    result = "#" + toHex(color.getRed()) + toHex(color.getGreen()) + toHex(color.getBlue());
return result;
StringtoHex(java.awt.Color color)
to Hex
return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
StringtoHex0x(Color col)
to Hexx
return String.format("0x%02x%02x%02x", col.getRed(), col.getGreen(), col.getBlue());
StringtoHexCode(String prefix, Color color)
transforms the color of the request from java.awt.Color to the hexadecimal representation as in an OGC conform WMS-GetMap request (e.g.
String r = Integer.toHexString(color.getRed());
if (r.length() < 2)
    r = "0" + r;
String g = Integer.toHexString(color.getGreen());
if (g.length() < 2)
    g = "0" + g;
String b = Integer.toHexString(color.getBlue());
if (b.length() < 2)
...