Adjusts the supplied color by the offsets in this colorization, taking the appropriate
measures for hue (wrapping it around) and saturation and value (clipping).

@return the RGB value of the recolored color.
507329
public int recolorColor (float[] hsv)
    {
        // hue will be wrapped-around by HSBtoRGB, we don't need to do it
        float hue = hsv[0] + offsets[0];
        // the others we must clip
        float sat = Math.min(Math.max(hsv[1] + offsets[1], 0), 1);
        float val = Math.min(Math.max(hsv[2] + offsets[2], 0), 1);

        // convert back to RGB space
        return Color.HSBtoRGB(hue, sat, val);
    }
174824
public void setAverageColor(final Color COLOR) {
        if (null == averageColor) {
            _averageColor = COLOR;
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            averageColor.set(COLOR);
        }
    }
249149
private Color4f[] getSymmetryColors(int nColors) {
		int offset = 0;
		int dMax = nColors + offset;
		Color[] col = ColorBrewer.Spectral.getColorPalette(dMax);
		Color4f[] colors = ColorConverter.convertColor4f(col);
		System.arraycopy(colors, offset, colors, 0, dMax-offset);
		return colors;
	}
745163
public static final String getRandomHexColor()
    {
        final int r = randomRGB();

        final int g = randomRGB();

        final int b = randomRGB();

        return rgbToBrowserHexColor(r, g, b);
    }
1279889
private void processColor() {
		if(red != -1 && green != -1 && blue != -1) {
			if(this.rtfParser.isImport()) {
				this.importHeader.importColor(Integer.toString(this.colorNr), new Color(this.red, this.green, this.blue));
			}
		
			if(this.rtfParser.isConvert()) {
				colorMap.put(Integer.toString(this.colorNr), new Color(this.red, this.green, this.blue));
			}
		}
		this.setToDefaults();
		this.colorNr++;
	}
852146
public void setRGB(int red, int green, int blue) throws Exception {

        if ((red < 0) || (red > 255)) {
            throw new Exception();
        }
        if ((green < 0) || (green > 255)) {
            throw new Exception();
        }
        if ((blue < 0) || (blue > 255)) {
            throw new Exception();
        }

        m_red = (float)red / 255;
        m_green = (float)green / 255;
        m_blue = (float)blue / 255;

        RGBtoHSV(m_red, m_green, m_blue);

        setHex();
    }
1011188
public static int color(ColorHolder colorHolder, Context ctx) {
        if (colorHolder == null) {
            return 0;
        } else {
            return colorHolder.color(ctx);
        }
    }
258787
private static final double[] getRGB(double hue, double saturation, double brightness) {
        double[] rgb = {0.0, 0.0, 0.0};

        double tmpHue = hue * 360.0;
        int hi;
        double f;
        double p, q, t;

        hi = (int)Math.floor(tmpHue / 60.0) % 6;
        f  = tmpHue / 60.0 - hi;
        p  = (brightness * (1.0 - saturation));
        q  = (brightness * (1.0 - saturation * f));
        t  = (brightness * (1.0 - saturation * (1.0 - f)));

        switch (hi) {
        case 0:
            rgb[0] = brightness;
            rgb[1] = t;
            rgb[2] = p;
            break;
        case 1:
            rgb[0] = q;
            rgb[1] = brightness;
            rgb[2] = p;
            break;
        case 2:
            rgb[0] = p;
            rgb[1] = brightness;
            rgb[2] = t;
            break;
        case 3:
            rgb[0] = p;
            rgb[1] = q;
            rgb[2] = brightness;
            break;
        case 4:
            rgb[0] = t;
            rgb[1] = p;
            rgb[2] = brightness;
            break;
        case 5:
            rgb[0] = brightness;
            rgb[1] = p;
            rgb[2] = q;
            break;
        default:
            break;
        }

        return rgb;
    }
