Java JComponent Color normalize(float q, float p, float color)

Here you can find the source of normalize(float q, float p, float color)

Description

This method was copied from class javax.swing.colorchooser.ColorModelHSL of Java 7.

License

Open Source License

Declaration

private static float normalize(float q, float p, float color) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww  w .ja  v  a2 s . c  o m*/
     * Normalizes the red, green and blue values.
     * @param red The red value.
     * @param green The green value.
     * @param blue The blue value.
     * @return The normalized red, green and blue values.
     */
    public static float[] normalize(int red, int green, int blue) {
        float[] result = new float[3];
        result[0] = normalize(red);
        result[1] = normalize(green);
        result[2] = normalize(blue);
        return result;
    }

    /**
     * This method was copied from class {@code javax.swing.colorchooser.ColorModel} of Java 7.
     */
    private static float normalize(int value) {
        return (float) (value & 0xFF) / 255.0f;
    }

    /**
     * This method was copied from class {@code javax.swing.colorchooser.ColorModelHSL} of Java 7.
     */
    private static float normalize(float q, float p, float color) {
        if (color < 1.0f) {
            return p + (q - p) * color;
        }
        if (color < 3.0f) {
            return q;
        }
        if (color < 4.0f) {
            return p + (q - p) * (4.0f - color);
        }
        return p;
    }
}

Related

  1. flashMessage(final Window parent, String string, Color background, Color foreground, final long howLong)
  2. highlightForDebugging(JComponent component, Color color)
  3. installColors(Component c, Color background, Color foreground)
  4. makeEmptyIcon(Dimension size, Color color)
  5. newColorComponent(Color value)
  6. recursiveSetBackground(Component comp, Color color)