org.jvnet.substance.api
Class SubstanceSkin

java.lang.Object
  extended by org.jvnet.substance.api.SubstanceSkin
All Implemented Interfaces:
java.lang.Cloneable, SubstanceTrait
Direct Known Subclasses:
AutumnSkin, BackgroundColorTest.CustomSkin, BusinessBlackSteelSkin, BusinessBlueSteelSkin, BusinessSkin, ChallengerDeepSkin, CremeCoffeeSkin, CremeSkin, DustSkin, EmeraldDuskSkin, Issue437Skin, MagmaSkin, MistAquaSkin, MistSilverSkin, ModerateSkin, NebulaSkin, OfficeBlue2007Skin, OfficeSilver2007Skin, RavenGraphiteGlassSkin, RavenGraphiteSkin, RavenSkin, RobotDefaultDarkSkin, RobotDefaultSkin, SaharaSkin, SampleMenuFactory.CustomSkin, TwilightSkin

public abstract class SubstanceSkin
extends java.lang.Object
implements SubstanceTrait, java.lang.Cloneable

Base abstract class for Substance skins.

Author:
Kirill Grouchnikov

Field Summary
protected  java.util.Map<DecorationAreaType,SubstanceColorScheme> backgroundColorSchemeMap
          Maps decoration area type to the background color schemes.
protected  SubstanceBorderPainter borderPainter
          The border painter of this skin.
protected  SubstanceButtonShaper buttonShaper
          The button shaper of this skin.
protected  java.util.Map<DecorationAreaType,SubstanceColorSchemeBundle> colorSchemeBundleMap
          Maps decoration area type to the color scheme bundles.
protected  java.util.Set<DecorationAreaType> decoratedAreaSet
          Set of all decoration area types that are not explicitly registered in colorSchemeBundleMap but still are considered as decoration areas in this skin.
protected  SubstanceDecorationPainter decorationPainter
          The decoration painter of this skin.
protected  java.util.Set<DecorationAreaType> dropShadowsSet
          Contains the types of decoration areas that show a drop shadow on the few top pixels.
protected  SubstanceGradientPainter gradientPainter
          The gradient painter of this skin.
protected  SubstanceBorderPainter highlightBorderPainter
          The highlight border painter of this skin.
protected  SubstanceHighlightPainter highlightPainter
          The highlight painter of this skin.
protected  double selectedTabFadeEnd
          The end of fade effect on the selected tabs in JTabbedPanes.
protected  double selectedTabFadeStart
          The start of fade effect on the selected tabs in JTabbedPanes.
protected  SubstanceWatermark watermark
          The watermark of this skin.
protected  SubstanceColorScheme watermarkScheme
          Color scheme for watermarks.
 
Constructor Summary
protected SubstanceSkin()
          Constructs the basic data structures for a skin.
 
Method Summary
 void addCustomEntriesToTable(javax.swing.UIDefaults table)
          Adds skin-specific entries to the UI defaults table.
protected  java.lang.Object clone()
           
 float getAlpha(java.awt.Component comp, ComponentState componentState)
          Returns the alpha channel of the color scheme of the component.
 SubstanceColorScheme getBackgroundColorScheme(DecorationAreaType decorationAreaType)
          Returns the background color scheme for the specified decoration area type.
 SubstanceColorScheme getBorderColorScheme(java.awt.Component comp, ComponentState componentState)
          Deprecated. Use getColorScheme(Component, ColorSchemeAssociationKind, ComponentState) with ColorSchemeAssociationKind.BORDER instead. This method will be removed in version 6.0.
 SubstanceBorderPainter getBorderPainter()
          Returns the border painter of this skin.
 SubstanceButtonShaper getButtonShaper()
          Returns the button shaper of this skin.
 SubstanceColorScheme getColorScheme(java.awt.Component comp, ColorSchemeAssociationKind associationKind, ComponentState componentState)
          Returns the color scheme to be used for painting the specified visual area of the component under the specified component state.
 SubstanceColorScheme getColorScheme(java.awt.Component comp, ComponentState componentState)
          Returns the color scheme of the specified component in the specified component state.