141981
function( t ){
            var idx;
            if( this.colors.size() > 2 ){
                idx = Math.floor( this.map.getClippedValueFor(t) + 0.5 );
            } else {
                idx = t >= this.map.getInputMedian() ? 1 : 0;
            }
            return this.colors.get(idx);
        }
351407
@Pure
	public static int getPreferredColor() {
		final Preferences prefs = Preferences.userNodeForPackage(MapElementConstants.class);
		if (prefs != null) {
			return prefs.getInt("COLOR", DEFAULT_COLOR); //$NON-NLS-1$
		}
		return DEFAULT_COLOR;
	}
1363433
private float colorToAngle(int color) {
		float[] colors = new float[3];
		Color.colorToHSV(color, colors);
		
		return (float) Math.toRadians(-colors[0]);
	}
146210
function( rc ){
            if( is.ColorRange(rc) ){
                addAll(this.hueConstraint, rc.hueConstraint);
                addAll(this.saturationConstraint, rc.saturationConstraint);
                addAll(this.brightnessConstraint, rc.brightnessConstraint);
                addAll(this.alphaConstraint, rc.alphaConstraint);
                this.black.min = Math.min( this.black.min, rc.black.min );
                this.black.max = Math.max( this.black.max, rc.black.max );
                this.white.min = Math.min( this.white.min, rc.white.min );
                this.white.max = Math.max( this.white.max, rc.white.max );
            } else {
                this.hueConstraint.push( new FloatRange(rc.hue(),rc.hue()) );
                this.saturationConstraint.push( new FloatRange(rc.saturation(),rc.saturation()) );
                this.brightnessConstraint.push( new FloatRange(rc.brightness(),rc.brightness()) );
                this.alphaConstraint.push( new FloatRange(rc.alpha(),rc.alpha()) );
            }
            return this;
        }
13105
public Color scaleCopy(float value) {
		Color copy = new Color(r,g,b,a);
		copy.r *= value;
		copy.g *= value;
		copy.b *= value;
		copy.a *= value;
		
		return copy;
	}
850590
public static Color valueOf(String color) {

    Objects.requireNonNull(color, "color");
    Throwable cause = null;
    try {
      Color hexColor = parseHexString(color);
      if (hexColor != null) {
        return hexColor;
      } else {
        String upperColor = BasicHelper.toUpperCase(color);
        Color namedColor = NAME_TO_COLOR_MAP.get(upperColor);
        if (namedColor != null) {
          return namedColor;
        } else if (upperColor.startsWith(ColorModel.RGB.toString())) {
          Color rgbColor = parseRgb(upperColor);
          if (rgbColor != null) {
            return rgbColor;
          }
        } else {
          return GenericColor.valueOf(color).toColor();
        }
      }
    } catch (NumberFormatException e) {
      cause = e;
    }
    throw new IllegalArgumentException(color, cause);
  }
1209338
public static RgbaColor fromRgb(String rgb) {
        if (rgb.length() == 0) return getDefaultColor();

        String[] parts = getRgbParts(rgb).split(",");
        if (parts.length == 3) {
            return new RgbaColor(parseInt(parts[0]),
                                 parseInt(parts[1]),
                                 parseInt(parts[2]));
        }
        else {
            return getDefaultColor();
        }
    }
242499
public int color(Context ctx, @AttrRes int colorStyle, @ColorRes int colorDefaultRes) {
        //get the color from the holder else from the theme
        int color = color(ctx);
        if (color == 0) {
            return UIUtils.getThemeColorFromAttrOrRes(ctx, colorStyle, colorDefaultRes);
        } else {
            return color;
        }
    }
290504
function (color) {
            this.glArray[0] = me.Math.clamp(this.glArray[0] + color.glArray[0], 0, 1);
            this.glArray[1] = me.Math.clamp(this.glArray[1] + color.glArray[1], 0, 1);
            this.glArray[2] = me.Math.clamp(this.glArray[2] + color.glArray[2], 0, 1);
            this.glArray[3] = (this.glArray[3] + color.glArray[3]) / 2;

            return this;
        }