01: // The UMLet source code is distributed under the terms of the GPL; see license.txt
02: package com.umlet.control;
03:
04: import com.umlet.element.base.*;
05:
06: /**
07: * <p>Title: </p>
08: * <p>Description: </p>
09: * <p>Copyright: Copyright (c) 2001</p>
10: * <p>Company: </p>
11: * @author unascribed
12: * @version 1.0
13: */
14:
15: public class Move extends Command {
16: //private Vector _entitiesToBeMoved;
17: private Entity _entity;
18:
19: public Entity getEntity() {
20: return _entity;
21: }
22:
23: private int _x, _y;
24:
25: public int getX() {
26: return _x;
27: }
28:
29: public int getY() {
30: return _y;
31: }
32:
33: public Move(Entity e, int x, int y) {
34: _entity = e;
35: _x = x;
36: _y = y;
37: }
38:
39: public void execute() {
40: super .execute();
41: this .getEntity().changeLocation(_x, _y);
42: }
43:
44: public void undo() {
45: super .undo();
46: this .getEntity().changeLocation(-_x, -_y);
47: }
48:
49: public boolean isMergeableTo(Command c) {
50: if (!(c instanceof Move))
51: return false;
52: Move m = (Move) c;
53: return this .getEntity() == m.getEntity();
54: }
55:
56: public Command mergeTo(Command c) {
57: //System.out.println(Controller.getInstance().commands.size()+", ");
58: Move m = (Move) c;
59: Move ret = new Move(this.getEntity(), this.getX() + m.getX(),
60: this.getY() + m.getY());
61: return ret;
62: }
63: }
|