view dwtx/draw2d/Animator.d @ 192:c3583c6ec027

Added missing default cases for switch statements
author Frank Benoit <benoit@tionex.de>
date Mon, 03 Nov 2008 22:52:26 +0100
parents 95307ad235d9
children
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 * Port to the D programming language:
 *     Frank Benoit <benoit@tionex.de>
 *******************************************************************************/

module dwtx.draw2d.Animator;

import dwt.dwthelper.utils;
import dwtx.draw2d.IFigure;
import dwtx.draw2d.Animation;

/**
 * Animates some aspect of a figure. Each animator will capture some of the effects of
 * validation of the figures.
 * <P>
 * Animators must be hooked to figure in special ways. Refer to each implementation for
 * the specific requirements. Animators are generally stateless, which allows them to be
 * shared and prevents them from leaking memory.
 *
 * @since 3.2
 */
public abstract class Animator {

this() { }

/**
 * Captures the final state of the given figure. This method is called once after the
 * update manager has completed validation of all invalid figures.
 * @param figure the container
 * @since 3.2
 */
public void capture(IFigure figure) {
    recordFinalState(figure);
}

/**
 * Returns an object encapsulating the current state of the figure. This method is called
 * to capture both the initial and final states.
 * @param figure the figure
 * @return the current state
 * @since 3.2
 */
protected abstract Object getCurrentState(IFigure figure);

/**
 * Plays back the animation for the given figure and returns <code>true</code> if
 * successful. This method does nothing by default and return <code>false</code>.
 * @param figure the figure being animated
 * @return <code>true</code> if playback was successful
 * @since 3.2
 */
protected bool playback(IFigure figure) {
    return false;
}
package bool playback_package(IFigure figure) {
    return playback(figure);
}

/**
 * Sent as playback is starting for a given figure.
 * @param figure the figure
 * @since 3.2
 */
public void playbackStarting(IFigure figure) { }

/**
 * Records the final state information for a figure.
 * @param figure the figure
 * @since 3.2
 */
protected void recordFinalState(IFigure figure) {
    Animation.putFinalState(this, figure, getCurrentState(figure));
}

/**
 * Records initial state information for the given figure.
 * @param figure the container.
 * @since 3.2
 */
protected void recordInitialState(IFigure figure) {
    Animation.putInitialState(this, figure, getCurrentState(figure));
}

/**
 * Sets up the animator for the given figure to be animated. This method is called exactly
 * once time prior to any layouts happening. The animator can capture the figure's current
 * state, and set any animation-time settings for the figure. Changes made to the figure
 * should be reverted in {@link #tearDown(IFigure)}.
 * @param figure the animated figure
 * @since 3.2
 */
public void init(IFigure figure) {
    recordInitialState(figure);
}

/**
 * Reverts any temporary changes made to the figure during animation. This method is
 * called exactly once after all animation has been completed. Subclasses should extend
 * this method to revert any changes.
 * @param figure the animated figure
 * @since 3.2
 * @see #init(IFigure)
 */
public void tearDown(IFigure figure) { }

}