comparison org.eclipse.draw2d/src/org/eclipse/draw2d/Animator.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13
14 module org.eclipse.draw2d.Animator;
15
16 import java.lang.all;
17 import org.eclipse.draw2d.IFigure;
18 import org.eclipse.draw2d.Animation;
19
20 /**
21 * Animates some aspect of a figure. Each animator will capture some of the effects of
22 * validation of the figures.
23 * <P>
24 * Animators must be hooked to figure in special ways. Refer to each implementation for
25 * the specific requirements. Animators are generally stateless, which allows them to be
26 * shared and prevents them from leaking memory.
27 *
28 * @since 3.2
29 */
30 public abstract class Animator {
31
32 this() { }
33
34 /**
35 * Captures the final state of the given figure. This method is called once after the
36 * update manager has completed validation of all invalid figures.
37 * @param figure the container
38 * @since 3.2
39 */
40 public void capture(IFigure figure) {
41 recordFinalState(figure);
42 }
43
44 /**
45 * Returns an object encapsulating the current state of the figure. This method is called
46 * to capture both the initial and final states.
47 * @param figure the figure
48 * @return the current state
49 * @since 3.2
50 */
51 protected abstract Object getCurrentState(IFigure figure);
52
53 /**
54 * Plays back the animation for the given figure and returns <code>true</code> if
55 * successful. This method does nothing by default and return <code>false</code>.
56 * @param figure the figure being animated
57 * @return <code>true</code> if playback was successful
58 * @since 3.2
59 */
60 protected bool playback(IFigure figure) {
61 return false;
62 }
63 package bool playback_package(IFigure figure) {
64 return playback(figure);
65 }
66
67 /**
68 * Sent as playback is starting for a given figure.
69 * @param figure the figure
70 * @since 3.2
71 */
72 public void playbackStarting(IFigure figure) { }
73
74 /**
75 * Records the final state information for a figure.
76 * @param figure the figure
77 * @since 3.2
78 */
79 protected void recordFinalState(IFigure figure) {
80 Animation.putFinalState(this, figure, getCurrentState(figure));
81 }
82
83 /**
84 * Records initial state information for the given figure.
85 * @param figure the container.
86 * @since 3.2
87 */
88 protected void recordInitialState(IFigure figure) {
89 Animation.putInitialState(this, figure, getCurrentState(figure));
90 }
91
92 /**
93 * Sets up the animator for the given figure to be animated. This method is called exactly
94 * once time prior to any layouts happening. The animator can capture the figure's current
95 * state, and set any animation-time settings for the figure. Changes made to the figure
96 * should be reverted in {@link #tearDown(IFigure)}.
97 * @param figure the animated figure
98 * @since 3.2
99 */
100 public void init(IFigure figure) {
101 recordInitialState(figure);
102 }
103
104 /**
105 * Reverts any temporary changes made to the figure during animation. This method is
106 * called exactly once after all animation has been completed. Subclasses should extend
107 * this method to revert any changes.
108 * @param figure the animated figure
109 * @since 3.2
110 * @see #init(IFigure)
111 */
112 public void tearDown(IFigure figure) { }
113
114 }