static java.util.Map<java.lang.String,SubstanceColorScheme> getColorSchemes(java.net.URL url)
          Returns the collection of color schemes in the specified URL.
 SubstanceDecorationPainter getDecorationPainter()
          Returns the decoration painter of this skin.
 SubstanceGradientPainter getGradientPainter()
          Returns the gradient painter of this skin.
 float getHighlightAlpha(java.awt.Component comp, ComponentState componentState)
          Returns the alpha channel of the highlight color scheme of the component.
 SubstanceBorderPainter getHighlightBorderPainter()
          Returns the highlight border painter of this skin.
 SubstanceColorScheme getHighlightColorScheme(java.awt.Component comp, ComponentState componentState)
          Deprecated. Use getColorScheme(Component, ColorSchemeAssociationKind, ComponentState) with ColorSchemeAssociationKind.HIGHLIGHT instead. This method will be removed in version 6.0.
 SubstanceHighlightPainter getHighlightPainter()
          Returns the highlight painter of this skin.
 SubstanceColorScheme getMainActiveColorScheme()
          Returns the main active color scheme for this skin.
 SubstanceColorScheme getMainActiveColorScheme(DecorationAreaType decorationAreaType)
          Returns the main active color scheme for the specific decoration area type.
 SubstanceColorScheme getMainDefaultColorScheme()
          Returns the main default color scheme for this skin.
 SubstanceColorScheme getMainDefaultColorScheme(DecorationAreaType decorationAreaType)
          Returns the main default color scheme for the specific decoration area type.
 SubstanceColorScheme getMainDisabledColorScheme()
          Returns the main disabled color scheme for this skin.
 SubstanceColorScheme getMainDisabledColorScheme(DecorationAreaType decorationAreaType)
          Returns the main disabled color scheme for the specific decoration area type.
 double getSelectedTabFadeEnd()
          Returns the end of fade effect on the selected tabs in JTabbedPanes.
 double getSelectedTabFadeStart()
          Returns the start of fade effect on the selected tabs in JTabbedPanes.
 SubstanceWatermark getWatermark()
          Returns the watermark of this skin.
 SubstanceColorScheme getWatermarkColorScheme()
          Returns the color scheme to be used for painting the watermark.
 boolean isPaintingDropShadows(DecorationAreaType decorationAreaType)
          Returns indication whether the specified decoration area type should paint drop shadows on the top few pixels.
 boolean isRegisteredAsDecorationArea(DecorationAreaType decorationType)
          Returns indication whether the specified decoration area type should have their background painted by SubstanceDecorationPainter.paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin) instead of a simple background fill.
 boolean isValid()
          Checks whether this skin is valid.
 void registerAsDecorationArea(SubstanceColorScheme backgroundColorScheme, DecorationAreaType... areaTypes)
          Registers the specified background color scheme to be used on controls in decoration areas.
 void registerDecorationAreaSchemeBundle(SubstanceColorSchemeBundle bundle, DecorationAreaType... areaTypes)
          Registers the specified color scheme bundle to be used on controls in decoration areas.
 void registerDecorationAreaSchemeBundle(SubstanceColorSchemeBundle bundle, SubstanceColorScheme backgroundColorScheme, DecorationAreaType... areaTypes)
          Registers the specified color scheme bundle and background color scheme to be used on controls in decoration areas.
 void setPaintingDropShadows(DecorationAreaType decorationAreaType)
          Marks the specified area type to have drop shadows on the top few pixels.
 void setSelectedTabFadeEnd(double selectedTabFadeEnd)
          Sets the end of fade effect on the selected tabs in JTabbedPanes.
 void setSelectedTabFadeStart(double selectedTabFadeStart)
          Sets the start of fade effect on the selected tabs in JTabbedPane s.
 SubstanceSkin transform(ColorSchemeTransform transform, java.lang.String name)
          Creates a new skin that has the same settings as this skin with the addition of applying the specified color scheme transformation on all the relevant color schemes.
 void unsetPaintingDropShadows(DecorationAreaType decorationAreaType)
          Marks the specified area type to not have drop shadows on the top few pixels.
 SubstanceSkin withWatermark(SubstanceWatermark watermark)
          Creates a clone of this skin with the specified watermark.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jvnet.substance.api.trait.SubstanceTrait
