01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.field.Field;
04: import jimm.datavision.field.Rectangle;
05: import jimm.datavision.gui.FieldWidget;
06: import jimm.util.I18N;
07:
08: /**
09: * Aligns a single field with another.
10: *
11: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
12: */
13: public class FieldAlignCommand extends CommandAdapter {
14:
15: protected FieldWidget fw;
16: protected int which;
17: protected Field prototype;
18: protected Rectangle origBounds;
19:
20: public FieldAlignCommand(FieldWidget fw, int which, Field prototype) {
21: super (I18N.get("FieldAlignCommand.name"));
22:
23: this .fw = fw;
24: this .which = which;
25: this .prototype = prototype;
26: origBounds = new Rectangle(fw.getField().getBounds()); // Make a copy
27: }
28:
29: public void perform() {
30: fw.align(which, prototype);
31: }
32:
33: public void undo() {
34: fw.getField().getBounds().setBounds(origBounds);
35: }
36:
37: }
|