Package org.geotools.data.util
Class ColorConverterFactory
Object
ColorConverterFactory
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic Converter
Converts color to hex representation.static Converter
Converts CSS Color Module 4 names to colors, with a fallback to the basicCONVERT_STRING
converter if the provided source String is not found in theCSS_COLORS
map.static Converter
Converts provided integer to color, taking care to allow rgb and rgba support.static Converter
UsesColor.decode(String)
to convert String to Color.A mapping from CSS Color Module 4 names to Color objects.protected static DecimalFormat
Fields inherited from interface ConverterFactory
SAFE_CONVERSION
-
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
CONVERT_STRING
UsesColor.decode(String)
to convert String to Color. -
CONVERT_NUMBER_TO_COLOR
Converts provided integer to color, taking care to allow rgb and rgba support. -
FORMAT
-
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
Converts CSS Color Module 4 names to colors, with a fallback to the basicCONVERT_STRING
converter if the provided source String is not found in theCSS_COLORS
map.This converter is willing to work with:
CSS_COLORS
names 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
#RRGGBB
and#RRGGBBAA
-
CONVERT_COLOR_TO_STRING
Converts color to hex representation.
-
-
Constructor Details
-
ColorConverterFactory
public ColorConverterFactory()
-
-
Method Details
-
createConverter
Description copied from interface:ConverterFactory
Creates aConverter
instance for converting one type of object to another.- Specified by:
createConverter
in 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
null
if one could not be found.
-