lt.monarch.util
Class ColorUtil

java.lang.Object
  extended by lt.monarch.util.ColorUtil

public final class ColorUtil
extends java.lang.Object

Utilities for color operations


Field Summary
Modifier and Type Field and Description
static java.lang.String[] pureColorNames
           
static java.awt.Color[] pureColors
           
 
Constructor Summary
Constructor and Description
ColorUtil()
           
 
Method Summary
Modifier and Type Method and Description
static int alpha(int rgb)
          Returns alpha component from sRGB ColorModel.
static int argb(int a, int r, int g, int b)
          Returns RGB value of the color from sRGB ColorModel.
static int argbv(int a, int r, int g, int b)
          Returns RGB value of the color from sRGB ColorModel.
static int blue(int rgb)
          Returns blue color component from sRGB ColorModel.
static java.awt.Color changeBrightness(java.awt.Color color, double multiplier)
          Changes color brightness.
static int changeBrightness(int color, double multiplier)
          Changes color brightness.
static java.util.ArrayList<java.awt.Color> extendPalette(java.util.ArrayList<java.awt.Color> original, int newCount)
           
static java.util.ArrayList<java.awt.Color> generateConvergingColors(int count, java.awt.Color c1, java.awt.Color c2)
           
static java.util.ArrayList<java.awt.Color> generateDivergingColors(int count, java.awt.Color c1, java.awt.Color c2, java.awt.Color c3, java.awt.Color c4)
           
static java.util.ArrayList<java.awt.Color> generateGenericColorVariations(java.awt.Color[] original, int valueVar, int valueVarCount)
           
static java.awt.Color[] getAnalogousColors(java.awt.Color original)
          Returns three colors generated according to analogous harmony.
static java.awt.Color getComplementaryColorFromHue(java.awt.Color primaryColor)
          Returns complementary color by hue
static java.awt.Color getComplementaryColorFromRGB(java.awt.Color original)
          Returns three colors generated according to complement harmony.
static java.awt.Color getComplementaryColorFromRYB(java.awt.Color primaryColor)
          Returns complementary color to the given one according to the RYB (Red-Yellow-Blue) color wheel
static java.util.ArrayList<java.awt.Color> getComplementaryColorsFromRYB(java.util.ArrayList<java.awt.Color> colors)
          Vectorized version of getComplementaryColorFromRYB
static java.awt.Color getDarkerColor(java.awt.Color original)
          Gets darker color of the specified one
static java.awt.Color getDarkerColor(java.awt.Color original, float step)
          Returns color which is darker than the given one by the given step.
static java.awt.Color[] getSplitComplementsColors(java.awt.Color original)
          Returns three colors generated according to split complements harmony.
static java.awt.Color[] getTriadicColors(java.awt.Color original)
          Returns three colors generated according to triadic harmony.
static int gray(int rgb)
          Returns gray color component from sRGB ColorModel.
static int green(int rgb)
          Returns green color component from sRGB ColorModel.
static java.awt.Color interpolateHSB(java.awt.Color c1, java.awt.Color c2, double transition)
           
static int red(int rgb)
          Returns red color component from sRGB ColorModel.
static int rgb(int r, int g, int b)
          Returns RGB value of the color from sRGB ColorModel.
static int rgbv(int r, int g, int b)
          Returns RGB value of the color from sRGB ColorModel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pureColors

public static java.awt.Color[] pureColors

pureColorNames

public static java.lang.String[] pureColorNames
Constructor Detail

ColorUtil

public ColorUtil()
Method Detail

changeBrightness

public static java.awt.Color changeBrightness(java.awt.Color color,
                                              double multiplier)
Changes color brightness.

Parameters:
color - color witch brightness will be changed.
multiplier - multiplier of color brightness.
Returns:
the new Color object with changed brightness

changeBrightness

public static int changeBrightness(int color,
                                   double multiplier)
Changes color brightness.

Parameters:
color - RGB value of the color witch brightness is changing.
multiplier - multiplier of color brightness.
Returns:
the new Color object with changed brightness

rgbv

public static int rgbv(int r,
                       int g,
                       int b)
Returns RGB value of the color from sRGB ColorModel.

Parameters:
r - red color component value.
g - green color component value.
b - blue color component value.
Returns:
rgb value of the color

rgb

public static int rgb(int r,
                      int g,
                      int b)
Returns RGB value of the color from sRGB ColorModel. Verifies bounds of components values.

Parameters:
r - red color component value.
g - green color component value.
b - blue color component value.
Returns:
rgb value of an array

