class DefaultContinuousAnimationPlan extends DefaultAnimationPlan implements ContinuousAnimationPlan {

    @Override
    @Nullable
    @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
    public DefaultContinuousAnimationState findState(Date time, Direction direction)
    {
        DefaultAnimationState parentState = super.findState(time, direction);
        if (parentState == null)
        {
            return null;
        }
        TimeSpan parentTime = getTimeSpanForState(parentState);
        TimeSpan timeSpan;
        if (direction == Direction.FORWARD)
        {
            timeSpan = TimeSpan.get(time, myActiveWindowDuration);
        }
        else
        {
            timeSpan = TimeSpan.get(myActiveWindowDuration, time.getTime());
        }
        if (timeSpan.getEnd() > parentTime.getEnd())
        {
            timeSpan = TimeSpan.get(myActiveWindowDuration, parentTime.getEnd());
        }
        else if (timeSpan.getStart() < parentTime.getStart())
        {
            timeSpan = TimeSpan.get(parentTime.getStart(), myActiveWindowDuration);
        }

        return new DefaultContinuousAnimationState(parentState.getStepNumber(), timeSpan, parentState.getDirection());
    }

    public  DefaultContinuousAnimationPlan(List<? extends TimeSpan> sequence, Duration activeWindowDuration,
            Duration advanceDuration, EndBehavior endBehavior, TimeSpan limitWindow);

}