com.alee.managers.style
Class StyleManager

java.lang.Object
  extended by com.alee.managers.style.StyleManager

public final class StyleManager
extends java.lang.Object

This class manages WebLaF component styles. It also manages available WebLaF skins and can install/change them in runtime.

Author:
Mikle Garin
See Also:
How to use StyleManager, WebLafSkin, SkinInfo

Field Summary
static java.lang.String DEFAULT_PAINTER_ID
          Default painter ID.
 
Constructor Summary
StyleManager()
           
 
Method Summary
static WebLafSkin applyDefaultSkin()
          Applies default skin to all existing skinnable components.
static WebLafSkin applySkin(java.lang.Class skinClass)
          Applies specified skin to all existing skinnable components.
static WebLafSkin applySkin(javax.swing.JComponent component)
          Applies current skin to the skinnable component.
static WebLafSkin applySkin(javax.swing.JComponent component, WebLafSkin skin)
          Applies specified skin to the skinnable component.
static WebLafSkin applySkin(java.lang.String skinClassName)
          Applies specified skin to all existing skinnable components.
static WebLafSkin applySkin(WebLafSkin skin)
          Applies specified skin to all existing skinnable components.
static void clearCustomPainterProperties(javax.swing.JComponent component)
          Clears all custom painter properties for the specified component.
static WebLafSkin createSkin(java.lang.Class skinClass)
          Returns newly created skin class instance.
static WebLafSkin getCurrentSkin()
          Returns currently applied skin.
static java.util.Map<javax.swing.JComponent,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>> getCustomPainterProperties()
          Returns all custom painter properties.
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> getCustomPainterProperties(javax.swing.JComponent component)
          Returns all custom painter properties for the specified component.
static java.util.Map<javax.swing.JComponent,java.util.Map<java.lang.String,Painter>> getCustomPainters()
          Returns all custom painters.
static java.util.Map<java.lang.String,Painter> getCustomPainters(javax.swing.JComponent component)
          Returns all custom painters for the specified component.
static WebLafSkin getDefaultSkin()
          Returns default skin.
static
<T extends Painter>
T
getPainter(javax.swing.JComponent component)
          Returns painter for the specified component.
static
<T extends Painter>
T
getPainter(javax.swing.JComponent component, java.lang.String painterId)
          Returns painter for the specified component and painter ID.
static
<T> T
getPainterPropertyValue(javax.swing.JComponent component, java.lang.String key)
          Returns painter property value from the specified component.
static
<T> T
getPainterPropertyValue(javax.swing.JComponent component, java.lang.String painterId, java.lang.String key)
          Returns painter property value from the specified component.
static void initialize()
          Initializes StyleManager settings.
static boolean isStrictStyleChecks()
          Returns whether strict style checks are enabled or not.
static void removeCustomPainters(javax.swing.JComponent component)
          Removes all custom painters from the specified component.
static WebLafSkin removeSkin(javax.swing.JComponent component)
          Removes skin applied to the specified component and returns it.
static
<T extends Painter>
T
setCustomPainter(javax.swing.JComponent component, java.lang.String id, T painter)
          Sets custom painter for the specified component.
static
<T extends Painter>
T
setCustomPainter(javax.swing.JComponent component, T painter)
          Sets custom default painter for the specified component.
static
<T> T
setCustomPainterProperty(javax.swing.JComponent component, java.lang.String painterId, java.lang.String key, T value)
          Sets custom value for painter property for the specified component.
static
<T> T
setCustomPainterProperty(javax.swing.JComponent component, java.lang.String key, T value)
          Sets custom value for painter property for the specified component.
static WebLafSkin setDefaultSkin(java.lang.Class skinClass)
          Sets default skin.
static WebLafSkin setDefaultSkin(java.lang.String skinClassName)
          Sets default skin.
static WebLafSkin setDefaultSkin(WebLafSkin skin)
          Sets default skin.
static void setStrictStyleChecks(boolean strict)
          Sets whether strict style checks are enabled or not.
