Class PColorActivity


public class PColorActivity extends PInterpolatingActivity
PColorActivity interpolates between two colors for its target over the duration of the animation. The source color is retrieved from the target just before the activity is scheduled to start.

Version:
1.0
Author:
Jesse Grosjean
  • Constructor Details

    • PColorActivity

      public PColorActivity(long duration, long stepRate, PColorActivity.Target aTarget)
      Constructs a color activity for the given target that will animate for the duration provided at an interval of stepRate. Destination color must be assigned later.
      Parameters:
      duration - duration in milliseconds that the animation should last
      stepRate - the time between interpolations
      aTarget - the target onto which the animation is being performed
    • PColorActivity

      public PColorActivity(long duration, long stepRate, PColorActivity.Target aTarget, Color aDestination)
      Constructs a color activity for the given target that will animate for the duration provided at an interval of stepRate from the target's starting color to the destination color.
      Parameters:
      duration - duration in milliseconds that the animation should last
      stepRate - the time between interpolations
      aTarget - the target onto which the animation is being performed
      aDestination - the color to which the animation is aiming at
    • PColorActivity

      public PColorActivity(long duration, long stepRate, int loopCount, int mode, PColorActivity.Target aTarget, Color aDestination)
      Create a new PColorActivity.
      Parameters:
      duration - the length of one loop of the activity
      stepRate - the amount of time between steps of the activity
      loopCount - number of times the activity should reschedule itself
      mode - defines how the activity interpolates between states
      aTarget - the object that the activity will be applied to and where the source state will be taken from.
      aDestination - the destination color state
  • Method Details

    • isAnimation

      protected boolean isAnimation()
      Returns true since all PColorActivities animate the scene.
      Overrides:
      isAnimation in class PActivity
      Returns:
      always returns true
    • getDestinationColor

      public Color getDestinationColor()
      Return the final color that will be set on the color activities target when the activity stops stepping.
      Returns:
      the final color for this color activity
    • setDestinationColor

      public void setDestinationColor(Color newDestination)
      Set the final color that will be set on the color activities target when the activity stops stepping.
      Parameters:
      newDestination - to animate towards
    • activityStarted

      protected void activityStarted()
      Overrides it's parent to ensure that the source color is the color of the node being animated.
      Overrides:
      activityStarted in class PInterpolatingActivity
    • setRelativeTargetValue

      public void setRelativeTargetValue(float zeroToOne)
      Interpolates the target node's color by mixing the source color and the destination color.
      Overrides:
      setRelativeTargetValue in class PInterpolatingActivity
      Parameters:
      zeroToOne - 0 = all source color, 1 = all destination color