com.alee.managers.style.skin
Class WebLafSkin

java.lang.Object
  extended by com.alee.managers.style.skin.WebLafSkin
Direct Known Subclasses:
CustomSkin

public abstract class WebLafSkin
extends java.lang.Object

This abstract class represents single WebLaF skin. Each skin combines a group of component painters and settings to provide an unique visual style.

Author:
Mikle Garin
See Also:
How to use StyleManager, StyleManager, CustomSkin

Field Summary
static java.lang.String ALL_SYSTEMS_SUPPORTED
          Constant provided in the skin that supports any kind of systems.
 
Constructor Summary
WebLafSkin()
           
 
Method Summary
protected  void applyProperties(java.lang.Object object, java.util.Map<java.lang.String,java.lang.Object> skinProperties, java.util.Map<java.lang.String,java.lang.Object> customProperties)
          Applies properties to specified object fields.
 boolean applySkin(javax.swing.JComponent component)
          Applies this skin to the specified component.
 boolean applySkin(javax.swing.JComponent component, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> customPainterProperties, java.util.Map<java.lang.String,Painter> customPainters)
          Applies this skin to the specified component.
abstract  java.lang.String getAuthor()
          Returns skin author.
abstract  ComponentStyle getComponentStyle(javax.swing.JComponent component, SupportedComponent type)
          Returns style for the specified supported component type.
protected  ComponentStyle getComponentStyleImpl(javax.swing.JComponent component)
          Returns component style.
protected  ComponentStyle getComponentStyleImpl(javax.swing.JComponent component, SupportedComponent type)
          Returns component style.
protected  javax.swing.plaf.ComponentUI getComponentUIImpl(javax.swing.JComponent component)
          Returns component UI object.
protected  java.util.Map<java.lang.String,java.lang.Object> getCustomPainterProperties(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> customPainterProperties, PainterStyle painterStyle, java.lang.String painterId)
          Returns custom painter properties based on painter ID.
abstract  java.lang.String getDescription()
          Returns skin description.
static
<T> T
getFieldValue(java.lang.Object object, java.lang.String field)
          Returns object field value.
abstract  java.lang.String getId()
          Returns unique skin ID.
abstract  java.lang.String getName()
          Returns skin name.
<T extends Painter>
T
getPainter(javax.swing.JComponent component, java.lang.String painterId)
          Returns component painter for the specified painter ID.
<T> T
getPainterPropertyValue(javax.swing.JComponent component, java.lang.String key)
          Returns painter property value from the specified component.
<T> T
getPainterPropertyValue(javax.swing.JComponent component, java.lang.String painterId, java.lang.String key)
          Returns painter property value from the specified component.
abstract  java.lang.String getSkinClass()
          Returns skin base class name.
protected  SupportedComponent getSupportedComponentTypeImpl(javax.swing.JComponent component)
          Returns component type.
abstract  java.util.List<java.lang.String> getSupportedSystems()
          Returns list of supported OS.
 boolean isSupported()
          Returns whether this skin is supported or not.
 boolean removeSkin(javax.swing.JComponent component)
          Removes this skin from the specified component.
 boolean setCustomPainterProperty(javax.swing.JComponent component, java.lang.String key, java.lang.Object value)
          Sets custom value for painter property for the specified component.
 boolean setCustomPainterProperty(javax.swing.JComponent component, java.lang.String painterId, java.lang.String key, java.lang.Object value)
          Sets custom value for painter property for the specified component.
static boolean setFieldValue(java.lang.Object object, java.lang.String field, java.lang.Object value)
          Applies specified value to object field.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_SYSTEMS_SUPPORTED

public static final java.lang.String ALL_SYSTEMS_SUPPORTED
Constant provided in the skin that supports any kind of systems.

See Also:
Constant Field Values
Constructor Detail

WebLafSkin

public WebLafSkin()
Method Detail

getId

public abstract java.lang.String getId()
Returns unique skin ID. Used to collect and manage skins within StyleManager.

Returns:
unique skin ID

getName

public abstract java.lang.String getName()
Returns skin name.

Returns:
skin name

getDescription

public abstract java.lang.String getDescription()
Returns skin description.

Returns:
skin description

getAuthor

public abstract java.lang.String getAuthor()
Returns skin author.

Returns:
skin author

getSupportedSystems

public abstract java.util.List<java.lang.String> getSupportedSystems()
Returns list of supported OS.

Returns:
list of supported OS

isSupported

public boolean isSupported()
Returns whether this skin is supported or not. This method reflects the default mechanism of checking skin support. You can override it in your own skin to provide any custom checks.

Returns:
true if this skin is supported, false otherwise

getSkinClass

public abstract java.lang.String getSkinClass()
Returns skin base class name.