getDisplayName
 

Field Detail

colorSchemeBundleMap

protected java.util.Map<DecorationAreaType,SubstanceColorSchemeBundle> colorSchemeBundleMap
Maps decoration area type to the color scheme bundles. Must contain an entry for DecorationAreaType.NONE.


backgroundColorSchemeMap

protected java.util.Map<DecorationAreaType,SubstanceColorScheme> backgroundColorSchemeMap
Maps decoration area type to the background color schemes.


watermark

protected SubstanceWatermark watermark
The watermark of this skin. May be null if this skin doesn't define a custom watermark.


buttonShaper

protected SubstanceButtonShaper buttonShaper
The button shaper of this skin. Must be non- null.


gradientPainter

protected SubstanceGradientPainter gradientPainter
The gradient painter of this skin. Must be non- null.


borderPainter

protected SubstanceBorderPainter borderPainter
The border painter of this skin. Must be non- null.


highlightBorderPainter

protected SubstanceBorderPainter highlightBorderPainter
The highlight border painter of this skin. Can be null.


highlightPainter

protected SubstanceHighlightPainter highlightPainter
The highlight painter of this skin. Must be non- null.


decorationPainter

protected SubstanceDecorationPainter decorationPainter
The decoration painter of this skin. Must be non- null.


decoratedAreaSet

protected java.util.Set<DecorationAreaType> decoratedAreaSet
Set of all decoration area types that are not explicitly registered in colorSchemeBundleMap but still are considered as decoration areas in this skin. Controls lying in such areas will have their background painted by SubstanceDecorationPainter.paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin) instead of a simple background fill.


selectedTabFadeStart

protected double selectedTabFadeStart
The start of fade effect on the selected tabs in JTabbedPanes.

See Also:
selectedTabFadeEnd

selectedTabFadeEnd

protected double selectedTabFadeEnd
The end of fade effect on the selected tabs in JTabbedPanes.

See Also:
selectedTabFadeStart

dropShadowsSet

protected java.util.Set<DecorationAreaType> dropShadowsSet
Contains the types of decoration areas that show a drop shadow on the few top pixels.


watermarkScheme

protected SubstanceColorScheme watermarkScheme
Color scheme for watermarks.

Constructor Detail

SubstanceSkin

protected SubstanceSkin()
Constructs the basic data structures for a skin.

Method Detail

getMainActiveColorScheme

public SubstanceColorScheme getMainActiveColorScheme()
Returns the main active color scheme for this skin. The result is the active color scheme for controls that do not lie in any decoration area. Custom painting code that needs to consult the colors of the specific component should use getColorScheme(Component, ComponentState) method and various SubstanceColorScheme methods.

Returns:
The main active color scheme for this skin.
See Also:
getColorScheme(Component, ComponentState), getMainActiveColorScheme(DecorationAreaType)

getMainDefaultColorScheme

public SubstanceColorScheme getMainDefaultColorScheme()
Returns the main default color scheme for this skin. The result is the default color scheme for controls that do not lie in any decoration area. Custom painting code that needs to consult the colors of the specific component should use getColorScheme(Component, ComponentState) method and various SubstanceColorScheme methods.

Returns:
The main default color scheme for this skin.
See Also:
getColorScheme(Component, ComponentState), getMainDefaultColorScheme(DecorationAreaType)

getMainDisabledColorScheme

public SubstanceColorScheme getMainDisabledColorScheme()
Returns the main disabled color scheme for this skin. The result is the disabled color scheme for controls that do not lie in any decoration area. Custom painting code that needs to consult the colors of the specific component should use getColorScheme(Component, ComponentState) method and various SubstanceColorScheme methods.

Returns:
The main disabled color scheme for this skin.
See Also:
getColorScheme(Component, ComponentState), getMainDisabledColorScheme(DecorationAreaType)

getWatermark

public SubstanceWatermark getWatermark()
Returns the watermark of this skin.

