Java Utililty Methods Color Darker

List of utility methods to do Color Darker

Description

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

Method

intdarker(int channel, int intensity)
darker
int color = channel - intensity;
if (color < 0) {
    color = 0;
return color;
ColordarkerColor(Color c)
darker Color
return factorColor(c, sFactor);
ColordarkerColor(Color c, double amount)
darker Color
float[] hsbvals = new float[3];
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbvals);
hsbvals[2] = Math.min(1f, Math.max(0f, (float) (hsbvals[2] - amount)));
int rgb = Color.HSBtoRGB(hsbvals[0], hsbvals[1], hsbvals[2]);
rgb |= c.getAlpha() << 24;
return new Color(rgb, true);
ColordarkerColor(Color color, double factor)
Creates a new Color that is a darker version of this Color.
return new Color(Math.max((int) (color.getRed() * factor), 0),
        Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0));
StringdarkerColor(String hexValue)
darker Color
return darkerColor(hexValue, 0.1);
ColorderiveColor(Color orig, int darker)
Derives a color from another color by linearly shifting its blue, green, and blue values.
int red = orig.getRed() - darker;
int green = orig.getGreen() - darker;
int blue = orig.getBlue() - darker;
if (red < 0)
    red = 0;
else if (red > 255)
    red = 255;
if (green < 0)
...
voiddraw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark, Color colorLight)
Draws a 3d frame around the designated rectangle.
Color colorOld = g.getColor();
g.setColor(colorBackground);
g.fillRect(rect.x, rect.y, rect.width, rect.height);
g.setColor(colorDark);
g.drawLine(rect.x, rect.y, rect.x, rect.y + (rect.height - 1));
g.drawLine(rect.x, rect.y, rect.x + (rect.width - 1), rect.y);
g.setColor(colorLight);
g.drawLine(rect.x + 1, rect.y + (rect.height - 1), rect.x + (rect.width - 1), rect.y + (rect.height - 1));
...
ColorgetDarkColor()
get Dark Color
return new Color(20, 20, 20);
Color[]getDarkColors(Color[] colors, double fraction)
get Dark Colors
Color[] darkColors = new Color[colors.length];
int i = 0;
for (Color color : colors) {
    darkColors[i] = darker(color, fraction);
    ++i;
return darkColors;
ColorgetDarker(Color c)
get Darker
if (DARKER_CACHE == null)
    DARKER_CACHE = new HashMap();
int rgb = c.getRGB();
Color d = DARKER_CACHE.get(rgb);
if (d == null) {
    if (c.equals(Color.WHITE)) {
        d = new Color(244, 244, 244);
    } else {
...