1 /*
   2  * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javax.swing.plaf.synth;
  26 
  27 import java.awt.*;
  28 import javax.swing.*;
  29 import javax.swing.border.Border;
  30 import javax.swing.plaf.UIResource;
  31 import javax.swing.plaf.basic.BasicLookAndFeel;
  32 import javax.swing.text.DefaultEditorKit;
  33 import java.util.HashMap;
  34 import java.util.Map;
  35 import javax.swing.text.JTextComponent;
  36 import sun.swing.SwingUtilities2;
  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);
  78         DEFAULT_VALUES.put("List.dropLineColor", Color.BLACK);
  79         DEFAULT_VALUES.put("Tree.dropLineColor", Color.BLACK);
  80         DEFAULT_VALUES.put("Table.dropLineColor", Color.BLACK);
  81         DEFAULT_VALUES.put("Table.dropLineShortColor", Color.RED);
  82 
  83         Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
  84                            "ctrl C", DefaultEditorKit.copyAction,
  85                            "ctrl V", DefaultEditorKit.pasteAction,
  86                            "ctrl X", DefaultEditorKit.cutAction,
  87                              "COPY", DefaultEditorKit.copyAction,
  88                             "PASTE", DefaultEditorKit.pasteAction,
  89                               "CUT", DefaultEditorKit.cutAction,
  90                    "control INSERT", DefaultEditorKit.copyAction,
  91                      "shift INSERT", DefaultEditorKit.pasteAction,
  92                      "shift DELETE", DefaultEditorKit.cutAction,
  93                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  94                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  95                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  96                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  97                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
  98                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  99                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
 100                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
 101                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 102                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
 103                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 104               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
 105                            "ctrl A", DefaultEditorKit.selectAllAction,
 106                              "HOME", DefaultEditorKit.beginLineAction,
 107                               "END", DefaultEditorKit.endLineAction,
 108                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 109                         "shift END", DefaultEditorKit.selectionEndLineAction,
 110 
 111                                "UP", DefaultEditorKit.upAction,
 112                             "KP_UP", DefaultEditorKit.upAction,
 113                              "DOWN", DefaultEditorKit.downAction,
 114                           "KP_DOWN", DefaultEditorKit.downAction,
 115                           "PAGE_UP", DefaultEditorKit.pageUpAction,
 116                         "PAGE_DOWN", DefaultEditorKit.pageDownAction,
 117                     "shift PAGE_UP", "selection-page-up",
 118                   "shift PAGE_DOWN", "selection-page-down",
 119                "ctrl shift PAGE_UP", "selection-page-left",
 120              "ctrl shift PAGE_DOWN", "selection-page-right",
 121                          "shift UP", DefaultEditorKit.selectionUpAction,
 122                       "shift KP_UP", DefaultEditorKit.selectionUpAction,
 123                        "shift DOWN", DefaultEditorKit.selectionDownAction,
 124                     "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
 125                             "ENTER", DefaultEditorKit.insertBreakAction,
 126                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 127                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 128                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 129                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 130                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 131                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 132                             "RIGHT", DefaultEditorKit.forwardAction,
 133                              "LEFT", DefaultEditorKit.backwardAction,
 134                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 135                           "KP_LEFT", DefaultEditorKit.backwardAction,
 136                               "TAB", DefaultEditorKit.insertTabAction,
 137                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 138                         "ctrl HOME", DefaultEditorKit.beginAction,
 139                          "ctrl END", DefaultEditorKit.endAction,
 140                   "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
 141                    "ctrl shift END", DefaultEditorKit.selectionEndAction,
 142                            "ctrl T", "next-link-action",
 143                      "ctrl shift T", "previous-link-action",
 144                        "ctrl SPACE", "activate-link-action",
 145                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 146         });
 147         DEFAULT_VALUES.put("EditorPane.focusInputMap", multilineInputMap);
 148         DEFAULT_VALUES.put("TextArea.focusInputMap", multilineInputMap);
 149         DEFAULT_VALUES.put("TextPane.focusInputMap", multilineInputMap);
 150 
 151         Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
 152                            "ctrl C", DefaultEditorKit.copyAction,
 153                            "ctrl V", DefaultEditorKit.pasteAction,
 154                            "ctrl X", DefaultEditorKit.cutAction,
 155                              "COPY", DefaultEditorKit.copyAction,
 156                             "PASTE", DefaultEditorKit.pasteAction,
 157                               "CUT", DefaultEditorKit.cutAction,
 158                    "control INSERT", DefaultEditorKit.copyAction,
 159                      "shift INSERT", DefaultEditorKit.pasteAction,
 160                      "shift DELETE", DefaultEditorKit.cutAction,
 161                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 162                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
 163                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 164                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
 165                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
 166                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
 167                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
 168                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
 169                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 170                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
 171                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 172               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
 173                            "ctrl A", DefaultEditorKit.selectAllAction,
 174                              "HOME", DefaultEditorKit.beginLineAction,
 175                               "END", DefaultEditorKit.endLineAction,
 176                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 177                         "shift END", DefaultEditorKit.selectionEndLineAction,
 178                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 179                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 180                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 181                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 182                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 183                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 184                             "RIGHT", DefaultEditorKit.forwardAction,
 185                              "LEFT", DefaultEditorKit.backwardAction,
 186                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 187                           "KP_LEFT", DefaultEditorKit.backwardAction,
 188                             "ENTER", JTextField.notifyAction,
 189                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
 190                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
 191         });
 192         DEFAULT_VALUES.put("TextField.focusInputMap", fieldInputMap);
 193         DEFAULT_VALUES.put("PasswordField.focusInputMap", fieldInputMap);
 194 
 195 
 196         DEFAULT_VALUES.put("ComboBox.ancestorInputMap",
 197                   new UIDefaults.LazyInputMap(new Object[] {
 198                      "ESCAPE", "hidePopup",
 199                     "PAGE_UP", "pageUpPassThrough",
 200                   "PAGE_DOWN", "pageDownPassThrough",
 201                        "HOME", "homePassThrough",
 202                         "END", "endPassThrough",
 203                        "DOWN", "selectNext",
 204                     "KP_DOWN", "selectNext",
 205                    "alt DOWN", "togglePopup",
 206                 "alt KP_DOWN", "togglePopup",
 207                      "alt UP", "togglePopup",
 208                   "alt KP_UP", "togglePopup",
 209                       "SPACE", "spacePopup",
 210                      "ENTER", "enterPressed",
 211                          "UP", "selectPrevious",
 212                       "KP_UP", "selectPrevious"
 213                   }));
 214 
 215         DEFAULT_VALUES.put("Desktop.ancestorInputMap",
 216                new UIDefaults.LazyInputMap(new Object[] {
 217                  "ctrl F5", "restore",
 218                  "ctrl F4", "close",
 219                  "ctrl F7", "move",
 220                  "ctrl F8", "resize",
 221                    "RIGHT", "right",
 222                 "KP_RIGHT", "right",
 223              "shift RIGHT", "shrinkRight",
 224           "shift KP_RIGHT", "shrinkRight",
 225                     "LEFT", "left",
 226                  "KP_LEFT", "left",
 227               "shift LEFT", "shrinkLeft",
 228            "shift KP_LEFT", "shrinkLeft",
 229                       "UP", "up",
 230                    "KP_UP", "up",
 231                 "shift UP", "shrinkUp",
 232              "shift KP_UP", "shrinkUp",
 233                     "DOWN", "down",
 234                  "KP_DOWN", "down",
 235               "shift DOWN", "shrinkDown",
 236            "shift KP_DOWN", "shrinkDown",
 237                   "ESCAPE", "escape",
 238                  "ctrl F9", "minimize",
 239                 "ctrl F10", "maximize",
 240                  "ctrl F6", "selectNextFrame",
 241                 "ctrl TAB", "selectNextFrame",
 242              "ctrl alt F6", "selectNextFrame",
 243        "shift ctrl alt F6", "selectPreviousFrame",
 244                 "ctrl F12", "navigateNext",
 245            "shift ctrl F12", "navigatePrevious"
 246                }));
 247 
 248         DEFAULT_VALUES.put("FileChooser.ancestorInputMap",
 249                new UIDefaults.LazyInputMap(new Object[] {
 250                      "ESCAPE", "cancelSelection",
 251                      "F2", "editFileName",
 252                      "F5", "refresh",
 253                      "BACK_SPACE", "Go Up",
 254                      "ENTER", "approveSelection",
 255                 "ctrl ENTER", "approveSelection"
 256                }));
 257 
 258         DEFAULT_VALUES.put("FormattedTextField.focusInputMap",
 259               new UIDefaults.LazyInputMap(new Object[] {
 260                            "ctrl C", DefaultEditorKit.copyAction,
 261                            "ctrl V", DefaultEditorKit.pasteAction,
 262                            "ctrl X", DefaultEditorKit.cutAction,
 263                              "COPY", DefaultEditorKit.copyAction,
 264                             "PASTE", DefaultEditorKit.pasteAction,
 265                               "CUT", DefaultEditorKit.cutAction,
 266                    "control INSERT", DefaultEditorKit.copyAction,
 267                      "shift INSERT", DefaultEditorKit.pasteAction,
 268                      "shift DELETE", DefaultEditorKit.cutAction,
 269                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
 270                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
 271                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
 272                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
 273                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
 274                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
 275                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
 276                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
 277                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
 278                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
 279                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
 280               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
 281                            "ctrl A", DefaultEditorKit.selectAllAction,
 282                              "HOME", DefaultEditorKit.beginLineAction,
 283                               "END", DefaultEditorKit.endLineAction,
 284                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
 285                         "shift END", DefaultEditorKit.selectionEndLineAction,
 286                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 287                  "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
 288                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
 289                            "DELETE", DefaultEditorKit.deleteNextCharAction,
 290                       "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
 291                   "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
 292                             "RIGHT", DefaultEditorKit.forwardAction,
 293                              "LEFT", DefaultEditorKit.backwardAction,
 294                          "KP_RIGHT", DefaultEditorKit.forwardAction,
 295                           "KP_LEFT", DefaultEditorKit.backwardAction,
 296                             "ENTER", JTextField.notifyAction,
 297                   "ctrl BACK_SLASH", "unselect",
 298                    "control shift O", "toggle-componentOrientation",
 299                            "ESCAPE", "reset-field-edit",
 300                                "UP", "increment",
 301                             "KP_UP", "increment",
 302                              "DOWN", "decrement",
 303                           "KP_DOWN", "decrement",
 304               }));
 305 
 306         DEFAULT_VALUES.put("InternalFrame.icon",
 307                            SwingUtilities2.makeIcon(BasicLookAndFeel.class,
 308                                                     BasicLookAndFeel.class,
 309                                                     "icons/JavaCup16.png"));
 310 
 311         DEFAULT_VALUES.put("InternalFrame.windowBindings",
 312             new Object[] {
 313               "shift ESCAPE", "showSystemMenu",
 314                 "ctrl SPACE", "showSystemMenu",
 315               "ESCAPE", "hideSystemMenu"});
 316 
 317         DEFAULT_VALUES.put("List.focusInputMap",
 318                new UIDefaults.LazyInputMap(new Object[] {
 319                            "ctrl C", "copy",
 320                            "ctrl V", "paste",
 321                            "ctrl X", "cut",
 322                              "COPY", "copy",
 323                             "PASTE", "paste",
 324                               "CUT", "cut",
 325                    "control INSERT", "copy",
 326                      "shift INSERT", "paste",
 327                      "shift DELETE", "cut",
 328                                "UP", "selectPreviousRow",
 329                             "KP_UP", "selectPreviousRow",
 330                          "shift UP", "selectPreviousRowExtendSelection",
 331                       "shift KP_UP", "selectPreviousRowExtendSelection",
 332                     "ctrl shift UP", "selectPreviousRowExtendSelection",
 333                  "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
 334                           "ctrl UP", "selectPreviousRowChangeLead",
 335                        "ctrl KP_UP", "selectPreviousRowChangeLead",
 336                              "DOWN", "selectNextRow",
 337                           "KP_DOWN", "selectNextRow",
 338                        "shift DOWN", "selectNextRowExtendSelection",
 339                     "shift KP_DOWN", "selectNextRowExtendSelection",
 340                   "ctrl shift DOWN", "selectNextRowExtendSelection",
 341                "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
 342                         "ctrl DOWN", "selectNextRowChangeLead",
 343                      "ctrl KP_DOWN", "selectNextRowChangeLead",
 344                              "LEFT", "selectPreviousColumn",
 345                           "KP_LEFT", "selectPreviousColumn",
 346                        "shift LEFT", "selectPreviousColumnExtendSelection",
 347                     "shift KP_LEFT", "selectPreviousColumnExtendSelection",
 348                   "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
 349                "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
 350                         "ctrl LEFT", "selectPreviousColumnChangeLead",
 351                      "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
 352                             "RIGHT", "selectNextColumn",
 353                          "KP_RIGHT", "selectNextColumn",
 354                       "shift RIGHT", "selectNextColumnExtendSelection",
 355                    "shift KP_RIGHT", "selectNextColumnExtendSelection",
 356                  "ctrl shift RIGHT", "selectNextColumnExtendSelection",
 357               "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
 358                        "ctrl RIGHT", "selectNextColumnChangeLead",
 359                     "ctrl KP_RIGHT", "selectNextColumnChangeLead",
 360                              "HOME", "selectFirstRow",
 361                        "shift HOME", "selectFirstRowExtendSelection",
 362                   "ctrl shift HOME", "selectFirstRowExtendSelection",
 363                         "ctrl HOME", "selectFirstRowChangeLead",
 364                               "END", "selectLastRow",
 365                         "shift END", "selectLastRowExtendSelection",
 366                    "ctrl shift END", "selectLastRowExtendSelection",
 367                          "ctrl END", "selectLastRowChangeLead",
 368                           "PAGE_UP", "scrollUp",
 369                     "shift PAGE_UP", "scrollUpExtendSelection",
 370                "ctrl shift PAGE_UP", "scrollUpExtendSelection",
 371                      "ctrl PAGE_UP", "scrollUpChangeLead",
 372                         "PAGE_DOWN", "scrollDown",
 373                   "shift PAGE_DOWN", "scrollDownExtendSelection",
 374              "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
 375                    "ctrl PAGE_DOWN", "scrollDownChangeLead",
 376                            "ctrl A", "selectAll",
 377                        "ctrl SLASH", "selectAll",
 378                   "ctrl BACK_SLASH", "clearSelection",
 379                             "SPACE", "addToSelection",
 380                        "ctrl SPACE", "toggleAndAnchor",
 381                       "shift SPACE", "extendTo",
 382                  "ctrl shift SPACE", "moveSelectionTo"
 383                }));
 384 
 385         DEFAULT_VALUES.put("List.focusInputMap.RightToLeft",
 386                new UIDefaults.LazyInputMap(new Object[] {
 387                              "LEFT", "selectNextColumn",
 388                           "KP_LEFT", "selectNextColumn",
 389                        "shift LEFT", "selectNextColumnExtendSelection",
 390                     "shift KP_LEFT", "selectNextColumnExtendSelection",
 391                   "ctrl shift LEFT", "selectNextColumnExtendSelection",
 392                "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
 393                         "ctrl LEFT", "selectNextColumnChangeLead",
 394                      "ctrl KP_LEFT", "selectNextColumnChangeLead",
 395                             "RIGHT", "selectPreviousColumn",
 396                          "KP_RIGHT", "selectPreviousColumn",
 397                       "shift RIGHT", "selectPreviousColumnExtendSelection",
 398                    "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
 399                  "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
 400               "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
 401                        "ctrl RIGHT", "selectPreviousColumnChangeLead",
 402                     "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
 403                }));
 404 
 405         DEFAULT_VALUES.put("MenuBar.windowBindings",
 406                                 new Object[] { "F10", "takeFocus" });
 407 
 408         DEFAULT_VALUES.put("OptionPane.windowBindings",
 409                  new Object[] { "ESCAPE", "close" });
 410 
 411         DEFAULT_VALUES.put("RootPane.defaultButtonWindowKeyBindings",
 412                  new Object[] {
 413                              "ENTER", "press",
 414                     "released ENTER", "release",
 415                         "ctrl ENTER", "press",
 416                "ctrl released ENTER", "release"
 417                  });
 418 
 419         DEFAULT_VALUES.put("RootPane.ancestorInputMap",
 420                new UIDefaults.LazyInputMap(new Object[] {
 421                     "shift F10", "postPopup"
 422                }));
 423 
 424         DEFAULT_VALUES.put("ScrollBar.anecstorInputMap",
 425                new UIDefaults.LazyInputMap(new Object[] {
 426                        "RIGHT", "positiveUnitIncrement",
 427                     "KP_RIGHT", "positiveUnitIncrement",
 428                         "DOWN", "positiveUnitIncrement",
 429                      "KP_DOWN", "positiveUnitIncrement",
 430                    "PAGE_DOWN", "positiveBlockIncrement",
 431                         "LEFT", "negativeUnitIncrement",
 432                      "KP_LEFT", "negativeUnitIncrement",
 433                           "UP", "negativeUnitIncrement",
 434                        "KP_UP", "negativeUnitIncrement",
 435                      "PAGE_UP", "negativeBlockIncrement",
 436                         "HOME", "minScroll",
 437                          "END", "maxScroll"
 438                }));
 439 
 440         DEFAULT_VALUES.put("ScrollBar.ancestorInputMap.RightToLeft",
 441                new UIDefaults.LazyInputMap(new Object[] {
 442                        "RIGHT", "negativeUnitIncrement",
 443                     "KP_RIGHT", "negativeUnitIncrement",
 444                         "LEFT", "positiveUnitIncrement",
 445                      "KP_LEFT", "positiveUnitIncrement",
 446                }));
 447 
 448         DEFAULT_VALUES.put("ScrollPane.ancestorInputMap",
 449                new UIDefaults.LazyInputMap(new Object[] {
 450                            "RIGHT", "unitScrollRight",
 451                         "KP_RIGHT", "unitScrollRight",
 452                             "DOWN", "unitScrollDown",
 453                          "KP_DOWN", "unitScrollDown",
 454                             "LEFT", "unitScrollLeft",
 455                          "KP_LEFT", "unitScrollLeft",
 456                               "UP", "unitScrollUp",
 457                            "KP_UP", "unitScrollUp",
 458                          "PAGE_UP", "scrollUp",
 459                        "PAGE_DOWN", "scrollDown",
 460                     "ctrl PAGE_UP", "scrollLeft",
 461                   "ctrl PAGE_DOWN", "scrollRight",
 462                        "ctrl HOME", "scrollHome",
 463                         "ctrl END", "scrollEnd"
 464                }));
 465         DEFAULT_VALUES.put("ScrollPane.ancestorInputMap.RightToLeft",
 466                new UIDefaults.LazyInputMap(new Object[] {
 467                     "ctrl PAGE_UP", "scrollRight",
 468                   "ctrl PAGE_DOWN", "scrollLeft",
 469                }));
 470 
 471         DEFAULT_VALUES.put("SplitPane.ancestorInputMap",
 472                new UIDefaults.LazyInputMap(new Object[] {
 473                         "UP", "negativeIncrement",
 474                       "DOWN", "positiveIncrement",
 475                       "LEFT", "negativeIncrement",
 476                      "RIGHT", "positiveIncrement",
 477                      "KP_UP", "negativeIncrement",
 478                    "KP_DOWN", "positiveIncrement",
 479                    "KP_LEFT", "negativeIncrement",
 480                   "KP_RIGHT", "positiveIncrement",
 481                       "HOME", "selectMin",
 482                        "END", "selectMax",
 483                         "F8", "startResize",
 484                         "F6", "toggleFocus",
 485                   "ctrl TAB", "focusOutForward",
 486             "ctrl shift TAB", "focusOutBackward"
 487                }));
 488 
 489         DEFAULT_VALUES.put("Spinner.ancestorInputMap",
 490                new UIDefaults.LazyInputMap(new Object[] {
 491                           "UP", "increment",
 492                        "KP_UP", "increment",
 493                         "DOWN", "decrement",
 494                      "KP_DOWN", "decrement"
 495                }));
 496 
 497         DEFAULT_VALUES.put("Slider.focusInputMap",
 498                new UIDefaults.LazyInputMap(new Object[] {
 499                        "RIGHT", "positiveUnitIncrement",
 500                     "KP_RIGHT", "positiveUnitIncrement",
 501                         "DOWN", "negativeUnitIncrement",
 502                      "KP_DOWN", "negativeUnitIncrement",
 503                    "PAGE_DOWN", "negativeBlockIncrement",
 504               "ctrl PAGE_DOWN", "negativeBlockIncrement",
 505                         "LEFT", "negativeUnitIncrement",
 506                      "KP_LEFT", "negativeUnitIncrement",
 507                           "UP", "positiveUnitIncrement",
 508                        "KP_UP", "positiveUnitIncrement",
 509                      "PAGE_UP", "positiveBlockIncrement",
 510                 "ctrl PAGE_UP", "positiveBlockIncrement",
 511                         "HOME", "minScroll",
 512                          "END", "maxScroll"
 513                }));
 514 
 515         DEFAULT_VALUES.put("Slider.focusInputMap.RightToLeft",
 516                new UIDefaults.LazyInputMap(new Object[] {
 517                        "RIGHT", "negativeUnitIncrement",
 518                     "KP_RIGHT", "negativeUnitIncrement",
 519                         "LEFT", "positiveUnitIncrement",
 520                      "KP_LEFT", "positiveUnitIncrement",
 521                }));
 522 
 523         DEFAULT_VALUES.put("TabbedPane.ancestorInputMap",
 524                new UIDefaults.LazyInputMap(new Object[] {
 525                    "ctrl PAGE_DOWN", "navigatePageDown",
 526                      "ctrl PAGE_UP", "navigatePageUp",
 527                           "ctrl UP", "requestFocus",
 528                        "ctrl KP_UP", "requestFocus",
 529                }));
 530 
 531         DEFAULT_VALUES.put("TabbedPane.focusInputMap",
 532               new UIDefaults.LazyInputMap(new Object[] {
 533                          "RIGHT", "navigateRight",
 534                       "KP_RIGHT", "navigateRight",
 535                           "LEFT", "navigateLeft",
 536                        "KP_LEFT", "navigateLeft",
 537                             "UP", "navigateUp",
 538                          "KP_UP", "navigateUp",
 539                           "DOWN", "navigateDown",
 540                        "KP_DOWN", "navigateDown",
 541                      "ctrl DOWN", "requestFocusForVisibleComponent",
 542                   "ctrl KP_DOWN", "requestFocusForVisibleComponent",
 543               }));
 544 
 545         DEFAULT_VALUES.put("Table.ancestorInputMap",
 546                new UIDefaults.LazyInputMap(new Object[] {
 547                                "ctrl C", "copy",
 548                                "ctrl V", "paste",
 549                                "ctrl X", "cut",
 550                                  "COPY", "copy",
 551                                 "PASTE", "paste",
 552                                   "CUT", "cut",
 553                        "control INSERT", "copy",
 554                          "shift INSERT", "paste",
 555                          "shift DELETE", "cut",
 556                                 "RIGHT", "selectNextColumn",
 557                              "KP_RIGHT", "selectNextColumn",
 558                           "shift RIGHT", "selectNextColumnExtendSelection",
 559                        "shift KP_RIGHT", "selectNextColumnExtendSelection",
 560                      "ctrl shift RIGHT", "selectNextColumnExtendSelection",
 561                   "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
 562                            "ctrl RIGHT", "selectNextColumnChangeLead",
 563                         "ctrl KP_RIGHT", "selectNextColumnChangeLead",
 564                                  "LEFT", "selectPreviousColumn",
 565                               "KP_LEFT", "selectPreviousColumn",
 566                            "shift LEFT", "selectPreviousColumnExtendSelection",
 567                         "shift KP_LEFT", "selectPreviousColumnExtendSelection",
 568                       "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
 569                    "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
 570                             "ctrl LEFT", "selectPreviousColumnChangeLead",
 571                          "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
 572                                  "DOWN", "selectNextRow",
 573                               "KP_DOWN", "selectNextRow",
 574                            "shift DOWN", "selectNextRowExtendSelection",
 575                         "shift KP_DOWN", "selectNextRowExtendSelection",
 576                       "ctrl shift DOWN", "selectNextRowExtendSelection",
 577                    "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
 578                             "ctrl DOWN", "selectNextRowChangeLead",
 579                          "ctrl KP_DOWN", "selectNextRowChangeLead",
 580                                    "UP", "selectPreviousRow",
 581                                 "KP_UP", "selectPreviousRow",
 582                              "shift UP", "selectPreviousRowExtendSelection",
 583                           "shift KP_UP", "selectPreviousRowExtendSelection",
 584                         "ctrl shift UP", "selectPreviousRowExtendSelection",
 585                      "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
 586                               "ctrl UP", "selectPreviousRowChangeLead",
 587                            "ctrl KP_UP", "selectPreviousRowChangeLead",
 588                                  "HOME", "selectFirstColumn",
 589                            "shift HOME", "selectFirstColumnExtendSelection",
 590                       "ctrl shift HOME", "selectFirstRowExtendSelection",
 591                             "ctrl HOME", "selectFirstRow",
 592                                   "END", "selectLastColumn",
 593                             "shift END", "selectLastColumnExtendSelection",
 594                        "ctrl shift END", "selectLastRowExtendSelection",
 595                              "ctrl END", "selectLastRow",
 596                               "PAGE_UP", "scrollUpChangeSelection",
 597                         "shift PAGE_UP", "scrollUpExtendSelection",
 598                    "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
 599                          "ctrl PAGE_UP", "scrollLeftChangeSelection",
 600                             "PAGE_DOWN", "scrollDownChangeSelection",
 601                       "shift PAGE_DOWN", "scrollDownExtendSelection",
 602                  "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
 603                        "ctrl PAGE_DOWN", "scrollRightChangeSelection",
 604                                   "TAB", "selectNextColumnCell",
 605                             "shift TAB", "selectPreviousColumnCell",
 606                                 "ENTER", "selectNextRowCell",
 607                           "shift ENTER", "selectPreviousRowCell",
 608                                "ctrl A", "selectAll",
 609                            "ctrl SLASH", "selectAll",
 610                       "ctrl BACK_SLASH", "clearSelection",
 611                                "ESCAPE", "cancel",
 612                                    "F2", "startEditing",
 613                                 "SPACE", "addToSelection",
 614                            "ctrl SPACE", "toggleAndAnchor",
 615                           "shift SPACE", "extendTo",
 616                      "ctrl shift SPACE", "moveSelectionTo",
 617                                    "F8", "focusHeader"
 618                }));
 619 
 620        DEFAULT_VALUES.put("TableHeader.ancestorInputMap",
 621                new UIDefaults.LazyInputMap(new Object[] {
 622                                 "SPACE", "toggleSortOrder",
 623                                  "LEFT", "selectColumnToLeft",
 624                               "KP_LEFT", "selectColumnToLeft",
 625                                 "RIGHT", "selectColumnToRight",
 626                              "KP_RIGHT", "selectColumnToRight",
 627                              "alt LEFT", "moveColumnLeft",
 628                           "alt KP_LEFT", "moveColumnLeft",
 629                             "alt RIGHT", "moveColumnRight",
 630                          "alt KP_RIGHT", "moveColumnRight",
 631                        "alt shift LEFT", "resizeLeft",
 632                     "alt shift KP_LEFT", "resizeLeft",
 633                       "alt shift RIGHT", "resizeRight",
 634                    "alt shift KP_RIGHT", "resizeRight",
 635                                "ESCAPE", "focusTable",
 636                }));
 637 
 638         DEFAULT_VALUES.put("Tree.ancestorInputMap",
 639                new UIDefaults.LazyInputMap(new Object[] {
 640                      "ESCAPE", "cancel"
 641                }));
 642         DEFAULT_VALUES.put("Tree.focusInputMap",
 643                new UIDefaults.LazyInputMap(new Object[] {
 644                                     "ADD", "expand",
 645                                "SUBTRACT", "collapse",
 646                                  "ctrl C", "copy",
 647                                  "ctrl V", "paste",
 648                                  "ctrl X", "cut",
 649                                    "COPY", "copy",
 650                                   "PASTE", "paste",
 651                                     "CUT", "cut",
 652                          "control INSERT", "copy",
 653                            "shift INSERT", "paste",
 654                            "shift DELETE", "cut",
 655                                      "UP", "selectPrevious",
 656                                   "KP_UP", "selectPrevious",
 657                                "shift UP", "selectPreviousExtendSelection",
 658                             "shift KP_UP", "selectPreviousExtendSelection",
 659                           "ctrl shift UP", "selectPreviousExtendSelection",
 660                        "ctrl shift KP_UP", "selectPreviousExtendSelection",
 661                                 "ctrl UP", "selectPreviousChangeLead",
 662                              "ctrl KP_UP", "selectPreviousChangeLead",
 663                                    "DOWN", "selectNext",
 664                                 "KP_DOWN", "selectNext",
 665                              "shift DOWN", "selectNextExtendSelection",
 666                           "shift KP_DOWN", "selectNextExtendSelection",
 667                         "ctrl shift DOWN", "selectNextExtendSelection",
 668                      "ctrl shift KP_DOWN", "selectNextExtendSelection",
 669                               "ctrl DOWN", "selectNextChangeLead",
 670                            "ctrl KP_DOWN", "selectNextChangeLead",
 671                                   "RIGHT", "selectChild",
 672                                "KP_RIGHT", "selectChild",
 673                                    "LEFT", "selectParent",
 674                                 "KP_LEFT", "selectParent",
 675                                 "PAGE_UP", "scrollUpChangeSelection",
 676                           "shift PAGE_UP", "scrollUpExtendSelection",
 677                      "ctrl shift PAGE_UP", "scrollUpExtendSelection",
 678                            "ctrl PAGE_UP", "scrollUpChangeLead",
 679                               "PAGE_DOWN", "scrollDownChangeSelection",
 680                         "shift PAGE_DOWN", "scrollDownExtendSelection",
 681                    "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
 682                          "ctrl PAGE_DOWN", "scrollDownChangeLead",
 683                                    "HOME", "selectFirst",
 684                              "shift HOME", "selectFirstExtendSelection",
 685                         "ctrl shift HOME", "selectFirstExtendSelection",
 686                               "ctrl HOME", "selectFirstChangeLead",
 687                                     "END", "selectLast",
 688                               "shift END", "selectLastExtendSelection",
 689                          "ctrl shift END", "selectLastExtendSelection",
 690                                "ctrl END", "selectLastChangeLead",
 691                                      "F2", "startEditing",
 692                                  "ctrl A", "selectAll",
 693                              "ctrl SLASH", "selectAll",
 694                         "ctrl BACK_SLASH", "clearSelection",
 695                               "ctrl LEFT", "scrollLeft",
 696                            "ctrl KP_LEFT", "scrollLeft",
 697                              "ctrl RIGHT", "scrollRight",
 698                           "ctrl KP_RIGHT", "scrollRight",
 699                                   "SPACE", "addToSelection",
 700                              "ctrl SPACE", "toggleAndAnchor",
 701                             "shift SPACE", "extendTo",
 702                        "ctrl shift SPACE", "moveSelectionTo"
 703                }));
 704         DEFAULT_VALUES.put("Tree.focusInputMap.RightToLeft",
 705                new UIDefaults.LazyInputMap(new Object[] {
 706                                   "RIGHT", "selectParent",
 707                                "KP_RIGHT", "selectParent",
 708                                    "LEFT", "selectChild",
 709                                 "KP_LEFT", "selectChild",
 710                }));
 711     }
 712 
 713     /**
 714      * Returns the default value for the specified property, or null if there
 715      * is no default for the specified value.
 716      */
 717     private static Object getDefaultValue(Object key) {
 718         synchronized(SynthStyle.class) {
 719             if (DEFAULT_VALUES == null) {
 720                 DEFAULT_VALUES = new HashMap<Object, Object>();
 721                 populateDefaultValues();
 722             }
 723             Object value = DEFAULT_VALUES.get(key);
 724             if (value instanceof UIDefaults.LazyValue) {
 725                 value = ((UIDefaults.LazyValue)value).createValue(null);
 726                 DEFAULT_VALUES.put(key, value);
 727             }
 728             return value;
 729         }
 730     }
 731 
 732     /**
 733      * Constructs a SynthStyle.
 734      */
 735     public SynthStyle() {
 736     }
 737 
 738     /**
 739      * Returns the <code>SynthGraphicUtils</code> for the specified context.
 740      *
 741      * @param context SynthContext identifying requester
 742      * @return SynthGraphicsUtils
 743      */
 744     public SynthGraphicsUtils getGraphicsUtils(SynthContext context) {
 745         return SYNTH_GRAPHICS;
 746     }
 747 
 748     /**
 749      * Returns the color for the specified state. This gives precedence to
 750      * foreground and background of the <code>JComponent</code>. If the
 751      * <code>Color</code> from the <code>JComponent</code> is not appropriate,
 752      * or not used, this will invoke <code>getColorForState</code>. Subclasses
 753      * should generally not have to override this, instead override
 754      * {@link #getColorForState}.
 755      *
 756      * @param context SynthContext identifying requester
 757      * @param type Type of color being requested.
 758      * @return Color
 759      */
 760     public Color getColor(SynthContext context, ColorType type) {
 761         JComponent c = context.getComponent();
 762         Region id = context.getRegion();
 763 
 764         if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
 765             //This component is disabled, so return the disabled color.
 766             //In some cases this means ignoring the color specified by the
 767             //developer on the component. In other cases it means using a
 768             //specified disabledTextColor, such as on JTextComponents.
 769             //For example, JLabel doesn't specify a disabled color that the
 770             //developer can set, yet it should have a disabled color to the
 771             //text when the label is disabled. This code allows for that.
 772             if (c instanceof JTextComponent) {
 773                 JTextComponent txt = (JTextComponent)c;
 774                 Color disabledColor = txt.getDisabledTextColor();
 775                 if (disabledColor == null || disabledColor instanceof UIResource) {
 776                     return getColorForState(context, type);
 777                 }
 778             } else if (c instanceof JLabel &&
 779                             (type == ColorType.FOREGROUND ||
 780                              type == ColorType.TEXT_FOREGROUND)) {
 781                 return getColorForState(context, type);
 782             }
 783         }
 784 
 785         // If the developer has specified a color, prefer it. Otherwise, get
 786         // the color for the state.
 787         Color color = null;
 788         if (!id.isSubregion()) {
 789             if (type == ColorType.BACKGROUND) {
 790                 color = c.getBackground();
 791             }
 792             else if (type == ColorType.FOREGROUND) {
 793                 color = c.getForeground();
 794             }
 795             else if (type == ColorType.TEXT_FOREGROUND) {
 796                 color = c.getForeground();
 797             }
 798         }
 799 
 800         if (color == null || color instanceof UIResource) {
 801             // Then use what we've locally defined
 802             color = getColorForState(context, type);
 803         }
 804 
 805         if (color == null) {
 806             // No color, fallback to that of the widget.
 807             if (type == ColorType.BACKGROUND ||
 808                         type == ColorType.TEXT_BACKGROUND) {
 809                 return c.getBackground();
 810             }
 811             else if (type == ColorType.FOREGROUND ||
 812                      type == ColorType.TEXT_FOREGROUND) {
 813                 return c.getForeground();
 814             }
 815         }
 816         return color;
 817     }
 818 
 819     /**
 820      * Returns the color for the specified state. This should NOT call any
 821      * methods on the <code>JComponent</code>.
 822      *
 823      * @param context SynthContext identifying requester
 824      * @param type Type of color being requested.
 825      * @return Color to render with
 826      */
 827     protected abstract Color getColorForState(SynthContext context,
 828                                               ColorType type);
 829 
 830     /**
 831      * Returns the Font for the specified state. This redirects to the
 832      * <code>JComponent</code> from the <code>context</code> as necessary.
 833      * If this does not redirect
 834      * to the JComponent {@link #getFontForState} is invoked.
 835      *
 836      * @param context SynthContext identifying requester
 837      * @return Font to render with
 838      */
 839     public Font getFont(SynthContext context) {
 840         JComponent c = context.getComponent();
 841         if (context.getComponentState() == SynthConstants.ENABLED) {
 842             return c.getFont();
 843         }
 844         Font cFont = c.getFont();
 845         if (cFont != null && !(cFont instanceof UIResource)) {
 846             return cFont;
 847         }
 848         return getFontForState(context);
 849     }
 850 
 851     /**
 852      * Returns the font for the specified state. This should NOT call any
 853      * method on the <code>JComponent</code>.
 854      *
 855      * @param context SynthContext identifying requester
 856      * @return Font to render with
 857      */
 858     protected abstract Font getFontForState(SynthContext context);
 859 
 860     /**
 861      * Returns the Insets that are used to calculate sizing information.
 862      *
 863      * @param context SynthContext identifying requester
 864      * @param insets Insets to place return value in.
 865      * @return Sizing Insets.
 866      */
 867     public Insets getInsets(SynthContext context, Insets insets) {
 868         if (insets == null) {
 869             insets = new Insets(0, 0, 0, 0);
 870         }
 871         insets.top = insets.bottom = insets.left = insets.right = 0;
 872         return insets;
 873     }
 874 
 875     /**
 876      * Returns the <code>SynthPainter</code> that will be used for painting.
 877      * This may return null.
 878      *
 879      * @param context SynthContext identifying requester
 880      * @return SynthPainter to use
 881      */
 882     public SynthPainter getPainter(SynthContext context) {
 883         return null;
 884     }
 885 
 886     /**
 887      * Returns true if the region is opaque.
 888      *
 889      * @param context SynthContext identifying requester
 890      * @return true if region is opaque.
 891      */
 892     public boolean isOpaque(SynthContext context) {
 893         return true;
 894     }
 895 
 896     /**
 897      * Getter for a region specific style property.
 898      *
 899      * @param context SynthContext identifying requester
 900      * @param key Property being requested.
 901      * @return Value of the named property
 902      */
 903     public Object get(SynthContext context, Object key) {
 904         return getDefaultValue(key);
 905     }
 906 
 907     void installDefaults(SynthContext context, SynthUI ui) {
 908         // Special case the Border as this will likely change when the LAF
 909         // can have more control over this.
 910         if (!context.isSubregion()) {
 911             JComponent c = context.getComponent();
 912             Border border = c.getBorder();
 913 
 914             if (border == null || border instanceof UIResource) {
 915                 c.setBorder(new SynthBorder(ui, getInsets(context, null)));
 916             }
 917         }
 918         installDefaults(context);
 919     }
 920 
 921     /**
 922      * Installs the necessary state from this Style on the
 923      * <code>JComponent</code> from <code>context</code>.
 924      *
 925      * @param context SynthContext identifying component to install properties
 926      *        to.
 927      */
 928     public void installDefaults(SynthContext context) {
 929         if (!context.isSubregion()) {
 930             JComponent c = context.getComponent();
 931             Region region = context.getRegion();
 932             Font font = c.getFont();
 933 
 934             if (font == null || (font instanceof UIResource)) {
 935                 c.setFont(getFontForState(context));
 936             }
 937             Color background = c.getBackground();
 938             if (background == null || (background instanceof UIResource)) {
 939                 c.setBackground(getColorForState(context,
 940                                                  ColorType.BACKGROUND));
 941             }
 942             Color foreground = c.getForeground();
 943             if (foreground == null || (foreground instanceof UIResource)) {
 944                 c.setForeground(getColorForState(context,
 945                          ColorType.FOREGROUND));
 946             }
 947             LookAndFeel.installProperty(c, "opaque", Boolean.valueOf(isOpaque(context)));
 948         }
 949     }
 950 
 951     /**
 952      * Uninstalls any state that this style installed on
 953      * the <code>JComponent</code> from <code>context</code>.
 954      * <p>
 955      * Styles should NOT depend upon this being called, in certain cases
 956      * it may never be called.
 957      *
 958      * @param context SynthContext identifying component to install properties
 959      *        to.
 960      */
 961     public void uninstallDefaults(SynthContext context) {
 962         if (!context.isSubregion()) {
 963             // NOTE: because getForeground, getBackground and getFont will look
 964             // at the parent Container, if we set them to null it may
 965             // mean we they return a non-null and non-UIResource value
 966             // preventing install from correctly settings its colors/font. For
 967             // this reason we do not uninstall the fg/bg/font.
 968 
 969             JComponent c = context.getComponent();
 970             Border border = c.getBorder();
 971 
 972             if (border instanceof UIResource) {
 973                 c.setBorder(null);
 974             }
 975         }
 976     }
 977 
 978     /**
 979      * Convenience method to get a specific style property whose value is
 980      * a <code>Number</code>. If the value is a <code>Number</code>,
 981      * <code>intValue</code> is returned, otherwise <code>defaultValue</code>
 982      * is returned.
 983      *
 984      * @param context SynthContext identifying requester
 985      * @param key Property being requested.
 986      * @param defaultValue Value to return if the property has not been
 987      *        specified, or is not a Number
 988      * @return Value of the named property
 989      */
 990     public int getInt(SynthContext context, Object key, int defaultValue) {
 991         Object value = get(context, key);
 992 
 993         if (value instanceof Number) {
 994             return ((Number)value).intValue();
 995         }
 996         return defaultValue;
 997     }
 998 
 999     /**
1000      * Convenience method to get a specific style property whose value is
1001      * an Boolean.
1002      *
1003      * @param context SynthContext identifying requester
1004      * @param key Property being requested.
1005      * @param defaultValue Value to return if the property has not been
1006      *        specified, or is not a Boolean
1007      * @return Value of the named property
1008      */
1009     public boolean getBoolean(SynthContext context, Object key,
1010                               boolean defaultValue) {
1011         Object value = get(context, key);
1012 
1013         if (value instanceof Boolean) {
1014             return ((Boolean)value).booleanValue();
1015         }
1016         return defaultValue;
1017     }
1018 
1019     /**
1020      * Convenience method to get a specific style property whose value is
1021      * an Icon.
1022      *
1023      * @param context SynthContext identifying requester
1024      * @param key Property being requested.
1025      * @return Value of the named property, or null if not specified
1026      */
1027     public Icon getIcon(SynthContext context, Object key) {
1028         Object value = get(context, key);
1029 
1030         if (value instanceof Icon) {
1031             return (Icon)value;
1032         }
1033         return null;
1034     }
1035 
1036     /**
1037      * Convenience method to get a specific style property whose value is
1038      * a String.
1039      *
1040      * @param context SynthContext identifying requester
1041      * @param key Property being requested.
1042      * @param defaultValue Value to return if the property has not been
1043      *        specified, or is not a String
1044      * @return Value of the named property
1045      */
1046     public String getString(SynthContext context, Object key,
1047                               String defaultValue) {
1048         Object value = get(context, key);
1049 
1050         if (value instanceof String) {
1051             return (String)value;
1052         }
1053         return defaultValue;
1054     }
1055 }
--- EOF ---