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.tools.edit.animation;
16:
17: import java.awt.Rectangle;
18:
19: import net.refractions.udig.project.ui.IAnimation;
20: import net.refractions.udig.project.ui.commands.AbstractDrawCommand;
21: import net.refractions.udig.tools.edit.preferences.PreferenceUtil;
22:
23: import org.eclipse.core.runtime.IProgressMonitor;
24:
25: /**
26: * A simple animation to run when adding a vertex
27: *
28: * @author jones
29: * @since 1.1.0
30: */
31: public class AddVertexAnimation extends AbstractDrawCommand implements
32: IAnimation {
33:
34: private int frame;
35: private int y;
36: private int x;
37:
38: public AddVertexAnimation(int x, int y) {
39: this .x = x;
40: this .y = y;
41: }
42:
43: public short getFrameInterval() {
44: return 100;
45: }
46:
47: public void nextFrame() {
48: frame++;
49: }
50:
51: public boolean hasNext() {
52: return frame < 6;
53: }
54:
55: public void run(IProgressMonitor monitor) throws Exception {
56:
57: graphics.setColor(PreferenceUtil.instance().getFeedbackColor());
58: int rad = 25 - (frame * 5);
59: graphics.drawOval(x - rad, y - rad, rad * 2, rad * 2);
60: }
61:
62: public Rectangle getValidArea() {
63: int rad = 25 - (frame * 5);
64: return new Rectangle(x - rad, y - rad, rad * 2, rad * 2);
65: }
66:
67: }
|