Class RadianceColorUtilities

java.lang.Object
org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities

public class RadianceColorUtilities extends Object
Various color-related utilities. This class is for internal use only.
  • Constructor Details

    • RadianceColorUtilities

      public RadianceColorUtilities()
  • Method Details

    • getInterpolatedRGB

      public static int getInterpolatedRGB(Color color1, Color color2, double color1Likeness)
      Interpolates color.
      Parameters:
      color1 - The first color
      color2 - The second color
      color1Likeness - The closer this value is to 0.0, the closer the resulting color will be to color2.
      Returns:
      Interpolated RGB value.
    • getInterpolatedChannelValue

      private static int getInterpolatedChannelValue(int value1, int value2, double value1Likeness)
    • OECF_sRGB

      private static double OECF_sRGB(double linear)
    • EOCF_sRGB

      private static double EOCF_sRGB(double srgb)
    • getInterpolatedColor

      public static Color getInterpolatedColor(Color color1, Color color2, double color1Likeness)
      Interpolates color.
      Parameters:
      color1 - The first color
      color2 - The second color
      color1Likeness - The closer this value is to 0.0, the closer the resulting color will be to color2.
      Returns:
      Interpolated color.
    • invertColor

      public static Color invertColor(Color color)
      Inverts the specified color.
      Parameters:
      color - The original color.
      Returns:
      The inverted color.
    • getNegativeColor

      public static int getNegativeColor(int rgb)
      Returns a negative of the specified color.
      Parameters:
      rgb - Color RGB.
      Returns:
      Negative of the specified color.
    • getAlphaColor

      public static Color getAlphaColor(Color color, int alpha)
      Returns a translucent of the specified color.
      Parameters:
      color - Color.
      alpha - Alpha channel value.
      Returns:
      Translucent of the specified color that matches the requested alpha channel value.
    • getSaturatedColor

      public static Color getSaturatedColor(Color color, double factor)
      Returns saturated version of the specified color.
      Parameters:
      color - Color.
      factor - Saturation factor.
      Returns:
      Saturated color.
    • getHueShiftedColor

      public static Color getHueShiftedColor(Color color, double hueShift)
      Returns hue-shifted (in HSV space) version of the specified color.
      Parameters:
      color - Color.
      hueShift - hue shift factor.
      Returns:
      Hue-shifted (in HSV space) color.
    • deriveByBrightness

      public static Color deriveByBrightness(Color original, Color brightnessSource)
      Derives a color based on the original color and a brightness source. The resulting color has the same hue and saturation as the original color, but its brightness is shifted towards the brightness of the brightness source. Thus, a light red color shifted towards dark green will become dark red.
      Parameters:
      original - Original color.
      brightnessSource - Brightness source.
      Returns:
      Derived color that has the same hue and saturation as the original color, but its brightness is shifted towards the brightness of the brightness source.
    • deriveByBrightness

      public static Color deriveByBrightness(Color original, float brightnessFactor)
    • getForegroundColor

      public static ColorUIResource getForegroundColor(RadianceColorScheme scheme)
      Returns the foreground color of the specified color scheme.
      Parameters:
      scheme - Color scheme.
      Returns:
      Color scheme foreground color.
    • getLighterColor

      public static Color getLighterColor(Color color, double diff)
      Returns lighter version of the specified color.
      Parameters:
      color - Color.
      diff - Difference factor (values closer to 1.0 will produce results closer to white color).
      Returns:
      Lighter version of the specified color.
    • getDarkerColor

      public static Color getDarkerColor(Color color, double diff)
      Returns darker version of the specified color.
      Parameters:
      color - Color.
      diff - Difference factor (values closer to 1.0 will produce results closer to black color).
      Returns:
      Darker version of the specified color.
    • getColorBrightness

      public static int getColorBrightness(int rgb)
      Returns the brightness of the specified color.
      Parameters:
      rgb - RGB value of a color.
      Returns:
      The brightness of the specified color.
    • getFocusColor

      public static Color getFocusColor(Component comp, TransitionAwareUI transitionAwareUI)
      Returns the color of the focus ring for the specified component.
      Parameters:
      comp - Component.
      Returns:
      The color of the focus ring for the specified component.
    • getColorStrength

      public static float getColorStrength(Color color)
      Returns the color strength.
      Parameters:
      color - Color.
      Returns:
      Color strength.
    • getForegroundColor

      public static Color getForegroundColor(Component component, StateTransitionTracker.ModelStateInfo modelStateInfo)
      Returns the foreground text color of the specified component.
      Parameters:
      component - Component.
      modelStateInfo - Component model state info.
      Returns:
      The foreground text color of the specified component.
    • getMenuComponentForegroundColor

      public static Color getMenuComponentForegroundColor(JMenuItem menuComponent, StateTransitionTracker.ModelStateInfo modelStateInfo)
      Returns the foreground text color of the specified menu component.
      Parameters:
      menuComponent - Menu component.
      modelStateInfo - Model state info for the component.
      Returns:
      The foreground text color of the specified menu component.
    • getBackgroundFillColor

      public static Color getBackgroundFillColor(Component component)
      Returns the background fill color of the specified component.
      Parameters:
      component - Component.
      Returns:
      The background fill color of the specified component.
    • getBackgroundFillColorScrollBar

      public static Color getBackgroundFillColorScrollBar(JScrollBar scrollbar)
    • getDefaultBackgroundColor

      private static ColorUIResource getDefaultBackgroundColor(Component comp, ComponentState compState)
      Returns the default background color for the specified component.
      Parameters:
      comp - Component.
      compState - Component state.
      Returns:
      The default background color for the components of the specified class.
    • getStripedBackground

      public static Color getStripedBackground(JComponent component, int rowIndex)
      Returns the striped background for the specified component. This method is relevant for components such as trees, tables and lists that use odd-even striping for the alternating rows.
      Parameters:
      component - Component.
      rowIndex - Row index.
      Returns:
      The striped background for the specified component.
    • encode

      public static String encode(int number)
    • encode

      public static String encode(Color color)