com.levigo.util.swing.plaf
Class AbstractComponentAddon

java.lang.Object
  extended by com.levigo.util.swing.plaf.AbstractComponentAddon
All Implemented Interfaces:
ComponentAddon
Direct Known Subclasses:
JadiceComponentAddon

public abstract class AbstractComponentAddon
extends Object
implements ComponentAddon

Ease the work of creating an addon for a component.

Author:
Frederic Lavigne

Constructor Summary
protected AbstractComponentAddon(String name)
           
 
Method Summary
protected  void add(IconManager iconManager, String prefix, int effectFlags)
          Add all icons provided by the given icon manager the the UI resources.
protected  void add(String key, Border... borders)
          Add a set of nested borders.
protected  void add(String key, Color color, int alpha)
          Add a color with a transparency value.
protected  void add(String key, Object value)
          Add a simple UI property.
protected  void addInputMap(int focusState, String parentMapName, String... map)
          Add an input map comprised of the given map entries.
protected  void addResource(String bundleName)
          Adds the all keys/values from the given named resource bundle to the defaults
protected  Color getColor(String key)
           
protected  Color getColor(String key, Color defaultColor)
           
protected  Font getFont(String key)
           
protected  Font getFont(String key, Font defaultFont)
           
 String getName()
           
protected  void initBasicDefaults(LookAndFeelAddons addon)
          Adds default key/value pairs to the given list.
 void initialize(LookAndFeelAddons addon)
          Initializes this addon (i.e register UI classes, colors, fonts, borders, any UIResource used by the component class).
protected  void initMacDefaults(LookAndFeelAddons addon)
          Default implementation calls initBasicDefaults(LookAndFeelAddons)
protected  void initMetalDefaults(LookAndFeelAddons addon)
          Default implementation calls initBasicDefaults(LookAndFeelAddons)
protected  void initMotifDefaults(LookAndFeelAddons addon)
          Default implementation calls initBasicDefaults(LookAndFeelAddons)
protected  void initWindowsDefaults(LookAndFeelAddons addon)
          Default implementation calls initBasicDefaults(LookAndFeelAddons)
protected  boolean isMac(LookAndFeelAddons addon)
           
protected  boolean isMetal(LookAndFeelAddons addon)
           
protected  boolean isMotif(LookAndFeelAddons addon)
           
protected  boolean isPlastic()
           
protected  boolean isSynth()
           
protected  boolean isWindows(LookAndFeelAddons addon)
           
protected  Color lookupColor(Color fallback, String... keys)
          Look up a Color from the UIManager using a list of keys to try.
 void uninitialize(LookAndFeelAddons addon)
          Uninitializes this addon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractComponentAddon

protected AbstractComponentAddon(String name)
Method Detail

getName

public final String getName()
Specified by:
getName in interface ComponentAddon
Returns:
the name of this addon

initialize

public void initialize(LookAndFeelAddons addon)
Description copied from interface: ComponentAddon
Initializes this addon (i.e register UI classes, colors, fonts, borders, any UIResource used by the component class). When initializing, the addon can register different resources based on the addon or the current look and feel.

Specified by:
initialize in interface ComponentAddon
Parameters:
addon - the current addon

uninitialize

public void uninitialize(LookAndFeelAddons addon)
Description copied from interface: ComponentAddon
Uninitializes this addon.

Specified by:
uninitialize in interface ComponentAddon

initBasicDefaults

protected void initBasicDefaults(LookAndFeelAddons addon)
Adds default key/value pairs to the given list.

Parameters:
addon -

initMacDefaults

protected void initMacDefaults(LookAndFeelAddons addon)
Default implementation calls initBasicDefaults(LookAndFeelAddons)

Parameters:
addon -

initMetalDefaults

protected void initMetalDefaults(LookAndFeelAddons addon)
Default implementation calls initBasicDefaults(LookAndFeelAddons)

Parameters:
addon -

initMotifDefaults

protected void initMotifDefaults(LookAndFeelAddons addon)
Default implementation calls initBasicDefaults(LookAndFeelAddons)

Parameters:
addon -

initWindowsDefaults

protected void initWindowsDefaults(LookAndFeelAddons addon)
Default implementation calls initBasicDefaults(LookAndFeelAddons)

Parameters:
addon -

add

protected void add(String key,
                   Object value)
Add a simple UI property. The property key is automatically prefixed with the addon name, unless the given key starts with a ".". In the latter case the leading dot is removed and the rest of the key used as-is, without prefixing it.

Parameters:
key - the property key
value - the property value

add

protected void add(String key,
                   Color color,
                   int alpha)
Add a color with a transparency value.

Parameters:
key - the property key. For details see add(String, Object).
color - the (opaque) color
alpha - the alpha value

addResource

protected void addResource(String bundleName)
Adds the all keys/values from the given named resource bundle to the defaults


add

protected void add(String key,
                   Border... borders)
Add a set of nested borders. If there is more than than border, the borders are nested using compounding. They are nested according to their order from outside to inside.

Parameters:
key - the property key. For details see add(String, Object).
borders - the value

isWindows

protected boolean isWindows(LookAndFeelAddons addon)
Returns:
true if the addon is the Windows addon or its subclasses

isMetal

protected boolean isMetal(LookAndFeelAddons addon)
Returns:
true if the addon is the Metal addon or its subclasses

isMac

protected boolean isMac(LookAndFeelAddons addon)
Returns:
true if the addon is the Aqua addon or its subclasses

isMotif

protected boolean isMotif(LookAndFeelAddons addon)
Returns:
true if the addon is the Motif addon or its subclasses

isPlastic

protected boolean isPlastic()
Returns:
true if the current look and feel is one of JGoodies Plastic l&fs

isSynth

protected boolean isSynth()
Returns:
true if the current look and feel is Synth l&f

getFont

protected Font getFont(String key)

getFont

protected Font getFont(String key,
                       Font defaultFont)

getColor

protected Color getColor(String key)

getColor

protected Color getColor(String key,
                         Color defaultColor)

addInputMap

protected void addInputMap(int focusState,
                           String parentMapName,
                           String... map)
Add an input map comprised of the given map entries. The key is determined from the focus state to which this map pertains (key prefixing as detailed fir add(String, Object) still applies):
JComponent.WHEN_FOCUSED
focusInputMap
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
ancestorInputMap
JComponent.WHEN_IN_FOCUSED_WINDOW
windowInputMap

Parameters:
focusState - the focus state to which this map pertains
parentMapName - UI resource name of the parent map or null, if this map should not use a parent map
map - the map's key/value pairs

add

protected void add(IconManager iconManager,
                   String prefix,
                   int effectFlags)
Add all icons provided by the given icon manager the the UI resources.

Parameters:
iconManager - the IconManager instance.
prefix - the prefix to apply to the icon names. May be null. If non-null, a dot is automatically inserted between the prefix and the key.
effectFlags - the effect flags for which to retrieve the icons.

lookupColor

protected Color lookupColor(Color fallback,
                            String... keys)
Look up a Color from the UIManager using a list of keys to try. The keys are tried in order, until a value is found. If no value is found for any of the keys, the given fallback color is returned.

Parameters:
fallback -
keys -
Returns:


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.