Package com.formdev.flatlaf.extras
Class FlatSVGIcon.ColorFilter
java.lang.Object
com.formdev.flatlaf.extras.FlatSVGIcon.ColorFilter
- Enclosing class:
FlatSVGIcon
A color filter that can modify colors of a painted
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty color filter.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 Color
applyMappings
(Color color) createRGBImageFilterFunction
(RGBImageFilter rgbImageFilter) Creates a color modifying function that usesRGBImageFilter.filterRGB(int, int, int)
.private void
private void
Returns the color mappings used for dark themes.static FlatSVGIcon.ColorFilter
Returns the global ColorFilter that is applied to all icons.Returns the color mappings used for light themes.Returns a color modifying function ornull
Removes a specific color mapping.Removes all color mappings.void
Sets a color modifying function that changes painted colors.
-
Field Details
-
instance
-
rgb2keyMap
-
colorMap
-
darkColorMap
-
mapper
-
-
Constructor Details
-
ColorFilter
public ColorFilter()Creates an empty color filter. -
ColorFilter
Creates a color filter with a color modifying function that changes painted colors. TheFunction
gets 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
-
-
Method Details
-
getInstance
Returns the global ColorFilter that is applied to all icons. -
getMapper
Returns a color modifying function ornull
- Since:
- 1.2
-
setMapper
Sets a color modifying function that changes painted colors. TheFunction
gets 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
-
getLightColorMap
Returns the color mappings used for light themes.- Since:
- 1.2
-
getDarkColorMap
Returns the color mappings used for dark themes.- Since:
- 1.2
-
addAll
Adds color mappings. Used for light and dark themes. -
addAll
public FlatSVGIcon.ColorFilter addAll(Map<Color, Color> from2toLightMap, Map<Color, Color> from2toDarkMap) Adds a color mappings, which has different colors for light and dark themes.- Since:
- 1.2
-
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
Removes all color mappings.- Since:
- 1.2
-
ensureColorMap
private void ensureColorMap() -
ensureDarkColorMap
private void ensureDarkColorMap() -
filter
-
applyMappings
-
createRGBImageFilterFunction
Creates a color modifying function that usesRGBImageFilter.filterRGB(int, int, int)
. Can be set to aFlatSVGIcon.ColorFilter
usingsetMapper(Function)
.- Since:
- 1.2
- See Also:
-