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: import net.refractions.udig.tools.edit.support.Point;
23:
24: import org.eclipse.core.runtime.IProgressMonitor;
25:
26: public class DeleteVertexAnimation extends AbstractDrawCommand
27: implements IAnimation {
28:
29: private int frame = 0;
30: Point center;
31:
32: /**
33: * @param point
34: */
35: public DeleteVertexAnimation(Point point) {
36: this .center = point;
37: }
38:
39: public short getFrameInterval() {
40: return 50;
41: }
42:
43: public void nextFrame() {
44: frame++;
45: }
46:
47: public boolean hasNext() {
48: return frame < 6;
49: }
50:
51: public void run(IProgressMonitor monitor) throws Exception {
52: graphics.setColor(PreferenceUtil.instance().getFeedbackColor());
53: int a = frame * 4;
54: int c = (int) Math.sqrt(a * a + a * a);
55: int x = center.getX();
56: int y = center.getY();
57: int rad = 3;
58: graphics.fill(new Rectangle(x - c, y, rad, rad));
59: graphics.fill(new Rectangle(x + c, y, rad, rad));
60: graphics.fill(new Rectangle(x, y + c, rad, rad));
61: graphics.fill(new Rectangle(x, y - c, rad, rad));
62:
63: graphics.fill(new Rectangle(x - a, y - a, rad, rad));
64: graphics.fill(new Rectangle(x + a, y - a, rad, rad));
65: graphics.fill(new Rectangle(x + a, y + a, rad, rad));
66: graphics.fill(new Rectangle(x - a, y + a, rad, rad));
67: }
68:
69: public Rectangle getValidArea() {
70: int a = frame * 4;
71: int c = (int) Math.sqrt(a * a + a * a);
72: int x = center.getX();
73: int y = center.getY();
74:
75: return new Rectangle(x - c, y - c, c + c, c + c);
76: }
77:
78: }
|