jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
changeset 37569 bf2bc4d9491d
parent 29894 3e16b51732f5
child 44655 06871a50a4b5
equal deleted inserted replaced
37568:9e458df677e9 37569:bf2bc4d9491d
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   993                 } else if ((xstate & oState) == oState) {
   993                 } else if ((xstate & oState) == oState) {
   994                     // This is key, we need to make sure all bits of the
   994                     // This is key, we need to make sure all bits of the
   995                     // StateInfo match, otherwise a StateInfo with
   995                     // StateInfo match, otherwise a StateInfo with
   996                     // SELECTED | ENABLED would match ENABLED, which we
   996                     // SELECTED | ENABLED would match ENABLED, which we
   997                     // don't want.
   997                     // don't want.
   998 
   998                     int bitCount = Integer.bitCount(oState);
   999                     // This comes from BigInteger.bitCnt
       
  1000                     int bitCount = oState;
       
  1001                     bitCount -= (0xaaaaaaaa & bitCount) >>> 1;
       
  1002                     bitCount = (bitCount & 0x33333333) + ((bitCount >>> 2) &
       
  1003                             0x33333333);
       
  1004                     bitCount = bitCount + (bitCount >>> 4) & 0x0f0f0f0f;
       
  1005                     bitCount += bitCount >>> 8;
       
  1006                     bitCount += bitCount >>> 16;
       
  1007                     bitCount = bitCount & 0xff;
       
  1008                     if (bitCount > bestCount) {
   999                     if (bitCount > bestCount) {
  1009                         bestIndex = counter;
  1000                         bestIndex = counter;
  1010                         bestCount = bitCount;
  1001                         bestCount = bitCount;
  1011                     }
  1002                     }
  1012                 }
  1003                 }