edu.umd.cfar.lamp.viper.util
Class ColorUtilities

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.ColorUtilities

public class ColorUtilities
extends java.lang.Object

A quick hack for placeholder colors, these color utility methods and static items allow quick access to colors by their English name.

Author:
davidm

Field Summary
static java.awt.Color translucent
           
static java.util.Map WEB_COLOR_NAMES
          A map of web color names, e.g.
 
Constructor Summary
ColorUtilities()
           
 
Method Summary
static java.awt.Color getColor(java.lang.String name)
          Gets the java color corresponding to the given CSS color name.
static double[] rgb2xyz(double[] RGB)
          Converts from the given RGB triplet into a corresponding XYZ triplet.
static double[] xyz2rgb(double[] XYZ)
          Converts from XYZ to RGB.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEB_COLOR_NAMES

public static java.util.Map WEB_COLOR_NAMES
A map of web color names, e.g. antiquewhite or salmon. For a comprehensive list, see the w3c's css color module documenation.


translucent

public static java.awt.Color translucent
Constructor Detail

ColorUtilities

public ColorUtilities()
Method Detail

getColor

public static java.awt.Color getColor(java.lang.String name)
Gets the java color corresponding to the given CSS color name.

Parameters:
name - the color name, e.g. khaki or burlywood
Returns:
the matching java color, or null if no color matches. XXX: Should it throw an illegal argument exception?

rgb2xyz

public static double[] rgb2xyz(double[] RGB)
Converts from the given RGB triplet into a corresponding XYZ triplet.

Parameters:
RGB - red, green and blue components, in the range from 0 to 1
Returns:
the XYZ color components

xyz2rgb

public static double[] xyz2rgb(double[] XYZ)
Converts from XYZ to RGB.

Parameters:
XYZ - a color in XYZ space
Returns:
the color, converted to RBG space