Module xaos.ui

Class ColorUtils

    • Field Detail

      • ESS_BLUE

        public static final Color ESS_BLUE
      • ESS_BLUE_DARK

        public static final Color ESS_BLUE_DARK
      • ESS_BLUE_LED

        public static final Color ESS_BLUE_LED
      • ESS_BLUE_LED_OFF

        public static final Color ESS_BLUE_LED_OFF
      • ESS_GRAY

        public static final Color ESS_GRAY
      • ESS_GRAY_DARK

        public static final Color ESS_GRAY_DARK
      • ESS_GREEN

        public static final Color ESS_GREEN
      • ESS_GREEN_DARK

        public static final Color ESS_GREEN_DARK
      • ESS_GREEN_LED

        public static final Color ESS_GREEN_LED
      • ESS_GREEN_LED_OFF

        public static final Color ESS_GREEN_LED_OFF
      • ESS_MAGENTA

        public static final Color ESS_MAGENTA
      • ESS_MAGENTA_DARK

        public static final Color ESS_MAGENTA_DARK
      • ESS_MAGENTA_LED

        public static final Color ESS_MAGENTA_LED
      • ESS_MAGENTA_LED_OFF

        public static final Color ESS_MAGENTA_LED_OFF
      • ESS_ORANGE

        public static final Color ESS_ORANGE
      • ESS_ORANGE_DARK

        public static final Color ESS_ORANGE_DARK
      • ESS_ORANGE_LED

        public static final Color ESS_ORANGE_LED
      • ESS_ORANGE_LED_OFF

        public static final Color ESS_ORANGE_LED_OFF
      • ESS_PRIMARY

        public static final Color ESS_PRIMARY
      • ESS_PRIMARY_DARK

        public static final Color ESS_PRIMARY_DARK
      • ESS_PRIMARY_LIGHT

        public static final Color ESS_PRIMARY_LIGHT
      • ESS_RED

        public static final Color ESS_RED
      • ESS_RED_DARK

        public static final Color ESS_RED_DARK
      • ESS_RED_LED

        public static final Color ESS_RED_LED
      • ESS_RED_LED_OFF

        public static final Color ESS_RED_LED_OFF
      • ESS_SECONDARY

        public static final Color ESS_SECONDARY
      • ESS_SECONDARY_DARK

        public static final Color ESS_SECONDARY_DARK
      • ESS_SECONDARY_LIGHT

        public static final Color ESS_SECONDARY_LIGHT
      • ESS_YELLOW

        public static final Color ESS_YELLOW
      • ESS_YELLOW_DARK

        public static final Color ESS_YELLOW_DARK
      • ESS_YELLOW_LED

        public static final Color ESS_YELLOW_LED
      • ESS_YELLOW_LED_OFF

        public static final Color ESS_YELLOW_LED_OFF
      • ESS_ATTENTION

        public static final Color ESS_ATTENTION
      • ESS_DISCONNECTED

        public static final Color ESS_DISCONNECTED
      • ESS_ERROR

        public static final Color ESS_ERROR
      • ESS_INVALID

        public static final Color ESS_INVALID
      • ESS_MAJOR

        public static final Color ESS_MAJOR
      • ESS_MINOR

        public static final Color ESS_MINOR
      • ESS_OFF

        public static final Color ESS_OFF
      • ESS_OK

        public static final Color ESS_OK
      • ESS_ON

        public static final Color ESS_ON
      • ESS_STOP

        public static final Color ESS_STOP
      • ESS_WARNING

        public static final Color ESS_WARNING
    • Method Detail

      • bestConstrasting

        public static Color bestConstrasting​(Color color,
                                             Color... others)
        Selects from the others Colors the one with the best contrast against the given color.
        Parameters:
        color - The Color who needs a best contrasting one from the others ones.
        others - The array of Colors from which the best contrasting one must be chosen.
        Returns:
        The best contrasting color.
        Throws:
        NullPointerException - If color or others is null.
        IllegalArgumentException - If others is an empty array.
        See Also:
        getLuma(javafx.scene.paint.Color)
      • changeOpacity

        public static Color changeOpacity​(Color color,
                                          double offset)
        Adds the given offset to the color's opacity. Negative values will increase transparency (lower opacity), positive values will increase opacity.
        Parameters:
        color - The Color whose opacity must be changed.
        offset - The opacity offset to be added to the current color's opacity.
        Returns:
        The changed Color.
        Throws:
        NullPointerException - If color is null.
        IllegalArgumentException - If offset is not in the [0, 1] range.
      • getLuma

        public static double getLuma​(Color color)
        Returns the weighted brightness (luma) according to the HSP color model.
        Parameters:
        color - The color whose perceived brightness must be returned.
        Returns:
        The weighted brightness (luma).
        Throws:
        NullPointerException - If color is null.
        See Also:
        HSP Color Model, Weighted Methods.
      • mean

        public static Color mean​(List<Color> colors)
        Returns the mean Color of the ones in the given List.
        Parameters:
        colors - The List of Colors whose mean must be returned.
        Returns:
        A Color whose components are the mean of the given colors components.
      • meanColor

        public static Color meanColor​(List<Stop> stops)
        Returns the mean Color of the ones in the given List of Stops.
        Parameters:
        stops - The List of Stops whose color mean must be returned.
        Returns:
        A Color whose components are the mean of the given stops color components.
      • toColor

        public static Color toColor​(Paint paint)
        Converts the given Paint object to a Color one. If the given paint object is already a Color, then simple cast is performed. If the paint object is a LinearGradient or a RadialGradient, the mean color of its stops is returned instead. In all other cases null is returned.
        Parameters:
        paint - The Paint object to be converted.
        Returns:
        The Color resulting from the conversion of the given paint, or null.
      • toWeb

        public static String toWeb​(Color color)
        Converts the given Color to its web string representation.

        If the given color is opaque then the returned string will be #rrggbb otherwise #rrggbboo, where rr, gg, and bb are the hexadecimal value of the three color components (red, green, and blue), while oo is the hexadecimal representation of the color's opacity.

        Parameters:
        color - The Color to be converted.
        Returns:
        A String representation of the given color.
        Throws:
        NullPointerException - If color is null.