class DefaultAnimationPlan implements AnimationPlan {

    @Override
    public int calculateDistance(AnimationState from, AnimationState to)
    {
        Utilities.checkNull(from, "from");
        Utilities.checkNull(to, "to");
        DefaultAnimationState fromState = getDefaultAnimationState(from);
        validateStepNumber(fromState.getStepNumber());
        DefaultAnimationState toState = getDefaultAnimationState(to);

        int delta = toState.getStepNumber() - fromState.getStepNumber();
        if (fromState.getDirection() == Direction.BACKWARD)
        {
            delta *= -1;
        }

        if (delta >= 0)
        {
            return delta;
        }
        switch (getEndBehavior())
        {
            case BOUNCE:
                return (fromState.getDirection() == Direction.FORWARD ? myAnimationSequence.size() - 1 - fromState.getStepNumber()
                        : fromState.getStepNumber()) * 2 - delta;
            case STOP:
                return Integer.MAX_VALUE;
            case WRAP:
                return myAnimationSequence.size() + delta;
            default:
                throw new UnexpectedEnumException(getEndBehavior());
        }
    }

    public  DefaultAnimationPlan(List<? extends TimeSpan> sequence, EndBehavior endBehavior);

}