# Substance look and feel - border painters

### Overview

The base class for Substance border painters is `org.jvnet.substance.painter.border.SubstanceBorderPainter`. Border painter is used to paint the outer contour of most Swing components, such as buttons, check boxes, radio buttons, progress bars, tabs, scroll bars and others. 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.border.SubstanceBorderPainter` is

`/**
* Paints the control border.
*
* @param g
* Graphics.
* @param c
* Component.
* @param width
* Width of a UI component.
* @param height
* Height of a UI component.
* @param contour
* Contour of a UI component.
* @param innerContour
* Inner contour of a UI component. May be ignored if the
* specific implementation paints only the outside border.
* @param colorScheme1
* The first color scheme.
* @param colorScheme2
* The second color scheme.
* @param cyclePos
* Cycle position. Is used for rollover and pulsation effects.
* Must be in 0..10 range.
* @param useCyclePosAsInterpolation
* Indicates the algorithm to use for computing various colors.
* If <code>true</code>, the <code>cyclePos</code> is used
* to interpolate colors between different color components of
* both color schemes. If <code>false</code>, the
* <code>cyclePos</code> is used to interpolate colors between
* different color components of the first color scheme.
*/
public void paintBorder(Graphics g, Component c, int width, int height,
Shape contour, Shape innerContour, ColorScheme colorScheme1,
ColorScheme colorScheme2, float cyclePos,
boolean useCyclePosAsInterpolation)`

The `contour` and `innerContour` parameters specify the outer and inner contour shapes to paint, the `colorScheme1` and `colorScheme2` specify the Substance color schemes to be used to compute the gradient colors, while `cyclePos` and `useCyclePosAsInterpolation` indicate how (and whether) to interpolate between the actual colors of the passed two color schemes. The internal implementation of a specific border painter may decide to ignore the `innerContour` if this are not relevant.

Applications that wish to provide a custom (branding) border painter may utilize the existing `StandardBorderPainter` base class. It provides three extension points that compute gradient paint colors at different vertical locations (see `get*BorderColor` methods). Most core Substance border painters extend this class. In addition, the `InnerDelegateBorderPainter` base class provides a convinient way to create border painters that respect the `innerContour` parameter.

### Management API

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

- `SubstanceLookAndFeel.getCurrentSkin()` to retrieve the current skin.
- `SubstanceSkin.getBorderPainter()` to retrieve the border painter of the current skin.
- `SubstanceBorderPainter.paintBorder()` to paint the border on the specific graphics context.