Java Utililty Methods Color Value

List of utility methods to do Color Value

Description

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

Method

ColorgetDefaultBackgroundColor()
get Default Background Color
return new JLabel().getBackground();
ColorgetDefaultBackgroundColor(Color color)
get Default Background Color
Color backIDE;
if ((color.getRed() == 212) && (color.getGreen() == 208) && (color.getBlue() == 200)) {
    backIDE = new ColorUIResource(247, 243, 233);
} else if ((color.getRed() == 236) && (color.getGreen() == 233) && (color.getBlue() == 216)) {
    backIDE = new ColorUIResource(255, 251, 233);
} else {
    int r = color.getRed() + 35;
    int g = color.getGreen() + 35;
...
ColorgetDerivedColor(Color color, float ratio)
Gets a derived color from an existing color.
if (color != null) {
    float[] hsl = RGBtoHSL(color);
    if (hsl[2] < 0.4) {
        hsl[2] = 0.4f;
    if (ratio > 0.5) {
        hsl[2] += (1f - hsl[2]) * 2 * (ratio - 0.5);
    } else {
...
ColorgetDisabledForeground(Color c)
get Disabled Foreground
Color b = c.brighter();
if (c.getRGB() == b.getRGB())
    return b; 
else if (isNimbusLookAndFeel())
    return UIManager.getColor("nimbusDisabledText").darker(); 
else if (isMetalLookAndFeel())
    return UIManager.getColor("Label.disabledForeground"); 
else if (Color.BLACK.getRGB() == c.getRGB())
...
ColorgetDisabledLineColor()
get Disabled Line Color
if (disabledLineColor == null) {
    disabledLineColor = UIManager.getColor(isAquaLookAndFeel() ? "controlShadow" : 
            "Label.disabledForeground"); 
    if (disabledLineColor == null)
        disabledLineColor = UIManager.getColor("Label.disabledText"); 
    if (disabledLineColor == null || disabledLineColor.equals(getProfilerResultsBackground()))
        disabledLineColor = Color.GRAY;
return disabledLineColor;
ColorgetFieldForegroundColor()
get Field Foreground Color
return UIManager.getColor("field.foreground");
ColorgetGripperForegroundColor(Color color)
get Gripper Foreground Color
int r = getGripperValue(color.getRed());
int g = getGripperValue(color.getGreen());
int b = getGripperValue(color.getBlue());
if (r >= 255)
    r = 255;
if (g >= 255)
    g = 255;
if (b >= 255)
...
ColorgetInfoColor()
get Info Color
return UIManager.getColor("CyColor.complement(+2)");
ImageIcongetLetterIcon(Character letter, Color fgColor, Color bgColor, int size)
This method generates an icon which is a circle (background) with a letter showing on top
BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D) bi.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(bgColor);
g2d.fill(new Ellipse2D.Double(1, 1, size - 2, size - 2));
g2d.setStroke(new BasicStroke(0.5f));
g2d.setColor(Color.black);
g2d.draw(new Ellipse2D.Double(1, 1, size - 2, size - 2));
...
ColorgetLightColor()
get Light Color
return UIManager.getColor(TABLE_BACKGROUND_COLOR_KEY);