public void doFade ( ColorDelta target , String groupName ) { FadeState fadeState = timers . get ( groupName ) ; // Set up the color interpolator. Iterator < Color > interpolator = new ColorInterpolator ( startColor , endColor , 8 ) . iterator ( ) ; if ( fadeState == null ) { // Create a new fade state for the target group, and a timer to run it. Timer timer = new Timer ( 20 , this ) ; fadeState = new FadeState ( timer , target , interpolator ) ; timers . put ( groupName , fadeState ) ; } else { // Kill any previous fade and replace the target with the new one. fadeState . timer . stop ( ) ; fadeState . target = target ; fadeState . interpolator = interpolator ; } // Iterate to the initial color. Color firstColor = fadeState . interpolator . next ( ) ; fadeState . target . changeColor ( firstColor ) ; // Kick off the fade timer. fadeState . timer . setActionCommand ( groupName ) ; fadeState . timer . setInitialDelay ( 400 ) ; fadeState . timer . start ( ) ; }
Requests a color fade against the specified target under a group name .