< prev index next >

src/share/classes/javax/swing/plaf/synth/SynthStyle.java

Print this page
rev 1580 : 6727661: Code improvement and warnings removing from the swing/plaf packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: alexp
Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>


  37 
  38 /**
  39  * <code>SynthStyle</code> is a set of style properties.
  40  * Each <code>SynthUI</code> references at least one
  41  * <code>SynthStyle</code> that is obtained using a
  42  * <code>SynthStyleFactory</code>. You typically don't need to interact with
  43  * this class directly, rather you will load a
  44  * <a href="doc-files/synthFileFormat.html">Synth File Format file</a> into
  45  * <code>SynthLookAndFeel</code> that will create a set of SynthStyles.
  46  *
  47  * @see SynthLookAndFeel
  48  * @see SynthStyleFactory
  49  *
  50  * @since 1.5
  51  * @author Scott Violet
  52  */
  53 public abstract class SynthStyle {
  54     /**
  55      * Contains the default values for certain properties.
  56      */
  57     private static Map DEFAULT_VALUES;
  58 
  59     /**
  60      * Shared SynthGraphics.
  61      */
  62     private static final SynthGraphicsUtils SYNTH_GRAPHICS =
  63                               new SynthGraphicsUtils();
  64 
  65     /**
  66      * Adds the default values that we know about to DEFAULT_VALUES.
  67      */
  68     private static void populateDefaultValues() {
  69         Object buttonMap = new UIDefaults.LazyInputMap(new Object[] {
  70                           "SPACE", "pressed",
  71                  "released SPACE", "released"
  72         });
  73         DEFAULT_VALUES.put("Button.focusInputMap", buttonMap);
  74         DEFAULT_VALUES.put("CheckBox.focusInputMap", buttonMap);
  75         DEFAULT_VALUES.put("RadioButton.focusInputMap", buttonMap);
  76         DEFAULT_VALUES.put("ToggleButton.focusInputMap", buttonMap);
  77         DEFAULT_VALUES.put("SynthArrowButton.focusInputMap", buttonMap);


 699                              "ctrl SPACE", "toggleAndAnchor",
 700                             "shift SPACE", "extendTo",
 701                        "ctrl shift SPACE", "moveSelectionTo"
 702                }));
 703         DEFAULT_VALUES.put("Tree.focusInputMap.RightToLeft",
 704                new UIDefaults.LazyInputMap(new Object[] {
 705                                   "RIGHT", "selectParent",
 706                                "KP_RIGHT", "selectParent",
 707                                    "LEFT", "selectChild",
 708                                 "KP_LEFT", "selectChild",
 709                }));
 710     }
 711 
 712     /**
 713      * Returns the default value for the specified property, or null if there
 714      * is no default for the specified value.
 715      */
 716     private static Object getDefaultValue(Object key) {
 717         synchronized(SynthStyle.class) {
 718             if (DEFAULT_VALUES == null) {
 719                 DEFAULT_VALUES = new HashMap();
 720                 populateDefaultValues();
 721             }
 722             Object value = DEFAULT_VALUES.get(key);
 723             if (value instanceof UIDefaults.LazyValue) {
 724                 value = ((UIDefaults.LazyValue)value).createValue(null);
 725                 DEFAULT_VALUES.put(key, value);
 726             }
 727             return value;
 728         }
 729     }
 730 
 731     /**
 732      * Constructs a SynthStyle.
 733      */
 734     public SynthStyle() {
 735     }
 736 
 737     /**
 738      * Returns the <code>SynthGraphicUtils</code> for the specified context.
 739      *




  37 
  38 /**
  39  * <code>SynthStyle</code> is a set of style properties.
  40  * Each <code>SynthUI</code> references at least one
  41  * <code>SynthStyle</code> that is obtained using a
  42  * <code>SynthStyleFactory</code>. You typically don't need to interact with
  43  * this class directly, rather you will load a
  44  * <a href="doc-files/synthFileFormat.html">Synth File Format file</a> into
  45  * <code>SynthLookAndFeel</code> that will create a set of SynthStyles.
  46  *
  47  * @see SynthLookAndFeel
  48  * @see SynthStyleFactory
  49  *
  50  * @since 1.5
  51  * @author Scott Violet
  52  */
  53 public abstract class SynthStyle {
  54     /**
  55      * Contains the default values for certain properties.
  56      */
  57     private static Map<Object, Object> DEFAULT_VALUES;
  58 
  59     /**
  60      * Shared SynthGraphics.
  61      */
  62     private static final SynthGraphicsUtils SYNTH_GRAPHICS =
  63                               new SynthGraphicsUtils();
  64 
  65     /**
  66      * Adds the default values that we know about to DEFAULT_VALUES.
  67      */
  68     private static void populateDefaultValues() {
  69         Object buttonMap = new UIDefaults.LazyInputMap(new Object[] {
  70                           "SPACE", "pressed",
  71                  "released SPACE", "released"
  72         });
  73         DEFAULT_VALUES.put("Button.focusInputMap", buttonMap);
  74         DEFAULT_VALUES.put("CheckBox.focusInputMap", buttonMap);
  75         DEFAULT_VALUES.put("RadioButton.focusInputMap", buttonMap);
  76         DEFAULT_VALUES.put("ToggleButton.focusInputMap", buttonMap);
  77         DEFAULT_VALUES.put("SynthArrowButton.focusInputMap", buttonMap);


 699                              "ctrl SPACE", "toggleAndAnchor",
 700                             "shift SPACE", "extendTo",
 701                        "ctrl shift SPACE", "moveSelectionTo"
 702                }));
 703         DEFAULT_VALUES.put("Tree.focusInputMap.RightToLeft",
 704                new UIDefaults.LazyInputMap(new Object[] {
 705                                   "RIGHT", "selectParent",
 706                                "KP_RIGHT", "selectParent",
 707                                    "LEFT", "selectChild",
 708                                 "KP_LEFT", "selectChild",
 709                }));
 710     }
 711 
 712     /**
 713      * Returns the default value for the specified property, or null if there
 714      * is no default for the specified value.
 715      */
 716     private static Object getDefaultValue(Object key) {
 717         synchronized(SynthStyle.class) {
 718             if (DEFAULT_VALUES == null) {
 719                 DEFAULT_VALUES = new HashMap<Object, Object>();
 720                 populateDefaultValues();
 721             }
 722             Object value = DEFAULT_VALUES.get(key);
 723             if (value instanceof UIDefaults.LazyValue) {
 724                 value = ((UIDefaults.LazyValue)value).createValue(null);
 725                 DEFAULT_VALUES.put(key, value);
 726             }
 727             return value;
 728         }
 729     }
 730 
 731     /**
 732      * Constructs a SynthStyle.
 733      */
 734     public SynthStyle() {
 735     }
 736 
 737     /**
 738      * Returns the <code>SynthGraphicUtils</code> for the specified context.
 739      *


< prev index next >