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.core.IProvider;
20: import net.refractions.udig.project.ui.IAnimation;
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 SearchBoxAnimation extends AbstractLongRunningAnimation
27: implements IAnimation {
28:
29: protected Point center;
30: private long start;
31:
32: public SearchBoxAnimation(Point center,
33: IProvider<Boolean> isValidProvider) {
34: super (PreferenceUtil.instance().getSnappingRadius(),
35: isValidProvider);
36: this .center = center;
37: start = System.currentTimeMillis();
38: }
39:
40: public void run(IProgressMonitor monitor) throws Exception {
41: graphics.setColor(PreferenceUtil.instance().getFeedbackColor());
42: int radius = PreferenceUtil.instance().getSnappingRadius();
43: graphics.drawOval(center.getX() - radius, center.getY()
44: - radius, radius * 2, radius * 2);
45:
46: graphics.drawOval(center.getX() - frame, center.getY() - frame,
47: frame * 2, frame * 2);
48:
49: }
50:
51: public short getFrameInterval() {
52: return 50;
53: }
54:
55: @Override
56: public boolean isValid() {
57: return super .isValid()
58: && System.currentTimeMillis() - start < 10000;
59: }
60:
61: public Rectangle getValidArea() {
62: int radius = PreferenceUtil.instance().getSnappingRadius() + 1;
63: return new Rectangle(center.getX() - radius, center.getY()
64: - radius, radius + radius, radius + radius);
65: }
66:
67: }
|