org.jvnet.substance.painter.border
Class DelegateBorderPainter

java.lang.Object
  extended by org.jvnet.substance.painter.border.StandardBorderPainter
      extended by org.jvnet.substance.painter.border.DelegateBorderPainter
All Implemented Interfaces:
SubstanceTrait, SubstanceBorderPainter

public class DelegateBorderPainter
extends StandardBorderPainter

Delegate border painter that allows tweaking the visual appearance of borders.

Author:
Kirill Grouchnikov

Field Summary
protected  int bottomMask
          8-digit hexadecimal mask applied on the bottom color painted by delegate.
protected  StandardBorderPainter delegate
          The delegate border painter.
protected  java.lang.String displayName
          Display name of this border painter.
protected  int midMask
          8-digit hexadecimal mask applied on the middle color painted by delegate.
protected  int topMask
          8-digit hexadecimal mask applied on the top color painted by delegate.
protected  ColorSchemeTransform transform
          Transformation to be applied on the color schemes prior to compute the colors to be used for border painting.
protected static LazyResettableHashMap<SubstanceColorScheme> transformMap
          Map of transformed color schemes (to speed up the subsequent lookups).
 
Constructor Summary
DelegateBorderPainter(java.lang.String displayName, StandardBorderPainter delegate, ColorSchemeTransform transform)
          Creates a new delegate border painter
DelegateBorderPainter(java.lang.String displayName, StandardBorderPainter delegate, int topMask, int midMask, int bottomMask, ColorSchemeTransform transform)
          Creates a new delegate border painter
 
Method Summary
 java.awt.Color getBottomBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Computes the color of the bottom portion of the border.
 java.lang.String getDisplayName()
          Returns the display name of this trait.
 java.awt.Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Computes the color of the middle portion of the border.
 java.awt.Color getTopBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation)
          Computes the color of the top portion of the border.
 void paintBorder(java.awt.Graphics g, java.awt.Component c, int width, int height, java.awt.Shape contour, java.awt.Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation)
          Paints the control border.
 
Methods inherited from class org.jvnet.substance.painter.border.StandardBorderPainter
isPaintingInnerContour
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

displayName

protected java.lang.String displayName
Display name of this border painter.


delegate

protected StandardBorderPainter delegate
The delegate border painter.


topMask

protected int topMask
8-digit hexadecimal mask applied on the top color painted by delegate. Can be used to apply custom translucency. For example, value 0x80FFFFFF will result in 50% translucency of the original top border color.


midMask

protected int midMask
8-digit hexadecimal mask applied on the middle color painted by delegate. Can be used to apply custom translucency. For example, value 0x80FFFFFF will result in 50% translucency of the original middle border color.


bottomMask

protected int bottomMask
8-digit hexadecimal mask applied on the bottom color painted by delegate. Can be used to apply custom translucency. For example, value 0x80FFFFFF will result in 50% translucency of the original bottom border color.


transform

protected ColorSchemeTransform transform
Transformation to be applied on the color schemes prior to compute the colors to be used for border painting.


transformMap

protected static LazyResettableHashMap<SubstanceColorScheme> transformMap
Map of transformed color schemes (to speed up the subsequent lookups).

Constructor Detail

DelegateBorderPainter

public DelegateBorderPainter(java.lang.String displayName,
                             StandardBorderPainter delegate,
                             ColorSchemeTransform transform)
Creates a new delegate border painter

Parameters:
displayName - Display name of this border painter.
delegate - The delegate border painter.
transform - Transformation to be applied on the color schemes prior to compute the colors to be used for border painting.

DelegateBorderPainter

public DelegateBorderPainter(java.lang.String displayName,
                             StandardBorderPainter delegate,
                             int topMask,
                             int midMask,
                             int bottomMask,
                             ColorSchemeTransform transform)
Creates a new delegate border painter

