Java Color Value getGripperForegroundColor(Color color)

Here you can find the source of getGripperForegroundColor(Color color)

Description

get Gripper Foreground Color

License

Open Source License

Declaration

static Color getGripperForegroundColor(Color color) 

Method Source Code

//package com.java2s;
import javax.swing.plaf.ColorUIResource;
import java.awt.*;

public class Main {
    static Color getGripperForegroundColor(Color color) {
        int r = getGripperValue(color.getRed());
        int g = getGripperValue(color.getGreen());
        int b = getGripperValue(color.getBlue());
        if (r >= 255)
            r = 255;/* ww  w. j  a  v a  2 s  .c  o  m*/
        if (g >= 255)
            g = 255;
        if (b >= 255)
            b = 255;
        return new ColorUIResource(r, g, b);
    }

    static int getGripperValue(int x) {
        if (x == 255) {
            return 0;
        } else if (x >= 0 && x <= 64) {
            return x * 33 / 64 + 123;
        } else {
            return (x - 65) * 157 / 189 + 33;
        }
    }
}

Related

  1. getDefaultBackgroundColor(Color color)
  2. getDerivedColor(Color color, float ratio)
  3. getDisabledForeground(Color c)
  4. getDisabledLineColor()
  5. getFieldForegroundColor()
  6. getInfoColor()
  7. getLetterIcon(Character letter, Color fgColor, Color bgColor, int size)
  8. getLightColor()
  9. getMediumDarkColor()