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;
16:
17: import net.refractions.udig.tools.edit.support.EditGeom;
18:
19: /**
20: * An extension interface allowing an EventBehaviour to Lock the tool handler.
21: * <p>
22: * Certain types of events need to be able to "lock" the tool handler
23: * so that it is the only event getting events until it "unlocks" the tool handler.
24: * </p><p>
25: * Example:
26: * </p><p>
27: * The Polygon tool has a BoxSelection behaviour that accepts drag events and draws a
28: * rectangle until the mouse is released (at that point it selects the vertices that are with
29: * the box).
30: * </p><p>
31: * The Polygon tool also has a move geometry behaviour that moves the geometry when the mouse
32: * is dragged over an {@link EditGeom}.
33: * </p><p>
34: * Given these two behaviours the following case can occur: The mouse is pressed (not over a
35: * geometry) and the BoxSelection behaviour starts drawing the selection box. The mouse drags
36: * over a Geometry and the MoveGeometry behaviour starts as well.
37: * </p><p>
38: * One solution is to put both behaviours in a {@link net.refractions.udig.tools.edit.MutualExclusiveEventBehavior} so that if the BoxSelection
39: * behaviour is running then the MoveGeometryBehaviour won't. However if the MoveGeometryBehaviour
40: * starts then the BoxSelection behaviour may as well.
41: * </p>
42: * @author jones
43: * @since 1.1.0
44: */
45: public interface LockingBehaviour extends EventBehaviour {
46: /**
47: * If the object returned by getKey() is the same as the object that the {@link EditToolHandler}
48: * has as its lock this object may unlock the EditToolHandler and is also permitted
49: * to run.
50: * @param handler handler that is calling getKey.
51: *
52: * @return the object that this behaviour uses as a key.
53: */
54: Object getKey(EditToolHandler handler);
55: }
|