com.vaadin.sass.internal.util
Class ColorUtil

java.lang.Object
  extended by com.vaadin.sass.internal.util.ColorUtil

public class ColorUtil
extends Object


Constructor Summary
ColorUtil()
           
 
Method Summary
static int[] colorToRgb(LexicalUnitImpl color)
          Converts a color into an array of its RGB components.
static LexicalUnitImpl darken(LexicalUnitImpl darkenFunc)
           
static boolean isColor(LexicalUnitImpl unit)
          Returns true if the lexical unit represents a valid color (hexadecimal, rgb(), color name etc.), false otherwise.
static boolean isColorName(LexicalUnitImpl unit)
          Returns true if the lexical unit represents a valid color name, false otherwise.
static boolean isHexColor(LexicalUnitImpl unit)
          Returns true if the lexical unit represents a valid color in the hexadecimal form (three or six digits), false otherwise.
static boolean isHexColor(String string)
          Returns true if the string represents a valid color in the hexadecimal form (three or six digits), false otherwise.
static boolean isHslColor(LexicalUnitImpl unit)
          Returns true if the lexical unit represents a valid hsl() color function call, false otherwise.
static boolean isRgba(LexicalUnitImpl unit)
          Returns true if the lexical unit represents a valid RGBA value, false otherwise.
static boolean isRgbFunction(LexicalUnitImpl unit)
          Returns true if the lexical unit represents a valid rgb() method call , false otherwise.
static LexicalUnitImpl lighten(LexicalUnitImpl lightenFunc)
           
static String rgbToColorString(int[] rgb)
          Converts an array of RGB components to a string representing the color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorUtil

public ColorUtil()
Method Detail

isColor

public static boolean isColor(LexicalUnitImpl unit)
Returns true if the lexical unit represents a valid color (hexadecimal, rgb(), color name etc.), false otherwise. Note that rgba() is not considered to be a normal color. To detect it, call isRgba().

Parameters:
unit - lexical unit
Returns:
true if unit represents a color

isRgbFunction

public static boolean isRgbFunction(LexicalUnitImpl unit)
Returns true if the lexical unit represents a valid rgb() method call , false otherwise.

Parameters:
unit - lexical unit
Returns:
true if unit represents an RGB method call

isRgba

public static boolean isRgba(LexicalUnitImpl unit)
Returns true if the lexical unit represents a valid RGBA value, false otherwise.

Parameters:
unit - lexical unit
Returns:
true if unit represents an RGBA value

isHexColor

public static boolean isHexColor(LexicalUnitImpl unit)
Returns true if the lexical unit represents a valid color in the hexadecimal form (three or six digits), false otherwise.

Parameters:
unit - lexical unit
Returns:
true if unit represents a hexadecimal color

isColorName

public static boolean isColorName(LexicalUnitImpl unit)
Returns true if the lexical unit represents a valid color name, false otherwise. Currently, the 17 standard color names from the HTML and CSS color specification are supported.

Parameters:
unit - lexical unit
Returns:
true if unit represents a color name

isHslColor

public static boolean isHslColor(LexicalUnitImpl unit)
Returns true if the lexical unit represents a valid hsl() color function call, false otherwise.

Parameters:
unit - lexical unit
Returns:
true if unit represents as HSL color

colorToRgb

public static int[] colorToRgb(LexicalUnitImpl color)
Converts a color into an array of its RGB components.

Parameters:
color - a lexical unit that represents a color
Returns:
RGB components or null if not a color

rgbToColorString

public static String rgbToColorString(int[] rgb)
Converts an array of RGB components to a string representing the color.

Parameters:
rgb - the RGB components of a color
Returns:
a valid string representation of the color

isHexColor

public static boolean isHexColor(String string)
Returns true if the string represents a valid color in the hexadecimal form (three or six digits), false otherwise.

Parameters:
string - string that might represent a hex color
Returns:
true if string represents a hexadecimal color

darken

public static LexicalUnitImpl darken(LexicalUnitImpl darkenFunc)

lighten

public static LexicalUnitImpl lighten(LexicalUnitImpl lightenFunc)


Copyright © 2013–2014 Vaadin. All rights reserved.