Class FlatSVGIcon.ColorFilter
- Enclosing class:
FlatSVGIcon
FlatSVGIcon.
The ColorFilter modifies color in two ways. Either using a color map, where specific colors are mapped to different ones. And/or by modifying the colors in a mapper function.
When filtering a color, mappings are applied first, then the mapper function is applied.
Global FlatSVGIcon ColorFilter can be retrieved using the getInstance() method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Componentprivate static FlatSVGIcon.ColorFilterprivate BiFunction<Component, Color, Color> -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty color filter.ColorFilter(BiFunction<Component, Color, Color> mapperEx) Creates a color modifying function that changes painted colors.ColorFilter(Function<Color, Color> mapper) Creates a color filter with a color modifying function that changes painted colors. -
Method Summary
Modifier and TypeMethodDescriptionAdds a color mapping.Adds a color mapping, which has different colors for light and dark themes.Adds color mappings.Adds a color mappings, which has different colors for light and dark themes.private ColorapplyMappings(Color color) createRGBImageFilterFunction(RGBImageFilter rgbImageFilter) Creates a color modifying function that usesRGBImageFilter.filterRGB(int, int, int).private voidprivate voidReturns the color mappings used for dark themes.static FlatSVGIcon.ColorFilterReturns the global ColorFilter that is applied to all icons.Returns the color mappings used for light themes.Returns a color modifying function ornullReturns a color modifying function ornullReturns the component passed toFlatSVGIcon.paintIcon(Component, Graphics, int, int).Removes a specific color mapping.Removes all color mappings.voidSets a color modifying function that changes painted colors.voidsetMapperEx(BiFunction<Component, Color, Color> mapperEx) Sets a color modifying function that changes painted colors.
-
Field Details
-
instance
-
rgb2keyMap
-
colorMap
-
darkColorMap
-
mapper
-
mapperEx
-
c
-
-
Constructor Details
-
ColorFilter
public ColorFilter()Creates an empty color filter. -
ColorFilter
Creates a color filter with a color modifying function that changes painted colors. TheFunctiongets passed the original color and returns a modified one.Examples: A ColorFilter can be used to brighten colors of the icon:
new ColorFilter( color -> color.brighter() );
Using a ColorFilter, icons can also be turned monochrome (painted with a single color):
new ColorFilter( color -> Color.RED );
- Parameters:
mapper- The color mapper function- Since:
- 1.2
-
ColorFilter
Creates a color modifying function that changes painted colors. TheBiFunctiongets passed the component and the original color and returns a modified one.Examples: A ColorFilter can be used to brighten colors of the icon (depending on component state if desired):
new ColorFilter( (c, color) -> c.isEnabled() ? color.brighter() : color );
- Parameters:
mapperEx- The color mapper function- Since:
- 3.6
-
-
Method Details
-
getInstance
Returns the global ColorFilter that is applied to all icons. -
getMapper
-
setMapper
Sets a color modifying function that changes painted colors. TheFunctiongets passed the original color and returns a modified one.Examples: A ColorFilter can be used to brighten colors of the icon:
filter.setMapper( color -> color.brighter() );
Using a ColorFilter, icons can also be turned monochrome (painted with a single color):
filter.setMapper( color -> Color.RED );
- Parameters:
mapper- The color mapper function- Since:
- 1.2
- See Also:
-
getMapperEx
Returns a color modifying function ornull- Since:
- 3.6
-
setMapperEx
Sets a color modifying function that changes painted colors. TheBiFunctiongets passed the component and the original color and returns a modified one.Examples: A ColorFilter can be used to brighten colors of the icon (depending on component state if desired):
filter.setMapperEx( (c, color) -> c.isEnabled() ? color.brighter() : color );
- Parameters:
mapperEx- The color mapper function- Since:
- 3.6
- See Also:
-
getLightColorMap
-
getDarkColorMap
-
addAll
Adds color mappings. Used for light and dark themes. -
addAll
-
add
Adds a color mapping. Used for light and dark themes. -
add
Adds a color mapping, which has different colors for light and dark themes.- Since:
- 1.2
-
remove
Removes a specific color mapping. -
removeAll
-
ensureColorMap
private void ensureColorMap() -
ensureDarkColorMap
private void ensureDarkColorMap() -
filter
-
filter
-
applyMappings
-
getPaintingComponent
Returns the component passed toFlatSVGIcon.paintIcon(Component, Graphics, int, int). This allows color mapping depend on component state (e.g. enabled, selected, hover, etc).- Since:
- 3.6
-
createRGBImageFilterFunction
Creates a color modifying function that usesRGBImageFilter.filterRGB(int, int, int). Can be set to aFlatSVGIcon.ColorFilterusingsetMapper(Function).- Since:
- 1.2
- See Also:
-