01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.project.ui.internal.commands.draw;
16:
17: import java.util.List;
18:
19: import net.refractions.udig.project.command.AbstractCommand;
20: import net.refractions.udig.project.command.UndoableMapCommand;
21: import net.refractions.udig.project.render.displayAdapter.IMapDisplay;
22: import net.refractions.udig.project.ui.AnimationUpdater;
23: import net.refractions.udig.project.ui.IAnimation;
24: import net.refractions.udig.project.ui.internal.Messages;
25:
26: import org.eclipse.core.runtime.IProgressMonitor;
27:
28: /**
29: * Stops an animation on run and starts it on rollback.
30: *
31: * @author jones
32: * @since 1.1.0
33: */
34: public class StartAnimationCommand extends AbstractCommand implements
35: UndoableMapCommand {
36:
37: private List<IAnimation> animations;
38: private IMapDisplay display;
39:
40: /**
41: * New instance
42: * @param animations animations to run.
43: */
44: public StartAnimationCommand(IMapDisplay display,
45: List<IAnimation> animations) {
46: this .animations = animations;
47: this .display = display;
48: }
49:
50: public void run(IProgressMonitor monitor) throws Exception {
51: for (IAnimation anim : animations) {
52: anim.setValid(true);
53: AnimationUpdater.runTimer(display, anim);
54: }
55: }
56:
57: public void rollback(IProgressMonitor monitor) throws Exception {
58: for (IAnimation anim : animations) {
59: anim.setValid(false);
60: }
61: }
62:
63: public String getName() {
64: return Messages.StartAnimationCommand_name;
65: }
66:
67: }
|