src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2010, 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


 628      * Button.opacity
 629      * Button.Enabled.foreground
 630      * Button.Enabled+Selected.background
 631      * </pre>
 632      *
 633      * <p>In this example, suppose you were in the Enabled+Selected state and
 634      * searched for "foreground". In this case, we first check for
 635      * Button.Enabled+Selected.foreground, but no such color exists. We then
 636      * fall back to the next valid state, in this case,
 637      * Button.Enabled.foreground, and have a match. So we return it.</p>
 638      *
 639      * <p>Again, if we were in the state Enabled and looked for "background", we
 640      * wouldn't find it in Button.Enabled, or in Button, but would at the top
 641      * level in UIManager. So we return that value.</p>
 642      *
 643      * <p>One special note: the "key" passed to this method could be of the form
 644      * "background" or "Button.background" where "Button" equals the prefix
 645      * passed to the NimbusStyle constructor. In either case, it looks for
 646      * "background".</p>
 647      *
 648      * @param ctx
 649      * @param key must not be null
 650      */
 651     @Override public Object get(SynthContext ctx, Object key) {
 652         Values v = getValues(ctx);
 653 
 654         // strip off the prefix, if there is one.
 655         String fullKey = key.toString();
 656         String partialKey = fullKey.substring(fullKey.indexOf(".") + 1);
 657 
 658         Object obj = null;
 659         int xstate = getExtendedState(ctx, v);
 660 
 661         // check the cache
 662         tmpKey.init(partialKey, xstate);
 663         obj = v.cache.get(tmpKey);
 664         boolean wasInCache = obj != null;
 665         if (!wasInCache){
 666             // Search exact matching states and then lesser matching states
 667             RuntimeState s = null;
 668             int[] lastIndex = new int[] {-1};


   1 /*
   2  * Copyright (c) 2005, 2013, 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


 628      * Button.opacity
 629      * Button.Enabled.foreground
 630      * Button.Enabled+Selected.background
 631      * </pre>
 632      *
 633      * <p>In this example, suppose you were in the Enabled+Selected state and
 634      * searched for "foreground". In this case, we first check for
 635      * Button.Enabled+Selected.foreground, but no such color exists. We then
 636      * fall back to the next valid state, in this case,
 637      * Button.Enabled.foreground, and have a match. So we return it.</p>
 638      *
 639      * <p>Again, if we were in the state Enabled and looked for "background", we
 640      * wouldn't find it in Button.Enabled, or in Button, but would at the top
 641      * level in UIManager. So we return that value.</p>
 642      *
 643      * <p>One special note: the "key" passed to this method could be of the form
 644      * "background" or "Button.background" where "Button" equals the prefix
 645      * passed to the NimbusStyle constructor. In either case, it looks for
 646      * "background".</p>
 647      *
 648      * @param ctx SynthContext identifying requester
 649      * @param key must not be null
 650      */
 651     @Override public Object get(SynthContext ctx, Object key) {
 652         Values v = getValues(ctx);
 653 
 654         // strip off the prefix, if there is one.
 655         String fullKey = key.toString();
 656         String partialKey = fullKey.substring(fullKey.indexOf(".") + 1);
 657 
 658         Object obj = null;
 659         int xstate = getExtendedState(ctx, v);
 660 
 661         // check the cache
 662         tmpKey.init(partialKey, xstate);
 663         obj = v.cache.get(tmpKey);
 664         boolean wasInCache = obj != null;
 665         if (!wasInCache){
 666             // Search exact matching states and then lesser matching states
 667             RuntimeState s = null;
 668             int[] lastIndex = new int[] {-1};