Returns:
The watermark of this skin. May be null.

getBorderPainter

public SubstanceBorderPainter getBorderPainter()
Returns the border painter of this skin.

Returns:
The border painter of this skin. A valid skin cannot have a null value returned from this method. Call isValid() to verify that the skin is valid.
See Also:
isValid()

getHighlightBorderPainter

public SubstanceBorderPainter getHighlightBorderPainter()
Returns the highlight border painter of this skin.

Returns:
The highlight border painter of this skin. The return value of this method may be null. In this case, call getBorderPainter().

getButtonShaper

public SubstanceButtonShaper getButtonShaper()
Returns the button shaper of this skin.

Returns:
The button shaper of this skin. A valid skin cannot have a null value returned from this method. Call isValid() to verify that the skin is valid.
See Also:
isValid()

getGradientPainter

public SubstanceGradientPainter getGradientPainter()
Returns the gradient painter of this skin.

Returns:
The gradient painter of this skin. A valid skin cannot have a null value returned from this method. Call isValid() to verify that the skin is valid.
See Also:
isValid()

getHighlightPainter

public SubstanceHighlightPainter getHighlightPainter()
Returns the highlight painter of this skin.

Returns:
The highlight painter of this skin. A valid skin cannot have a null value returned from this method. Call isValid() to verify that the skin is valid.
See Also:
isValid()

getDecorationPainter

public SubstanceDecorationPainter getDecorationPainter()
Returns the decoration painter of this skin.

Returns:
The decoration painter of this skin. A valid skin cannot have a null value returned from this method. Call isValid() to verify that the skin is valid.
See Also:
isValid()

addCustomEntriesToTable

public void addCustomEntriesToTable(javax.swing.UIDefaults table)
Adds skin-specific entries to the UI defaults table.

Parameters:
table - UI defaults table.

getColorScheme

public SubstanceColorScheme getColorScheme(java.awt.Component comp,
                                           ComponentState componentState)
Returns the color scheme of the specified component in the specified component state.

Parameters:
comp - Component.
componentState - Component state.
Returns:
The color scheme of the component in the specified component state.

getHighlightColorScheme

@Deprecated
public SubstanceColorScheme getHighlightColorScheme(java.awt.Component comp,
                                                               ComponentState componentState)
Deprecated. Use getColorScheme(Component, ColorSchemeAssociationKind, ComponentState) with ColorSchemeAssociationKind.HIGHLIGHT instead. This method will be removed in version 6.0.

Returns the highlight color scheme of the component.

Parameters:
comp - Component.
componentState - Component state.
Returns:
Component highlight color scheme.

getHighlightAlpha

public float getHighlightAlpha(java.awt.Component comp,
                               ComponentState componentState)
Returns the alpha channel of the highlight color scheme of the component.

Parameters:
comp - Component.
componentState - Component state.
Returns:
Highlight color scheme alpha channel.

getAlpha

public float getAlpha(java.awt.Component comp,
                      ComponentState componentState)
Returns the alpha channel of the color scheme of the component.

Parameters:
comp - Component.
componentState - Component state.
Returns:
Color scheme alpha channel.

registerDecorationAreaSchemeBundle

public void registerDecorationAreaSchemeBundle(SubstanceColorSchemeBundle bundle,
                                               SubstanceColorScheme backgroundColorScheme,
                                               DecorationAreaType... areaTypes)
Registers the specified color scheme bundle and background color scheme to be used on controls in decoration areas.

Parameters:
bundle - The color scheme bundle to use on controls in decoration areas.
backgroundColorScheme - The color scheme to use for background of controls in decoration areas.
areaTypes - Enumerates the area types that are affected by the parameters.

registerDecorationAreaSchemeBundle

public void registerDecorationAreaSchemeBundle(SubstanceColorSchemeBundle bundle,
                                               DecorationAreaType... areaTypes)
Registers the specified color scheme bundle to be used on controls in decoration areas.

Parameters:
bundle - The color scheme bundle to use on controls in decoration areas.
areaTypes - Enumerates the area types that are affected by the parameters.

registerAsDecorationArea

