1 30 31 package com.jgoodies.animation.animations; 32 33 import com.jgoodies.animation.AbstractAnimation; 34 import com.jgoodies.animation.AnimationFunction; 35 import com.jgoodies.animation.AnimationFunctions; 36 import com.jgoodies.animation.components.FanComponent; 37 38 39 49 public final class FanAnimation extends AbstractAnimation { 50 51 public static final double DEFAULT_CLOCKWISE_ROTATION = 0.01; public static final double DEFAULT_ANTICLOCKWISE_ROTATION = -0.02; 53 54 55 private final FanComponent fan; 56 private final AnimationFunctions.FloatFunction rotationFunction; 57 58 59 67 public FanAnimation(FanComponent fan, long duration, AnimationFunction rotationFunction) { 68 super(duration); 69 this.fan = fan; 70 this.rotationFunction = 71 AnimationFunctions.asFloat(rotationFunction != null 72 ? rotationFunction 73 : defaultRotationFunction(duration)); 74 } 75 76 77 84 public static FanAnimation defaultFan(FanComponent fan, long duration) { 85 return new FanAnimation(fan, duration, null); 86 } 87 88 89 95 public static AnimationFunction defaultRotationFunction(long duration) { 96 return AnimationFunctions.fromTo(duration, 0f, (float) (Math.PI * 2.0f)); 97 } 98 99 100 105 protected void applyEffect(long time) { 106 fan.setRotation(rotationFunction.valueAt(time)); 107 } 108 109 } | Popular Tags |