static boolean setStyleId(java.awt.Component component, java.lang.String styleId)
          Sets component style ID if component or its UI is instance of Styleable interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PAINTER_ID

public static final java.lang.String DEFAULT_PAINTER_ID
Default painter ID.

See Also:
Constant Field Values
Constructor Detail

StyleManager

public StyleManager()
Method Detail

initialize

public static void initialize()
Initializes StyleManager settings.


isStrictStyleChecks

public static boolean isStrictStyleChecks()
Returns whether strict style checks are enabled or not.

Returns:
true if strict style checks are enabled, false otherwise

setStrictStyleChecks

public static void setStrictStyleChecks(boolean strict)
Sets whether strict style checks are enabled or not.

Parameters:
strict - whether strict style checks are enabled or not

getDefaultSkin

public static WebLafSkin getDefaultSkin()
Returns default skin.

Returns:
default skin

setDefaultSkin

public static WebLafSkin setDefaultSkin(java.lang.String skinClassName)
Sets default skin.

Parameters:
skinClassName - default skin class name
Returns:
previous default skin

setDefaultSkin

public static WebLafSkin setDefaultSkin(java.lang.Class skinClass)
Sets default skin.

Parameters:
skinClass - default skin class
Returns:
previous default skin

createSkin

public static WebLafSkin createSkin(java.lang.Class skinClass)
Returns newly created skin class instance.

Parameters:
skinClass - skin class
Returns:
newly created skin class instance

setDefaultSkin

public static WebLafSkin setDefaultSkin(WebLafSkin skin)
Sets default skin.

Parameters:
skin - default skin
Returns:
previous default skin

applyDefaultSkin

public static WebLafSkin applyDefaultSkin()
Applies default skin to all existing skinnable components. This skin will also be applied to all skinnable components created afterwards.

Returns:
previously applied skin

getCurrentSkin

public static WebLafSkin getCurrentSkin()
Returns currently applied skin.

Returns:
currently applied skin

applySkin

public static WebLafSkin applySkin(java.lang.String skinClassName)
Applies specified skin to all existing skinnable components. This skin will also be applied to all skinnable components created afterwards.

Parameters:
skinClassName - class name of the skin to be applied
Returns:
previously applied skin

applySkin

public static WebLafSkin applySkin(java.lang.Class skinClass)
Applies specified skin to all existing skinnable components. This skin will also be applied to all skinnable components created afterwards.

Parameters:
skinClass - class of the skin to be applied
Returns:
previously applied skin

applySkin

public static WebLafSkin applySkin(WebLafSkin skin)
Applies specified skin to all existing skinnable components. This skin will also be applied to all skinnable components created afterwards.

Parameters:
skin - skin to be applied
Returns:
previously applied skin

applySkin

public static WebLafSkin applySkin(javax.swing.JComponent component)
Applies current skin to the skinnable component.

Parameters:
component - component to apply skin to
Returns:
previously applied skin

applySkin

public static WebLafSkin applySkin(javax.swing.JComponent component,
                                   WebLafSkin skin)
Applies specified skin to the skinnable component. todo Do not replace custom applied skins when current skin changed?

Parameters:
component - component to apply skin to
skin - skin to be applied
Returns:
previously applied skin

removeSkin

public static WebLafSkin removeSkin(javax.swing.JComponent component)
Removes skin applied to the specified component and returns it.

Parameters:
component - component to remove skin from
Returns:
previously applied skin

getPainterPropertyValue

public static <T> T getPainterPropertyValue(javax.swing.JComponent component,
                                            java.lang.String key)
Returns painter property value from the specified component. Specified property is searched only inside the base painter so far.

Type Parameters:
T - style property value type
Parameters:
component - component to retrieve style property from
key - style property key
Returns:
style property value

getPainterPropertyValue

public static <T> T getPainterPropertyValue(javax.swing.JComponent component,
                                            java.lang.String painterId,
                                            java.lang.String key)
Returns painter property value from the specified component. Specified property is searched only inside the base painter so far.

