com.atlassian.confluence.util
Class ColourUtils

java.lang.Object
  extended by com.atlassian.confluence.util.ColourUtils

public class ColourUtils
extends Object

Color manipulation utilities

Since:
5.0

Field Summary
static Double EPSILON
           
 
Constructor Summary
ColourUtils()
           
 
Method Summary
static String colorToHex(Color color)
          Returns hexadecimal value for a color.
static Color darken(Color color, double amount)
          Returns a color darker than the given color
static String darken(String hexColor, double amount)
          Returns a color darker than the given color
static Color desaturate(Color color, double amount)
          Returns a color less saturate than the given color
static String desaturate(String hexColor, double amount)
          Returns a color less saturate than the given color
static Color hexToColor(String hexColor)
          Given a color hexadecimal value returns a Color object.
static int[] hslToRgb(float[] hsl)
          Returns the color value in the RGB space
static Color lighten(Color color, double amount)
          Returns a color lighter than the given color
static String lighten(String hexColor, double amount)
          Returns a color lighter than the given color
static Color saturate(Color color, double amount)
          Returns a color more saturated than the given color
static String saturate(String hexColor, double amount)
          Returns a color more saturated than the given color
static float[] toHSL(Color color)
          Returns the color value in the HSL space
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPSILON

public static final Double EPSILON
Constructor Detail

ColourUtils

public ColourUtils()
Method Detail

colorToHex

public static String colorToHex(Color color)
Returns hexadecimal value for a color.

Parameters:
color - color object
Returns:
color hexadecimal value

hexToColor

public static Color hexToColor(String hexColor)
Given a color hexadecimal value returns a Color object.

Parameters:
hexColor - color hexadecimal value
Returns:
Color object

darken

public static String darken(String hexColor,
                            double amount)
Returns a color darker than the given color

Parameters:
hexColor - color hexadecimal value
amount - value between 0 and 100.
Returns:
darker color

lighten

public static String lighten(String hexColor,
                             double amount)
Returns a color lighter than the given color

Parameters:
hexColor - color hexadecimal value
amount - value between 0 and 100.
Returns:
lighter color

saturate

public static String saturate(String hexColor,
                              double amount)
Returns a color more saturated than the given color

Parameters:
hexColor - color hexadecimal value
amount - value between 0 and 100.
Returns:
saturated color

desaturate

public static String desaturate(String hexColor,
                                double amount)
Returns a color less saturate than the given color

Parameters:
hexColor - color hexadecimal value
amount - value between 0 and 100.
Returns:
desaturated color

darken

public static Color darken(Color color,
                           double amount)
Returns a color darker than the given color

Parameters:
color - color onject
amount - value between 0 and 100.
Returns:
darker color

lighten

public static Color lighten(Color color,
                            double amount)
Returns a color lighter than the given color

Parameters:
color - color object
amount - value between 0 and 100.
Returns:
lighter color

desaturate

public static Color desaturate(Color color,
                               double amount)
Returns a color less saturate than the given color

Parameters:
color - color object
amount - value between 0 and 100.
Returns:
desaturated color

saturate

public static Color saturate(Color color,
                             double amount)
Returns a color more saturated than the given color

Parameters:
color - color object
amount - value between 0 and 100.
Returns:
saturated color

toHSL

public static float[] toHSL(Color color)
Returns the color value in the HSL space

Parameters:
color - color object
Returns:
{ hue, saturation, lightness, alpha }

hslToRgb

public static int[] hslToRgb(float[] hsl)
Returns the color value in the RGB space

Parameters:
hsl - color in hsl space
Returns:
rgb values [0, 255]


Copyright © 2003-2013 Atlassian. All Rights Reserved.