Package org.pushingpixels.substance.api
Class SubstanceSkin
- java.lang.Object
-
- org.pushingpixels.substance.api.SubstanceSkin
-
- All Implemented Interfaces:
SubstanceTrait
- Direct Known Subclasses:
AutumnSkin
,BusinessBlackSteelSkin
,BusinessBlueSteelSkin
,BusinessSkin
,CeruleanSkin
,ChallengerDeepSkin
,CremeCoffeeSkin
,CremeSkin
,DustSkin
,EmeraldDuskSkin
,GeminiSkin
,GraphiteAquaSkin
,GraphiteGlassSkin
,GraphiteSkin
,MagellanSkin
,MarinerSkin
,MistAquaSkin
,MistSilverSkin
,ModerateSkin
,NebulaSkin
,OfficeBlack2007Skin
,OfficeBlue2007Skin
,OfficeSilver2007Skin
,RavenSkin
,SaharaSkin
,TwilightSkin
public abstract class SubstanceSkin extends Object implements SubstanceTrait
Base abstract class for Substance skins.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SubstanceSkin.ColorSchemes
Contains information on color schemes loaded by thegetColorSchemes(URL)
andgetColorSchemes(String)
APIs.
-
Field Summary
Fields Modifier and Type Field Description protected Map<DecorationAreaType,SubstanceColorScheme>
backgroundColorSchemeMap
Maps decoration area type to the background color schemes.protected SubstanceBorderPainter
borderPainter
The border painter ofthis
skin.protected SubstanceButtonShaper
buttonShaper
The button shaper ofthis
skin.protected Map<DecorationAreaType,SubstanceColorSchemeBundle>
colorSchemeBundleMap
Maps decoration area type to the color scheme bundles.protected Set<DecorationAreaType>
decoratedAreaSet
Set of all decoration area types that are not explicitly registered incolorSchemeBundleMap
but still are considered as decoration areas in this skin.protected SubstanceDecorationPainter
decorationPainter
The decoration painter ofthis
skin.protected SubstanceFillPainter
fillPainter
The fill painter ofthis
skin.protected SubstanceBorderPainter
highlightBorderPainter
The highlight border painter ofthis
skin.protected SubstanceHighlightPainter
highlightPainter
The highlight painter ofthis
skin.protected Map<DecorationAreaType,List<SubstanceOverlayPainter>>
overlayPaintersMap
Maps decoration area type to the registered overlay painters.protected double
selectedTabFadeEnd
The end of fade effect on the selected tabs inJTabbedPane
s.protected double
selectedTabFadeStart
The start of fade effect on the selected tabs inJTabbedPane
s.protected SubstanceWatermark
watermark
The watermark ofthis
skin.protected SubstanceColorScheme
watermarkScheme
Color scheme for watermarks.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SubstanceSkin()
Constructs the basic data structures for a skin.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCustomEntriesToTable(UIDefaults table)
Adds skin-specific entries to the UI defaults table.void
addOverlayPainter(SubstanceOverlayPainter overlayPainter, DecorationAreaType... areaTypes)
Adds the specified overlay painter to the end of the list of overlay painters associated with the specified decoration area types.SubstanceColorScheme
getActiveColorScheme(DecorationAreaType decorationAreaType)
Returns the main active color scheme for the specific decoration area type.float
getAlpha(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.SubstanceBorderPainter
getBorderPainter()
Returns the border painter of this skin.SubstanceButtonShaper
getButtonShaper()
Returns the button shaper of this skin.SubstanceColorScheme
getColorScheme(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(Component comp, ComponentState componentState)
Returns the color scheme of the specified component in the specified component state.SubstanceColorScheme
getColorScheme(DecorationAreaType decorationAreaType, ColorSchemeAssociationKind associationKind, ComponentState componentState)
Returns the color scheme to be used for painting the specified visual area of components in the specified decoration area.static SubstanceSkin.ColorSchemes
getColorSchemes(String resourceName)
Returns the collection of color schemes in the specified URL.static SubstanceSkin.ColorSchemes
getColorSchemes(URL url)
Returns the collection of color schemes in the specified URL.SubstanceDecorationPainter
getDecorationPainter()
Returns the decoration painter of this skin.SubstanceColorScheme
getDisabledColorScheme(DecorationAreaType decorationAreaType)
Returns the main disabled color scheme for the specific decoration area type.SubstanceColorScheme
getEnabledColorScheme(DecorationAreaType decorationAreaType)
Returns the main enabled color scheme for the specific decoration area type.SubstanceFillPainter
getFillPainter()
Returns the fill painter of this skin.float
getHighlightAlpha(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.SubstanceHighlightPainter
getHighlightPainter()
Returns the highlight painter of this skin.List<SubstanceOverlayPainter>
getOverlayPainters(DecorationAreaType decorationAreaType)
Returns a non-null, non-modifiable list of overlay painters associated with the specified decoration area type.double
getSelectedTabFadeEnd()
Returns the end of fade effect on the selected tabs inJTabbedPane
s.double
getSelectedTabFadeStart()
Returns the start of fade effect on the selected tabs inJTabbedPane
s.SubstanceWatermark
getWatermark()
Returns the watermark of this skin.SubstanceColorScheme
getWatermarkColorScheme()
Returns the color scheme to be used for painting the watermark.boolean
isRegisteredAsDecorationArea(DecorationAreaType decorationType)
Returns indication whether the specified decoration area type should have their background painted bySubstanceDecorationPainter.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
removeOverlayPainter(SubstanceOverlayPainter overlayPainter, DecorationAreaType... areaTypes)
Removes the specified overlay painter from the list of overlay painters associated with the specified decoration area types.void
setSelectedTabFadeEnd(double selectedTabFadeEnd)
Sets the end of fade effect on the selected tabs inJTabbedPane
s.void
setSelectedTabFadeStart(double selectedTabFadeStart)
Sets the start of fade effect on the selected tabs inJTabbedPane
s.SubstanceSkin
transform(ColorSchemeTransform transform, 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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pushingpixels.substance.api.trait.SubstanceTrait
getDisplayName
-
-
-
-
Field Detail
-
colorSchemeBundleMap
protected Map<DecorationAreaType,SubstanceColorSchemeBundle> colorSchemeBundleMap
Maps decoration area type to the color scheme bundles. Must contain an entry forDecorationAreaType.NONE
.
-
backgroundColorSchemeMap
protected Map<DecorationAreaType,SubstanceColorScheme> backgroundColorSchemeMap
Maps decoration area type to the background color schemes.
-
overlayPaintersMap
protected Map<DecorationAreaType,List<SubstanceOverlayPainter>> overlayPaintersMap
Maps decoration area type to the registered overlay painters. Each decoration area type can have more than one overlay painter.
-
watermark
protected SubstanceWatermark watermark
The watermark ofthis
skin. May benull
ifthis
skin doesn't define a custom watermark.
-
buttonShaper
protected SubstanceButtonShaper buttonShaper
The button shaper ofthis
skin. Must be non-null
.
-
fillPainter
protected SubstanceFillPainter fillPainter
The fill painter ofthis
skin. Must be non-null
.
-
borderPainter
protected SubstanceBorderPainter borderPainter
The border painter ofthis
skin. Must be non-null
.
-
highlightBorderPainter
protected SubstanceBorderPainter highlightBorderPainter
The highlight border painter ofthis
skin. Can benull
.
-
highlightPainter
protected SubstanceHighlightPainter highlightPainter
The highlight painter ofthis
skin. Must be non-null
.
-
decorationPainter
protected SubstanceDecorationPainter decorationPainter
The decoration painter ofthis
skin. Must be non-null
.
-
decoratedAreaSet
protected Set<DecorationAreaType> decoratedAreaSet
Set of all decoration area types that are not explicitly registered incolorSchemeBundleMap
but still are considered as decoration areas in this skin. Controls lying in such areas will have their background painted bySubstanceDecorationPainter.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 inJTabbedPane
s.- See Also:
selectedTabFadeEnd
-
selectedTabFadeEnd
protected double selectedTabFadeEnd
The end of fade effect on the selected tabs inJTabbedPane
s.- See Also:
selectedTabFadeStart
-
watermarkScheme
protected SubstanceColorScheme watermarkScheme
Color scheme for watermarks.
-
-
Method Detail
-
getWatermark
public final SubstanceWatermark getWatermark()
Returns the watermark of this skin.- Returns:
- The watermark of this skin. May be
null
.
-
getBorderPainter
public final SubstanceBorderPainter getBorderPainter()
Returns the border painter of this skin.
-
getHighlightBorderPainter
public final 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, callgetBorderPainter()
.
-
getButtonShaper
public final SubstanceButtonShaper getButtonShaper()
Returns the button shaper of this skin.
-
getFillPainter
public final SubstanceFillPainter getFillPainter()
Returns the fill painter of this skin.
-
getHighlightPainter
public final SubstanceHighlightPainter getHighlightPainter()
Returns the highlight painter of this skin.
-
getDecorationPainter
public final SubstanceDecorationPainter getDecorationPainter()
Returns the decoration painter of this skin.
-
addCustomEntriesToTable
public void addCustomEntriesToTable(UIDefaults table)
Adds skin-specific entries to the UI defaults table.- Parameters:
table
- UI defaults table.
-
getColorScheme
public final SubstanceColorScheme getColorScheme(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.
-
getHighlightAlpha
public final float getHighlightAlpha(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 final float getAlpha(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 bySubstanceDecorationPainter.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 bySubstanceDecorationPainter.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 bySubstanceDecorationPainter.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
isnull
), the main default color scheme of this skin is used.- Returns:
- The color scheme to be used for painting the watermark.
-
getActiveColorScheme
public final SubstanceColorScheme getActiveColorScheme(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 usegetColorScheme(Component, ComponentState)
method and variousSubstanceColorScheme
methods.- Parameters:
decorationAreaType
- Decoration area type.- Returns:
- The main active color scheme for this skin.
- See Also:
getColorScheme(Component, ComponentState)
-
getEnabledColorScheme
public final SubstanceColorScheme getEnabledColorScheme(DecorationAreaType decorationAreaType)
Returns the main enabled color scheme for the specific decoration area type. Custom painting code that needs to consult the colors of the specific component should usegetColorScheme(Component, ComponentState)
method and variousSubstanceColorScheme
methods.- Parameters:
decorationAreaType
- Decoration area type.- Returns:
- The main enabled color scheme for this skin.
- See Also:
getColorScheme(Component, ComponentState)
-
getDisabledColorScheme
public final SubstanceColorScheme getDisabledColorScheme(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 usegetColorScheme(Component, ComponentState)
method and variousSubstanceColorScheme
methods.- Parameters:
decorationAreaType
- Decoration area type.- Returns:
- The main disabled color scheme for this skin.
- See Also:
getColorScheme(Component, ComponentState)
-
getSelectedTabFadeStart
public final double getSelectedTabFadeStart()
Returns the start of fade effect on the selected tabs inJTabbedPane
s. 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
JTabbedPane
s. - See Also:
getSelectedTabFadeEnd()
-
getSelectedTabFadeEnd
public final double getSelectedTabFadeEnd()
Returns the end of fade effect on the selected tabs inJTabbedPane
s. 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
JTabbedPane
s. - See Also:
getSelectedTabFadeStart()
-
setSelectedTabFadeEnd
public void setSelectedTabFadeEnd(double selectedTabFadeEnd)
Sets the end of fade effect on the selected tabs inJTabbedPane
s. The value should be in 0.0-1.0 range.- Parameters:
selectedTabFadeEnd
- The end of fade effect on the selected tabs inJTabbedPane
s. Should be in 0.0-1.0 range.
-
setSelectedTabFadeStart
public void setSelectedTabFadeStart(double selectedTabFadeStart)
Sets the start of fade effect on the selected tabs inJTabbedPane
s. The value should be in 0.0-1.0 range.- Parameters:
selectedTabFadeStart
- The start of fade effect on the selected tabs inJTabbedPane
s. Should be in 0.0-1.0 range.
-
addOverlayPainter
public void addOverlayPainter(SubstanceOverlayPainter overlayPainter, DecorationAreaType... areaTypes)
Adds the specified overlay painter to the end of the list of overlay painters associated with the specified decoration area types.- Parameters:
overlayPainter
- Overlay painter to add to the end of the list of overlay painters associated with the specified decoration area types.areaTypes
- Decoration area types.
-
removeOverlayPainter
public void removeOverlayPainter(SubstanceOverlayPainter overlayPainter, DecorationAreaType... areaTypes)
Removes the specified overlay painter from the list of overlay painters associated with the specified decoration area types.- Parameters:
overlayPainter
- Overlay painter to remove from the list of overlay painters associated with the specified decoration area types.areaTypes
- Decoration area types.
-
getOverlayPainters
public List<SubstanceOverlayPainter> getOverlayPainters(DecorationAreaType decorationAreaType)
Returns a non-null, non-modifiable list of overlay painters associated with the specified decoration area type.- Parameters:
decorationAreaType
- Decoration area type.- Returns:
- A non-null, non-modifiable list of overlay painters associated with the specified decoration area type.
-
getColorScheme
public final SubstanceColorScheme getColorScheme(DecorationAreaType decorationAreaType, ColorSchemeAssociationKind associationKind, ComponentState componentState)
Returns the color scheme to be used for painting the specified visual area of components in the specified decoration area.- Parameters:
decorationAreaType
- Decoration area type.associationKind
- Color scheme association kind.componentState
- Component state.- Returns:
- Color scheme to be used for painting the specified visual area of components in the specified decoration area.
- Since:
- version 5.3
-
getColorScheme
public final SubstanceColorScheme getColorScheme(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
-
transform
public SubstanceSkin transform(ColorSchemeTransform transform, 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.
-
getBackgroundColorScheme
public final SubstanceColorScheme getBackgroundColorScheme(DecorationAreaType decorationAreaType)
Returns the background color scheme for the specified decoration area type. This method is mainly for the internal use ofSubstanceDecorationPainter.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 forDecorationAreaType.NONE
and non-null
button shaper, gradient painter, border painter, highlight painter and decoration painter. If call toSubstanceLookAndFeel.setSkin(String)
orSubstanceLookAndFeel.setSkin(SubstanceSkin)
does not seem to have any visible effect (returningfalse
), call this method to verify that your skin is valid.- Returns:
true
if this skin is valid,false
otherwise.
-
getColorSchemes
public static SubstanceSkin.ColorSchemes getColorSchemes(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
-
getColorSchemes
public static SubstanceSkin.ColorSchemes getColorSchemes(String resourceName)
Returns the collection of color schemes in the specified URL.- Parameters:
resourceName
- Name of the resource containing the description of Substance color schemes.- Returns:
- The collection of color schemes in the specified URL.
- Since:
- version 6.0
-
-