Type Parameters:
T - style property value type
Parameters:
component - component to retrieve style property from
painterId - painter ID
key - style property key
Returns:
style property value

setCustomPainterProperty

public static <T> T setCustomPainterProperty(javax.swing.JComponent component,
                                             java.lang.String key,
                                             T value)
Sets custom value for painter property for the specified component. This tricky method uses component skin to set the specified property into component painter.

Type Parameters:
T - custom style property value type
Parameters:
component - component to apply custom style property to
key - custom style property key
value - custom style property value
Returns:
old custom style property value

setCustomPainterProperty

public static <T> T setCustomPainterProperty(javax.swing.JComponent component,
                                             java.lang.String painterId,
                                             java.lang.String key,
                                             T value)
Sets custom value for painter property for the specified component. This tricky method uses component skin to set the specified property into component painter.

Type Parameters:
T - custom style property value type
Parameters:
component - component to apply custom style property to
painterId - painter ID
key - custom style property key
value - custom style property value
Returns:
old custom style property value

getCustomPainterProperties

public static java.util.Map<javax.swing.JComponent,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>> getCustomPainterProperties()
Returns all custom painter properties. Map structure: JComponent -> painterId -> propertyName -> propertyValue

Returns:
all custom painter properties

getCustomPainterProperties

public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> getCustomPainterProperties(javax.swing.JComponent component)
Returns all custom painter properties for the specified component. Map structure: painterId -> propertyName -> propertyValue

Parameters:
component - component to retrieve custom properties for
Returns:
all custom painter properties for the specified component

clearCustomPainterProperties

public static void clearCustomPainterProperties(javax.swing.JComponent component)
Clears all custom painter properties for the specified component. This is required when painter changes to avoid setting unexisting variables into painter.

Parameters:
component - component to clear custom painter properties for

getPainter

public static <T extends Painter> T getPainter(javax.swing.JComponent component)
Returns painter for the specified component.

Type Parameters:
T - painter type
Parameters:
component - component to retrieve painter from
Returns:
current component painter

getPainter

public static <T extends Painter> T getPainter(javax.swing.JComponent component,
                                               java.lang.String painterId)
Returns painter for the specified component and painter ID.

Type Parameters:
T - painter type
Parameters:
component - component to retrieve painter from
painterId - painter ID
Returns:
current component painter for the specified painter ID

setCustomPainter

public static <T extends Painter> T setCustomPainter(javax.swing.JComponent component,
                                                     T painter)
Sets custom default painter for the specified component. You should call this method when setting painter outside of the UI to avoid

Type Parameters:
T - painter type
Parameters:
component - component to set painter for
painter - painter
Returns:
old custom painter

setCustomPainter

public static <T extends Painter> T setCustomPainter(javax.swing.JComponent component,
                                                     java.lang.String id,
                                                     T painter)
Sets custom painter for the specified component. You should call this method when setting painter outside of the UI to avoid

Type Parameters:
T - painter type
Parameters:
component - component to set painter for
id - painter ID
painter - painter
Returns:
old custom painter

getCustomPainters

public static java.util.Map<javax.swing.JComponent,java.util.Map<java.lang.String,Painter>> getCustomPainters()
Returns all custom painters.

Returns:
all custom painters

getCustomPainters

public static java.util.Map<java.lang.String,Painter> getCustomPainters(javax.swing.JComponent component)
Returns all custom painters for the specified component.

Parameters:
component - component to retrieve custom painters for
Returns:
all custom painters for the specified component

removeCustomPainters

public static void removeCustomPainters(javax.swing.JComponent component)
Removes all custom painters from the specified component.

Parameters:
component - component to remove custom painters from

setStyleId

public static boolean setStyleId(java.awt.Component component,
                                 java.lang.String styleId)
Sets component style ID if component or its UI is instance of Styleable interface. This might be useful in cases when you cannot be sure about component type but want to provide style if possible.

Parameters:
component - component to apply style ID to
styleId - style ID
Returns:
true if style ID was successfully applied, false otherwise