Class ColorUtil


  • public final class ColorUtil
    extends java.lang.Object
    Useful color utilities.
    Since:
    3.0 - initial release, 3.2 - public API
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static RGB blend​(RGB val1, RGB val2)
      Blend the two color values returning a value that is halfway between them.
      static RGB blend​(RGB c1, RGB c2, int ratio)
      Blends the two color values according to the provided ratio.
      static RGB getColorValue​(java.lang.String rawValue)
      Get the RGB value for a given color.
      static RGB[] getColorValues​(java.lang.String[] rawValues)
      Get the RGB values for a given color array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • blend

        public static RGB blend​(RGB c1,
                                RGB c2,
                                int ratio)
        Blends the two color values according to the provided ratio.
        Parameters:
        c1 - first color
        c2 - second color
        ratio - percentage of the first color in the blend (0-100)
        Returns:
        the RGB value of the blended color
        Since:
        3.3
      • blend

        public static RGB blend​(RGB val1,
                                RGB val2)
        Blend the two color values returning a value that is halfway between them.
        Parameters:
        val1 - the first value
        val2 - the second value
        Returns:
        the blended color
      • getColorValue

        public static RGB getColorValue​(java.lang.String rawValue)
                                 throws DataFormatException
        Get the RGB value for a given color.
        Parameters:
        rawValue - the raw value, either an RGB triple or an SWT constant name
        Returns:
        the RGB value
        Throws:
        DataFormatException - thrown if the value cannot be interpreted as a color
      • getColorValues

        public static RGB[] getColorValues​(java.lang.String[] rawValues)
        Get the RGB values for a given color array.
        Parameters:
        rawValues - the raw values, either RGB triple or an SWT constant
        Returns:
        the RGB values