argbv

public static int argbv(int a,
                        int r,
                        int g,
                        int b)
Returns RGB value of the color from sRGB ColorModel.

Parameters:
a - alpha value of the color.
r - red color component value.
g - green color component value.
b - blue color component value.
Returns:
rgb value of the color

argb

public static int argb(int a,
                       int r,
                       int g,
                       int b)
Returns RGB value of the color from sRGB ColorModel. Verifies bounds of components values.

Parameters:
a - alpha value of the color.
r - red color component value.
g - green color component value.
b - blue color component value.
Returns:
rgb value of the color

gray

public static int gray(int rgb)
Returns gray color component from sRGB ColorModel.

Parameters:
rgb - RGB value of the color.
Returns:
gray color component

alpha

public static int alpha(int rgb)
Returns alpha component from sRGB ColorModel.

Parameters:
rgb - RGB value of the color.
Returns:
alpha component

red

public static int red(int rgb)
Returns red color component from sRGB ColorModel.

Parameters:
rgb - RGB value of the color.
Returns:
red color component

green

public static int green(int rgb)
Returns green color component from sRGB ColorModel.

Parameters:
rgb - RGB value of the color.
Returns:
green color component

blue

public static int blue(int rgb)
Returns blue color component from sRGB ColorModel.

Parameters:
rgb - RGB value of the color.
Returns:
blue color component

generateDivergingColors

public static java.util.ArrayList<java.awt.Color> generateDivergingColors(int count,
                                                                          java.awt.Color c1,
                                                                          java.awt.Color c2,
                                                                          java.awt.Color c3,
                                                                          java.awt.Color c4)

generateConvergingColors

public static java.util.ArrayList<java.awt.Color> generateConvergingColors(int count,
                                                                           java.awt.Color c1,
                                                                           java.awt.Color c2)

interpolateHSB

public static java.awt.Color interpolateHSB(java.awt.Color c1,
                                            java.awt.Color c2,
                                            double transition)

generateGenericColorVariations

public static java.util.ArrayList<java.awt.Color> generateGenericColorVariations(java.awt.Color[] original,
                                                                                 int valueVar,
                                                                                 int valueVarCount)

extendPalette

public static java.util.ArrayList<java.awt.Color> extendPalette(java.util.ArrayList<java.awt.Color> original,
                                                                int newCount)

getDarkerColor

public static java.awt.Color getDarkerColor(java.awt.Color original)
Gets darker color of the specified one

Parameters:
original - input color
Returns:
darker color

getDarkerColor

public static java.awt.Color getDarkerColor(java.awt.Color original,
                                            float step)
Returns color which is darker than the given one by the given step.

Parameters:
original - Original color
step - Step by which to darken the given color. Step should be in interval [0; 1]
Returns:
darker color

getTriadicColors

public static java.awt.Color[] getTriadicColors(java.awt.Color original)
Returns three colors generated according to triadic harmony. This is the typical configuration of three colors that are equally spaced from each other on the RGB color wheel. The first color in array is the same as the given one. Calculation formula: given color HSB hue value +/- 120 degrees


getSplitComplementsColors

public static java.awt.Color[] getSplitComplementsColors(java.awt.Color original)
Returns three colors generated according to split complements harmony. This color scheme combines the two colors on either side of a color's complement. The first color in array is the same as the given one. Calculation formula: given color HSB hue value +/- 150 degrees


getAnalogousColors

public static java.awt.Color[] getAnalogousColors(java.awt.Color original)
Returns three colors generated according to analogous harmony. Uses the colors of the same color temperature near each other on the wheel. The first color in array is the same as the given one. Calculation formula: given color HSB hue value +/- 30 degrees


getComplementaryColorFromRGB

public static java.awt.Color getComplementaryColorFromRGB(java.awt.Color original)
Returns three colors generated according to complement harmony. This is the color opposite on the RGB color wheel. Calculation formula: given color HSB hue value + 180 degrees


getComplementaryColorFromRYB

public static java.awt.Color getComplementaryColorFromRYB(java.awt.Color primaryColor)
Returns complementary color to the given one according to the RYB (Red-Yellow-Blue) color wheel


getComplementaryColorsFromRYB

public static java.util.ArrayList<java.awt.Color> getComplementaryColorsFromRYB(java.util.ArrayList<java.awt.Color> colors)
Vectorized version of getComplementaryColorFromRYB


getComplementaryColorFromHue

public static java.awt.Color getComplementaryColorFromHue(java.awt.Color primaryColor)
Returns complementary color by hue