01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.printing.ui.internal.editor.commands;
18:
19: import net.refractions.udig.printing.model.Box;
20: import net.refractions.udig.printing.ui.internal.Messages;
21:
22: import org.eclipse.draw2d.geometry.Dimension;
23: import org.eclipse.draw2d.geometry.Point;
24: import org.eclipse.gef.commands.Command;
25:
26: /**
27: * Provides ...TODO summary sentence
28: * <p>
29: * TODO Description
30: * </p><p>
31: * Responsibilities:
32: * <ul>
33: * <li>
34: * <li>
35: * </ul>
36: * </p><p>
37: * Example Use:<pre><code>
38: * SetConstraintCommand x = new SetConstraintCommand( ... );
39: * TODO code example
40: * </code></pre>
41: * </p>
42: * @author Richard Gould
43: * @since 0.3
44: */
45: public class SetConstraintCommand extends Command {
46: private Box box;
47: private Point newPos;
48: private Point oldPos;
49:
50: private Dimension newSize;
51: private Dimension oldSize;
52:
53: public void setLocation(Point p) {
54: this .newPos = p;
55: }
56:
57: public void setNode(Box node) {
58: this .box = node;
59: }
60:
61: public void execute() {
62: oldPos = this .box.getLocation();
63: this .box.setLocation(newPos);
64:
65: oldSize = this .box.getSize();
66: this .box.setSize(newSize);
67: }
68:
69: public String getLabel() {
70: return Messages.SetConstraintCommand_label;
71: }
72:
73: public void redo() {
74: this .box.setLocation(newPos);
75: this .box.setSize(newSize);
76: }
77:
78: public void undo() {
79: this .box.setLocation(oldPos);
80: this .box.setSize(oldSize);
81: }
82:
83: public void setSize(Dimension size) {
84: this.newSize = size;
85: }
86: }
|