# Substance look and feel - highlight painters

### Overview

The base class for Substance highlight painters is `org.jvnet.substance.painter.highlight.SubstanceHighlightPainter`. Highlight painter is used to paint the highlights of renderer-based Swing components (such as trees, tables, lists), as well as highlights of menu items. It can also be used to paint visuals of third-party components (see skinning primer for more information). This allows providing a consistent and pluggable appearance to those components. In addition, it provides an external API for applications that wish to skin custom components in a visually consistent manner.

### Painting API

The only painting method in `org.jvnet.substance.painter.highlight.SubstanceHighlightPainter` is

`/**
* Paints the highlight.
*
* @param graphics
* Graphics context.
* @param comp
* Component.
* @param width
* Width.
* @param height
* Height.
* @param borderAlpha
* Border alpha factor.
* @param openSides
* The sides specified in this set will not be painted. Can be
* <code>null</code> or empty.
* @param colorScheme1
* The first color scheme.
* @param colorScheme2
* The second color scheme.
* @param cyclePos
* Cycle position. Is used for rollover and selection animations.
* Must be in 0..10 range.
*/
public void paintHighlight(Graphics2D graphics, Component comp, int width,
int height, float borderAlpha, Set<Side> openSides,
ColorScheme colorScheme1, ColorScheme colorScheme2, float cyclePos)`

The `width` and `height` parameters specify the rectangle to highlight (the highlight painters are only used on rectangular areas), the `colorScheme1` and `colorScheme2` specify the Substance color schemes to be used to compute the gradient colors, while `cyclePos` indicates how to interpolate between the actual colors of the passed two color schemes. The `borderAlpha` and `openSides` control the border of the highlight. For example, table highlight that needs to span the entire row will specify open left and right sides on most of the cells (for consistent and continuous highlight visuals). In addition, specific implementation is encouraged to maintain an internal cache of computed images, at least for small sizes.

### Management API

If you wish to use the highlight painter of the current skin to provide additional custom painting in your application, call:

- `SubstanceLookAndFeel.getCurrentSkin()` to retrieve the current skin.
- `SubstanceSkin.getHighlightPainter()` to retrieve the highlight painter of the current skin.
- `SubstanceHighlightPainter.paintHighlight()` to paint the highlight background on the specific graphics context.