01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.field.Rectangle;
04: import jimm.datavision.gui.FieldWidget;
05: import jimm.util.I18N;
06:
07: /**
08: * After stretching a field using the mouse, this command lets us undo and
09: * redo the size change.
10: *
11: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
12: */
13: public class FieldStretchCommand extends CommandAdapter {
14:
15: protected FieldWidget fw;
16: protected Rectangle origBounds;
17: protected Rectangle newBounds;
18:
19: public FieldStretchCommand(FieldWidget fw, Rectangle origBounds) {
20: super (I18N.get("FieldStretchCommand.name"));
21:
22: this .fw = fw;
23: this .origBounds = origBounds;
24: }
25:
26: public void perform() {
27: // Remember the field's new bounds.
28: newBounds = new Rectangle(fw.getField().getBounds()); // Make a copy
29: }
30:
31: public void undo() {
32: fw.getField().getBounds().setBounds(origBounds);
33: }
34:
35: public void redo() {
36: fw.getField().getBounds().setBounds(newBounds);
37: }
38:
39: }
|