public void registerAsDecorationArea(SubstanceColorScheme backgroundColorScheme,
                                     DecorationAreaType... areaTypes)
Registers the specified background color scheme to be used on controls in decoration areas.

Parameters:
backgroundColorScheme - The color scheme to use for background of controls in decoration areas.
areaTypes - Enumerates the area types that are affected by the parameters. Each decoration area type will be painted by SubstanceDecorationPainter.paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin) .

isRegisteredAsDecorationArea

public boolean isRegisteredAsDecorationArea(DecorationAreaType decorationType)
Returns indication whether the specified decoration area type should have their background painted by SubstanceDecorationPainter.paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin) instead of a simple background fill.

Parameters:
decorationType - Decoration area type.
Returns:
true if specified decoration area type should have their background painted by SubstanceDecorationPainter.paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin) , false otherwise.

getWatermarkColorScheme

public SubstanceColorScheme getWatermarkColorScheme()
Returns the color scheme to be used for painting the watermark. If no custom watermark color scheme is specified (watermarkScheme is null), the main default color scheme of this skin is used.

Returns:
The color scheme to be used for painting the watermark.

getMainActiveColorScheme

public SubstanceColorScheme getMainActiveColorScheme(DecorationAreaType decorationAreaType)
Returns the main active color scheme for the specific decoration area type. Custom painting code that needs to consult the colors of the specific component should use getColorScheme(Component, ComponentState) method and various SubstanceColorScheme methods.

Parameters:
decorationAreaType - Decoration area type.
Returns:
The main active color scheme for this skin.
See Also:
getColorScheme(Component, ComponentState), getMainActiveColorScheme()

getMainDefaultColorScheme

public SubstanceColorScheme getMainDefaultColorScheme(DecorationAreaType decorationAreaType)
Returns the main default color scheme for the specific decoration area type. Custom painting code that needs to consult the colors of the specific component should use getColorScheme(Component, ComponentState) method and various SubstanceColorScheme methods.

Parameters:
decorationAreaType - Decoration area type.
Returns:
The main default color scheme for this skin.
See Also:
getColorScheme(Component, ComponentState), getMainDefaultColorScheme()

getMainDisabledColorScheme

public SubstanceColorScheme getMainDisabledColorScheme(DecorationAreaType decorationAreaType)
Returns the main disabled color scheme for the specific decoration area type. Custom painting code that needs to consult the colors of the specific component should use getColorScheme(Component, ComponentState) method and various SubstanceColorScheme methods.

Parameters:
decorationAreaType - Decoration area type.
Returns:
The main disabled color scheme for this skin.
See Also:
getColorScheme(Component, ComponentState), getMainDisabledColorScheme()

getSelectedTabFadeStart

public double getSelectedTabFadeStart()
Returns the start of fade effect on the selected tabs in JTabbedPanes. This value can be used to create XP-like "headers" on the selected tabs.

Returns:
The start of fade effect on the selected tabs in JTabbedPanes.
See Also:
getSelectedTabFadeEnd()

getSelectedTabFadeEnd

public double getSelectedTabFadeEnd()
Returns the end of fade effect on the selected tabs in JTabbedPanes. This value can be used to create XP-like "headers" on the selected tabs.

Returns:
The end of fade effect on the selected tabs in JTabbedPanes.
See Also:
getSelectedTabFadeStart()

setSelectedTabFadeEnd

public void setSelectedTabFadeEnd(double selectedTabFadeEnd)
Sets the end of fade effect on the selected tabs in JTabbedPanes. The value should be in 0.0-1.0 range.

Parameters:
selectedTabFadeEnd - The end of fade effect on the selected tabs in JTabbedPanes. Should be in 0.0-1.0 range.

setSelectedTabFadeStart

public void setSelectedTabFadeStart(double selectedTabFadeStart)
Sets the start of fade effect on the selected tabs in JTabbedPane s. The value should be in 0.0-1.0 range.

Parameters:
selectedTabFadeStart - The start of fade effect on the selected tabs in JTabbedPane s. Should be in 0.0-1.0 range.

isPaintingDropShadows

