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 ConverterConverts color to hex representation.static ConverterConverts 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 ConverterConverts provided integer to color, taking care to allow rgb and rgba support.static ConverterUsesColor.decode(String)to convert String to Color.A mapping from CSS Color Module 4 names to Color objects.protected static DecimalFormatFields 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_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
Converts color to hex representation.
-
-
Constructor Details
-
ColorConverterFactory
public ColorConverterFactory()
-
-
Method Details
-
createConverter
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.
-