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.behaviour;
16:
17: import net.refractions.udig.project.command.UndoableMapCommand;
18: import net.refractions.udig.tools.edit.Behaviour;
19: import net.refractions.udig.tools.edit.EditPlugin;
20: import net.refractions.udig.tools.edit.EditState;
21: import net.refractions.udig.tools.edit.EditToolHandler;
22: import net.refractions.udig.tools.edit.commands.DifferenceFeatureCommand;
23:
24: /**
25: * <p>Requirements:
26: * <ul>
27: * <li>currentShape is not null</li>
28: * <li>edit blackboard has a geometry that is not the currentShape</li>
29: * <li></li>
30: * </ul>
31: * </p>
32: * <p>Action:
33: * <ul>
34: * <li>Splits the geometry in two on the currentShape and creates 2 features that have the
35: * same attributes but different geometries.</li>
36: * </ul>
37: * </p>
38: * @author jones
39: * @since 1.1.0
40: */
41: public class DifferenceFeatureAcceptor implements Behaviour {
42:
43: public boolean isValid(EditToolHandler handler) {
44: return handler.getCurrentShape() != null
45: && handler.getCurrentShape().getNumPoints() > 0;
46: }
47:
48: public UndoableMapCommand getCommand(EditToolHandler handler) {
49: return new DifferenceFeatureCommand(handler, EditState.NONE);
50: }
51:
52: public void handleError(EditToolHandler handler, Throwable error,
53: UndoableMapCommand command) {
54: EditPlugin.log("", error); //$NON-NLS-1$
55: }
56:
57: }
|