src/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java

Print this page


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


 113             return;
 114         }
 115         AnimationController controller =
 116             AnimationController.getAnimationController();
 117         State oldState = controller.getState(c, part);
 118         if (oldState != newState) {
 119             controller.putState(c, part, newState);
 120             if (newState == State.DEFAULTED) {
 121                 // it seems for DEFAULTED button state Vista does animation from
 122                 // HOT
 123                 oldState = State.HOT;
 124             }
 125             if (oldState != null) {
 126                 long duration;
 127                 if (newState == State.DEFAULTED) {
 128                     //Only button might have DEFAULTED state
 129                     //idk: do not know how to get the value from Vista
 130                     //one second seems plausible value
 131                     duration = 1000;
 132                 } else {
 133                      duration = XPStyle.getXP().getThemeTransitionDuration(


 134                            c, part,
 135                            normalizeState(oldState),
 136                            normalizeState(newState),
 137                            Prop.TRANSITIONDURATIONS);

 138                 }
 139                 controller.startAnimation(c, part, oldState, newState, duration);
 140             }
 141         }
 142     }
 143 
 144     // for scrollbar up, down, left and right button pictures are
 145     // defined by states.  It seems that theme has duration defined
 146     // only for up button states thus we doing this translation here.
 147     private static State normalizeState(State state) {
 148         State rv;
 149         switch (state) {
 150         case DOWNPRESSED:
 151             /* falls through */
 152         case LEFTPRESSED:
 153             /* falls through */
 154         case RIGHTPRESSED:
 155             rv = UPPRESSED;
 156             break;
 157 


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


 113             return;
 114         }
 115         AnimationController controller =
 116             AnimationController.getAnimationController();
 117         State oldState = controller.getState(c, part);
 118         if (oldState != newState) {
 119             controller.putState(c, part, newState);
 120             if (newState == State.DEFAULTED) {
 121                 // it seems for DEFAULTED button state Vista does animation from
 122                 // HOT
 123                 oldState = State.HOT;
 124             }
 125             if (oldState != null) {
 126                 long duration;
 127                 if (newState == State.DEFAULTED) {
 128                     //Only button might have DEFAULTED state
 129                     //idk: do not know how to get the value from Vista
 130                     //one second seems plausible value
 131                     duration = 1000;
 132                 } else {
 133                     XPStyle xp = XPStyle.getXP();
 134                     duration = (xp != null)
 135                                ? xp.getThemeTransitionDuration(
 136                                        c, part,
 137                                        normalizeState(oldState),
 138                                        normalizeState(newState),
 139                                        Prop.TRANSITIONDURATIONS)
 140                                : 1000;
 141                 }
 142                 controller.startAnimation(c, part, oldState, newState, duration);
 143             }
 144         }
 145     }
 146 
 147     // for scrollbar up, down, left and right button pictures are
 148     // defined by states.  It seems that theme has duration defined
 149     // only for up button states thus we doing this translation here.
 150     private static State normalizeState(State state) {
 151         State rv;
 152         switch (state) {
 153         case DOWNPRESSED:
 154             /* falls through */
 155         case LEFTPRESSED:
 156             /* falls through */
 157         case RIGHTPRESSED:
 158             rv = UPPRESSED;
 159             break;
 160