Class ColorHelper


  • public class ColorHelper
    extends Object
    Helper class for colors
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int[] colorYiq​(int[] rgb)
      Returns a default contrast color for the given color
      static int[] colorYiq​(int[] rgb, int[] darkText, int[] lightText)
      Returns a default contrast color
      static String formatRGBasHex​(int... rgb)
      Returns the HTML hex code for the given RGB color components, in the format #RRGGBB, or null if the array is null or doesn't contains 3 elements
      static int[] fromHSVtoRGB​(int[] hsv)  
      static int[] fromHSVtoRGB​(int h, int s, int v)
      Converts a color represented by the given HSV values to RGB values.
      static int[] fromRGB​(int rgb)
      Returns a color from the given number, being the first byte the red value, and the other 2 bytes, green and blue
      static int[] fromRGBtoHSV​(int[] rgb)  
      static int[] fromRGBtoHSV​(int r, int g, int b)
      Converts a color represented by the given RGB values to HSV values.
      static int[] parse​(String string)
      Parses the RGB color from the given string
      static int[] parseRGB​(String rgbString)
      Returns a color from the given RGB string, in form rgb(R,G,B)
      static int[] parseRGBfromHex​(String hexString)
      Returns the RGB components from the given hex string, in form #RRGGBB
      static int toRGB​(int[] rgb)
      Returns an integer with 6 bytes, being them RRGGBB, or -1 if the given array is null or doesn't have 3 elements
    • Constructor Detail

      • ColorHelper

        public ColorHelper()
    • Method Detail

      • colorYiq

        public static int[] colorYiq​(int[] rgb)
        Returns a default contrast color for the given color
      • colorYiq

        public static int[] colorYiq​(int[] rgb,
                                     int[] darkText,
                                     int[] lightText)
        Returns a default contrast color
      • formatRGBasHex

        public static String formatRGBasHex​(int... rgb)
        Returns the HTML hex code for the given RGB color components, in the format #RRGGBB, or null if the array is null or doesn't contains 3 elements
      • fromHSVtoRGB

        public static int[] fromHSVtoRGB​(int h,
                                         int s,
                                         int v)
        Converts a color represented by the given HSV values to RGB values. R, G and B ranges are [0, 255], H is [0, 360], S and V are [0, 100];
      • fromRGB

        public static int[] fromRGB​(int rgb)
        Returns a color from the given number, being the first byte the red value, and the other 2 bytes, green and blue
      • fromRGBtoHSV

        public static int[] fromRGBtoHSV​(int r,
                                         int g,
                                         int b)
        Converts a color represented by the given RGB values to HSV values. R, G and B ranges are [0, 255], H is [0, 360], S and V are [0, 100];
      • parse

        public static int[] parse​(String string)
        Parses the RGB color from the given string
      • parseRGB

        public static int[] parseRGB​(String rgbString)
        Returns a color from the given RGB string, in form rgb(R,G,B)
      • parseRGBfromHex

        public static int[] parseRGBfromHex​(String hexString)
        Returns the RGB components from the given hex string, in form #RRGGBB
      • toRGB

        public static int toRGB​(int[] rgb)
        Returns an integer with 6 bytes, being them RRGGBB, or -1 if the given array is null or doesn't have 3 elements