de.enough.polish.preprocess.css
Class ColorConverter

java.lang.Object
  extended by de.enough.polish.preprocess.css.ColorConverter

public class ColorConverter
extends Object

Translates colors.

Copyright Enough Software 2004 - 2011

 history
        01-Mar-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de, Eugene Markov, fixed inheritance of colors

Field Summary
static Map COLORS
          Defines the standard VGA colors.
static Map DYNAMIC_COLORS
          Defines dynamic colors like COLOR_BACKGROUND, COLOR_FOREGROUND, etc which can be used on MIDP/2.0 systems.
static String ENVIRONMENT_KEY
          the key for retrieving the color converter from the environment
 
Constructor Summary
ColorConverter()
          Creates a new colors parser.
 
Method Summary
 void clear()
          Removes all found color definition from the internal cache.
 String generateColorConstructor(String value)
          Generates a new de.enough.polish.ui.Color constructor for the given color value.
 boolean isAlphaColor(String color)
          Determines whether the given color has a defined alpha channel.
 boolean isDynamic(String value)
          Determines whether the given color is a dynamic one.
 void oldSetTemporaryColors(Map newColors)
          Sets the temporary colors.
 String parseColor(String definition)
          Parses the given color definition and returns the appropriate hex-definition.
 void setTemporaryColors(Map newColors)
          Sets the temporary colors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENVIRONMENT_KEY

public static final String ENVIRONMENT_KEY
the key for retrieving the color converter from the environment

See Also:
Constant Field Values

COLORS

public static final Map COLORS
Defines the standard VGA colors. Available colors are red, green, blue, lime, black, white, silver, gray, maroon, purple, fuchsia, olive, yellow, navy, teal and aqua.


DYNAMIC_COLORS

public static final Map DYNAMIC_COLORS
Defines dynamic colors like COLOR_BACKGROUND, COLOR_FOREGROUND, etc which can be used on MIDP/2.0 systems.

Constructor Detail

ColorConverter

public ColorConverter()
Creates a new colors parser.

Method Detail

clear

public void clear()
Removes all found color definition from the internal cache.


parseColor

public String parseColor(String definition)
Parses the given color definition and returns the appropriate hex-definition.

Parameters:
definition - the value of the color, e.g. "black", "#00ff00", "rgb( 340, 0, 0)"
Returns:
the hexadecimal color-value, e.g. "0x000000" or "Item.TRANSPARENT" when the definition equals "transparent".

oldSetTemporaryColors

public void oldSetTemporaryColors(Map newColors)
Sets the temporary colors.

Parameters:
newColors - all colors in a map.
Throws:
BuildException - when one of the given colors is invalid

setTemporaryColors

public void setTemporaryColors(Map newColors)
Sets the temporary colors.

Parameters:
newColors - all colors in a map.
Throws:
BuildException - when one of the given colors is invalid

isAlphaColor

public boolean isAlphaColor(String color)
Determines whether the given color has a defined alpha channel.

Parameters:
color - the color as a hexadecimal value
Returns:
true when the color has an alpha channel defined.

isDynamic

public boolean isDynamic(String value)
Determines whether the given color is a dynamic one.

Parameters:
value - the value, e.g. red or COLOR_BACKGROUND
Returns:
true when the given value represents a dynamic color like COLOR_BACKGROUND, COLOR_FOREGROUND, etc

generateColorConstructor

public String generateColorConstructor(String value)
Generates a new de.enough.polish.ui.Color constructor for the given color value.

Parameters:
value - the color value like red or COLOR_FOREGROUND
Returns:
source code that generates a new Color object