Class AnimationUtilities


  • public class AnimationUtilities
    extends java.lang.Object
    Helper methods for working with animations.
    Author:
    Chris Jennings
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void animateIconTransition​(javax.swing.JButton target, javax.swing.Icon newIcon)
      Performs a subtle animated transition between the icon currently set on target and a new icon.
      static void animateIconTransition​(javax.swing.JLabel target, javax.swing.Icon newIcon)
      Performs a subtle animated transition between the icon currently set on target and a new icon.
      static void animateOpacityTransition​(java.awt.Window w, float startAlpha, float endAlpha, float seconds, boolean disposeOnFinish)
      Animates a change in the opacity of a window, if opacity changes are supported and enabled.
      static void attentionFlash​(javax.swing.JComponent target, java.awt.Color flashColor)
      Calls attention to a component by flashing its background.
      static FrameComposer cut​(FrameComposer original, float start, float end)
      Given a composition, return a new composition that plays a subsequence of the original.
      static FrameComposer loop​(FrameComposer forward)
      Given a composition, return a new composition that can play the original composition in a loop by playing it forwards, then backwards.
      static FrameComposer reverse​(FrameComposer forward)
      Given a composition, return a new composition that plays the original composition in reverse.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • reverse

        public static FrameComposer reverse​(FrameComposer forward)
        Given a composition, return a new composition that plays the original composition in reverse.
        Parameters:
        forward - the forward-playing composition
        Returns:
        a composer that wraps the original composer
      • loop

        public static FrameComposer loop​(FrameComposer forward)
        Given a composition, return a new composition that can play the original composition in a loop by playing it forwards, then backwards.
        Parameters:
        forward - the forward-playing composition
        Returns:
        a composer that wraps the original composer
      • cut

        public static FrameComposer cut​(FrameComposer original,
                                        float start,
                                        float end)
        Given a composition, return a new composition that plays a subsequence of the original.
        Parameters:
        original - the composition to cut
        start - the time point to start the cut at
        end - the time point to end the cut at
        Returns:
        a composer that wraps the original composer
      • animateIconTransition

        public static void animateIconTransition​(javax.swing.JLabel target,
                                                 javax.swing.Icon newIcon)
        Performs a subtle animated transition between the icon currently set on target and a new icon.
        Parameters:
        target - the label whose icon will change
        newIcon - the new icon for the label
      • animateIconTransition

        public static void animateIconTransition​(javax.swing.JButton target,
                                                 javax.swing.Icon newIcon)
        Performs a subtle animated transition between the icon currently set on target and a new icon.
        Parameters:
        target - the label whose icon will change
        newIcon - the new icon for the label
      • animateOpacityTransition

        public static void animateOpacityTransition​(java.awt.Window w,
                                                    float startAlpha,
                                                    float endAlpha,
                                                    float seconds,
                                                    boolean disposeOnFinish)
        Animates a change in the opacity of a window, if opacity changes are supported and enabled.
        Parameters:
        w - the window to animate
        startAlpha - the starting alpha value for the window; if -1, the window's current alpha is used
        endAlpha - the alpha value for the window at the end of animation
        seconds - the duration of the animation
        disposeOnFinish - if true, the window's dispose method is called when the animation completes
        Throws:
        java.lang.NullPointerException - if the window w is null
        java.lang.IllegalArgumentException - if the alpha values are outside of the 0 to 1 range (except that startAlpha may be -1) or if seconds is negative
      • attentionFlash

        public static void attentionFlash​(javax.swing.JComponent target,
                                          java.awt.Color flashColor)
        Calls attention to a component by flashing its background.
        Parameters:
        target - the component to flash
        flashColor - the background colour to use when flashing; if null a default colour is used