|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.ericmignot.modeler.action; |
|
19 |
| |
|
20 |
| import java.awt.Point; |
|
21 |
| |
|
22 |
| import org.ericmignot.modeler.data.BusinessObject; |
|
23 |
| import org.ericmignot.modeler.util.action.ActionException; |
|
24 |
| import org.ericmignot.modeler.util.action.NotifyableAction; |
|
25 |
| |
|
26 |
| public class MoveAction extends NotifyableAction |
|
27 |
| { |
|
28 |
| private BusinessObject businessObject; |
|
29 |
| private Point delta; |
|
30 |
| |
|
31 |
64
| public MoveAction(BusinessObject businessObject, Point delta)
|
|
32 |
| { |
|
33 |
64
| this.businessObject = businessObject;
|
|
34 |
64
| this.delta = delta;
|
|
35 |
| } |
|
36 |
| |
|
37 |
2
| public Point getDelta()
|
|
38 |
| { |
|
39 |
2
| return this.delta;
|
|
40 |
| } |
|
41 |
| |
|
42 |
62
| public Object execute(Object actionParameter) throws ActionException
|
|
43 |
| { |
|
44 |
62
| Point oldLocation = this.businessObject.getCenter();
|
|
45 |
62
| this.businessObject.setCenter(oldLocation.x + this.delta.x,
|
|
46 |
| oldLocation.y + this.delta.y); |
|
47 |
62
| return this.businessObject;
|
|
48 |
| } |
|
49 |
| |
|
50 |
6
| public Object cancel(Object actionParameter) throws ActionException
|
|
51 |
| { |
|
52 |
6
| Point oldLocation = this.businessObject.getCenter();
|
|
53 |
6
| this.businessObject.setCenter(oldLocation.x - this.delta.x,
|
|
54 |
| oldLocation.y - this.delta.y); |
|
55 |
6
| return this.businessObject;
|
|
56 |
| } |
|
57 |
| |
|
58 |
| |
|
59 |
| } |