Returns:
skin base class name

getComponentStyle

public abstract ComponentStyle getComponentStyle(javax.swing.JComponent component,
                                                 SupportedComponent type)
Returns style for the specified supported component type. Custom style ID can be specified in any Web-component or Web-UI to override default component style. If style for such custom ID is not found in skin descriptor then default style for that component is used.

Parameters:
component - component instance
type - component type
Returns:
component style

getSupportedComponentTypeImpl

protected SupportedComponent getSupportedComponentTypeImpl(javax.swing.JComponent component)
Returns component type.

Parameters:
component - component instance
Returns:
component type

getComponentStyleImpl

protected ComponentStyle getComponentStyleImpl(javax.swing.JComponent component)
Returns component style. This method does a check that style exists in addition to abstract one.

Parameters:
component - component instance
Returns:
component style

getComponentStyleImpl

protected ComponentStyle getComponentStyleImpl(javax.swing.JComponent component,
                                               SupportedComponent type)
Returns component style. This method does a check that style exists in addition to abstract one.

Parameters:
component - component instance
type - component type
Returns:
component style

getComponentUIImpl

protected javax.swing.plaf.ComponentUI getComponentUIImpl(javax.swing.JComponent component)
Returns component UI object.

Parameters:
component - component instance
Returns:
component UI object

applySkin

public boolean applySkin(javax.swing.JComponent component)
Applies this skin to the specified component. Returns whether sking was successfully applied or not.

Parameters:
component - component to apply skin to
Returns:
true if skin was applied, false otherwise

applySkin

public boolean applySkin(javax.swing.JComponent component,
                         java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> customPainterProperties,
                         java.util.Map<java.lang.String,Painter> customPainters)
Applies this skin to the specified component. Returns whether sking was successfully applied or not.

Parameters:
component - component to apply skin to
customPainterProperties - custom painter properties to apply
customPainters - custom painters to apply
Returns:
true if skin was applied, false otherwise

getCustomPainterProperties

protected java.util.Map<java.lang.String,java.lang.Object> getCustomPainterProperties(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> customPainterProperties,
                                                                                      PainterStyle painterStyle,
                                                                                      java.lang.String painterId)
Returns custom painter properties based on painter ID.

Parameters:
customPainterProperties - all custom painter properties
painterStyle - painter style
painterId - painter ID
Returns:
specific custom painter properties

removeSkin

public boolean removeSkin(javax.swing.JComponent component)
Removes this skin from the specified component.

Parameters:
component - component to remove skin from
Returns:
true if skin was successfully removed, false otherwise

getPainterPropertyValue

public <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 <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 boolean setCustomPainterProperty(javax.swing.JComponent component,
                                        java.lang.String key,
                                        java.lang.Object value)
Sets custom value for painter property for the specified component. This tricky method retrieves component painter throught its UI and skin settings and applies the specified style property.

Parameters:
component - component to apply custom style property to
key - custom style property key
value - custom style property value
Returns:
true if custom style property was applied, false otherwise

setCustomPainterProperty

public boolean setCustomPainterProperty(javax.swing.JComponent component,
                                        java.lang.String painterId,
                                        java.lang.String key,
                                        java.lang.Object value)
Sets custom value for painter property for the specified component. This tricky method retrieves component painter throught its UI and skin settings and applies the specified style property.

Parameters:
component - component to apply custom style property to
painterId - painter ID
key - custom style property key
value - custom style property value
Returns:
true if custom style property was applied, false otherwise

applyProperties

protected void applyProperties(java.lang.Object object,
                               java.util.Map<java.lang.String,java.lang.Object> skinProperties,
                               java.util.Map<java.lang.String,java.lang.Object> customProperties)
Applies properties to specified object fields.

Parameters:
object - object instance
skinProperties - skin properties to apply, these properties come from the skin
customProperties - custom properties to apply, these properties are provided directly into the specific component

setFieldValue

public static boolean setFieldValue(java.lang.Object object,
                                    java.lang.String field,
                                    java.lang.Object value)
Applies specified value to object field. This method allows to access and modify even private object fields. Note that this method might also work even if there is no real field with the specified name but there is fitting setter method.

Parameters:
object - object instance
field - object field
value - field value
Returns:
true if value was applied successfully, false otherwise

getFieldValue

public static <T> T getFieldValue(java.lang.Object object,
                                  java.lang.String field)
Returns object field value. This method allows to access even private object fields. Note that this method might also work even if there is no real field with the specified name but there is fitting getter method.

Type Parameters:
T - value type
Parameters:
object - object instance
field - object field
Returns:
field value for the specified object or null

getPainter

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

Parameters:
component - component to retrieve painter from
painterId - painter ID
Returns:
component painter

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object