Parameters:
displayName - Display name of this border painter.
delegate - The delegate border painter.
topMask - 8-digit hexadecimal mask applied on the top color painted by the delegate.
midMask - 8-digit hexadecimal mask applied on the middle color painted by the delegate.
bottomMask - 8-digit hexadecimal mask applied on the bottom color painted by the delegate.
transform - Transformation to be applied on the color schemes prior to compute the colors to be used for border painting.
Method Detail

getTopBorderColor

public java.awt.Color getTopBorderColor(SubstanceColorScheme interpolationScheme1,
                                        SubstanceColorScheme interpolationScheme2,
                                        double cycleCoef,
                                        boolean useCyclePosAsInterpolation)
Description copied from class: StandardBorderPainter
Computes the color of the top portion of the border. Override to provide different visual.

Overrides:
getTopBorderColor in class StandardBorderPainter
Parameters:
interpolationScheme1 - The first interpolation scheme.
interpolationScheme2 - The second interpolation scheme.
cycleCoef - Cycle coefficient.
useCyclePosAsInterpolation - Indicates whether the cycle coefficient should be used as the interpolation parameter.
Returns:
The color of the top portion of the border.

getMidBorderColor

public java.awt.Color getMidBorderColor(SubstanceColorScheme interpolationScheme1,
                                        SubstanceColorScheme interpolationScheme2,
                                        double cycleCoef,
                                        boolean useCyclePosAsInterpolation)
Description copied from class: StandardBorderPainter
Computes the color of the middle portion of the border. Override to provide different visual.

Overrides:
getMidBorderColor in class StandardBorderPainter
Parameters:
interpolationScheme1 - The first interpolation scheme.
interpolationScheme2 - The second interpolation scheme.
cycleCoef - Cycle coefficient.
useCyclePosAsInterpolation - Indicates whether the cycle coefficient should be used as the interpolation parameter.
Returns:
The color of the middle portion of the border.

getBottomBorderColor

public java.awt.Color getBottomBorderColor(SubstanceColorScheme interpolationScheme1,
                                           SubstanceColorScheme interpolationScheme2,
                                           double cycleCoef,
                                           boolean useCyclePosAsInterpolation)
Description copied from class: StandardBorderPainter
Computes the color of the bottom portion of the border. Override to provide different visual.

Overrides:
getBottomBorderColor in class StandardBorderPainter
Parameters:
interpolationScheme1 - The first interpolation scheme.
interpolationScheme2 - The second interpolation scheme.
cycleCoef - Cycle coefficient.
useCyclePosAsInterpolation - Indicates whether the cycle coefficient should be used as the interpolation parameter.
Returns:
The color of the bottom portion of the border.

paintBorder

public void paintBorder(java.awt.Graphics g,
                        java.awt.Component c,
                        int width,
                        int height,
                        java.awt.Shape contour,
                        java.awt.Shape innerContour,
                        SubstanceColorScheme colorScheme1,
                        SubstanceColorScheme colorScheme2,
                        float cyclePos,
                        boolean useCyclePosAsInterpolation)
Description copied from interface: SubstanceBorderPainter
Paints the control border.

Specified by:
paintBorder in interface SubstanceBorderPainter
Overrides:
paintBorder in class StandardBorderPainter
Parameters:
g - Graphics.
c - Component.
width - Width of a UI component.
height - Height of a UI component.
contour - Contour of a UI component.
innerContour - Inner contour of a UI component. May be ignored if the specific implementation paints only the outside border.
colorScheme1 - The first color scheme.
colorScheme2 - The second color scheme.
cyclePos - Cycle position. Is used for rollover and pulsation effects. Must be in 0..1 range.
useCyclePosAsInterpolation - Indicates the algorithm to use for computing various colors. If true, the cyclePos is used to interpolate colors between different color components of both color schemes. If false, the cyclePos is used to interpolate colors between different color components of the first color scheme.

getDisplayName

public java.lang.String getDisplayName()
Description copied from interface: SubstanceTrait
Returns the display name of this trait. This method is part of officially supported API.

Specified by:
getDisplayName in interface SubstanceTrait
Overrides:
getDisplayName in class StandardBorderPainter
Returns:
The display name of this trait.