Package org.geotools.data.util
Class ColorConverterFactory
- Object
-
- ColorConverterFactory
-
- All Implemented Interfaces:
ConverterFactory
public class ColorConverterFactory extends Object implements ConverterFactory
ConverterFactory for handling color conversions.Supported conversions:
- "#FF0000" (String) -> Color.RED
- 0xCC0000FF (Integer) -> RED with 80% alpha
- "gray" (String) --> Color.GRAY
This code was previously part of the SLD utility class, it is being made available as part of the Converters framework to allow for broader use.
- Since:
- 2.5
- Author:
- Jody Garnett (Refractions Research)
-
-
Field Summary
Fields Modifier and Type Field Description static ConverterCONVERT_COLOR_TO_STRINGConverts color to hex representation.static ConverterCONVERT_CSS_TO_COLORConverts CSS Color Module 4 names to colors, with a fallback to the basicCONVERT_STRINGconverter if the provided source String is not found in theCSS_COLORSmap.static ConverterCONVERT_NUMBER_TO_COLORConverts provided integer to color, taking care to allow rgb and rgba support.static ConverterCONVERT_STRINGUsesColor.decode(String)to convert String to Color.static Map<String,Color>CSS_COLORSA mapping from CSS Color Module 4 names to Color objects.protected static DecimalFormatFORMAT-
Fields inherited from interface ConverterFactory
SAFE_CONVERSION
-
-
Constructor Summary
Constructors Constructor Description ColorConverterFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConvertercreateConverter(Class source, Class target, Hints hints)Creates aConverterinstance for converting one type of object to another.
-
-
-
Field Detail
-
CONVERT_STRING
public static Converter CONVERT_STRING
UsesColor.decode(String)to convert String to Color.
-
CONVERT_NUMBER_TO_COLOR
public static Converter CONVERT_NUMBER_TO_COLOR
Converts provided integer to color, taking care to allow rgb and rgba support.
-
FORMAT
protected static DecimalFormat FORMAT
-
CSS_COLORS
public static final Map<String,Color> CSS_COLORS
A mapping from CSS Color Module 4 names to Color objects.- See Also:
- https://www.w3.org/TR/css-color-4/#named-colors for more information.
-
CONVERT_CSS_TO_COLOR
public static Converter CONVERT_CSS_TO_COLOR
Converts CSS Color Module 4 names to colors, with a fallback to the basicCONVERT_STRINGconverter if the provided source String is not found in theCSS_COLORSmap.This converter is willing to work with:
CSS_COLORSnames such as "aliceblue".- rgb representation of the form
rgb(0,0,255) - rgba representation of the form
rgba(0,0,255,255) - Hex representation of the form
#RRGGBBand#RRGGBBAA
-
CONVERT_COLOR_TO_STRING
public static Converter CONVERT_COLOR_TO_STRING
Converts color to hex representation.
-
-
Method Detail
-
createConverter
public Converter createConverter(Class source, Class target, Hints hints)
Description copied from interface:ConverterFactoryCreates aConverterinstance for converting one type of object to another.- Specified by:
createConverterin interfaceConverterFactory- Parameters:
source- The type to convert from.target- The type to convert to.hints- Hints used to be used while creating a converter.- Returns:
- The converter, or
nullif one could not be found.
-
-