public boolean isPaintingDropShadows(DecorationAreaType decorationAreaType)
Returns indication whether the specified decoration area type should paint drop shadows on the top few pixels.

Parameters:
decorationAreaType - Decoration area type.
Returns:
true if the specified decoration area type should paint drop shadows on the top few pixels, false otherwise.
See Also:
setPaintingDropShadows(DecorationAreaType), unsetPaintingDropShadows(DecorationAreaType)

setPaintingDropShadows

public void setPaintingDropShadows(DecorationAreaType decorationAreaType)
Marks the specified area type to have drop shadows on the top few pixels.

Parameters:
decorationAreaType - Decoration areas of this type will have drop shadows on the top few pixels.
See Also:
unsetPaintingDropShadows(DecorationAreaType), isPaintingDropShadows(DecorationAreaType)

unsetPaintingDropShadows

public void unsetPaintingDropShadows(DecorationAreaType decorationAreaType)
Marks the specified area type to not have drop shadows on the top few pixels.

Parameters:
decorationAreaType - Decoration areas of this type will not have drop shadows on the top few pixels.
See Also:
setPaintingDropShadows(DecorationAreaType), isPaintingDropShadows(DecorationAreaType)

getColorScheme

public SubstanceColorScheme getColorScheme(java.awt.Component comp,
                                           ColorSchemeAssociationKind associationKind,
                                           ComponentState componentState)
Returns the color scheme to be used for painting the specified visual area of the component under the specified component state.

Parameters:
comp - Component.
associationKind - Color scheme association kind.
componentState - Component state.
Returns:
Color scheme to be used for painting the specified visual area of the component under the specified component state.
Since:
version 5.1

getBorderColorScheme

@Deprecated
public SubstanceColorScheme getBorderColorScheme(java.awt.Component comp,
                                                            ComponentState componentState)
Deprecated. Use getColorScheme(Component, ColorSchemeAssociationKind, ComponentState) with ColorSchemeAssociationKind.BORDER instead. This method will be removed in version 6.0.

Returns the border color scheme of the component.

Parameters:
comp - Component.
componentState - Component state.
Returns:
Component border color scheme.

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

transform

public SubstanceSkin transform(ColorSchemeTransform transform,
                               java.lang.String name)
Creates a new skin that has the same settings as this skin with the addition of applying the specified color scheme transformation on all the relevant color schemes.

Parameters:
transform - Color scheme transformation.
name - The name of the new skin.
Returns:
The new skin.

withWatermark

public SubstanceSkin withWatermark(SubstanceWatermark watermark)
Creates a clone of this skin with the specified watermark. This is mainly targeting sample applications and docrobot. Applications are encouraged to create a custom skin by either extending one of the core Substance skins, or by extending the SubstanceSkin directly.

Parameters:
watermark - Watermark for the new skin.
Returns:
A clone of this skin with the specified watermark.

getBackgroundColorScheme

public SubstanceColorScheme getBackgroundColorScheme(DecorationAreaType decorationAreaType)
Returns the background color scheme for the specified decoration area type. This method is mainly for the internal use of SubstanceDecorationPainter.paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin) , but can be used in applications that wish to provide custom overlay background painting (such as watermarks, for example).

Parameters:
decorationAreaType - Decoration area type.
Returns:
The background color scheme for the specified decoration area type.

isValid

public boolean isValid()
Checks whether this skin is valid. A valid skin must have a color scheme bundle for DecorationAreaType.NONE and non-null button shaper, gradient painter, border painter, highlight painter and decoration painter. If call to SubstanceLookAndFeel.setSkin(String) or SubstanceLookAndFeel.setSkin(SubstanceSkin) does not seem to have any visible effect (returning false), call this method to verify that your skin is valid.

Returns:
true if this skin is valid, false otherwise.

getColorSchemes

public static java.util.Map<java.lang.String,SubstanceColorScheme> getColorSchemes(java.net.URL url)
Returns the collection of color schemes in the specified URL.

Parameters:
url - URL that points to a resource containing the description of Substance color schemes.
Returns:
The collection of color schemes in the specified URL.
Since:
version 5.2