org.anadix.section508
Class ContrastUtility

java.lang.Object
  extended by org.anadix.section508.ContrastUtility

public final class ContrastUtility
extends Object

A class that is used to count and compare contrast between two colors

Version:
$Id: $
Author:
tomason

Method Summary
static double countRelativeLuminance(String color)
          Counts relative luminence of a color.
static double getContrastRatio(double luminance1, double luminance2)
          Counts contrast ratio between two colors
static String normalizeColor(String color)
          Normalizes the representation of color to the 32bit form starting with #.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

normalizeColor

public static String normalizeColor(String color)
Normalizes the representation of color to the 32bit form starting with #. 17 basic colors are normalized as well.

Parameters:
color - - some color representation
Returns:
color in range #000000 to #FFFFFF

countRelativeLuminance

public static double countRelativeLuminance(String color)
Counts relative luminence of a color. For more information see WCAG 2.0.

Parameters:
color - - color in form #{32bit in hexadecimal}
Returns:
a relative luminence

getContrastRatio

public static double getContrastRatio(double luminance1,
                                      double luminance2)
Counts contrast ratio between two colors

Parameters:
luminance1 - relative luminance of one color
luminance2 - relative luminance of the other color
Returns:
a number between [1, infinity)


Copyright © 2011. All Rights Reserved.