1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.model.visual;
19
20 import java.beans.PropertyChangeListener;
21
22 import org.eclipse.draw2d.geometry.Point;
23
24 import pl.edu.agh.cast.data.model.property.IPropertyChangeProvider;
25 import pl.edu.agh.cast.data.model.property.PropertyChangeProviderHelper;
26
27
28
29
30
31
32 public class Legend implements IPropertyChangeProvider {
33
34
35
36
37 public static final String LOCATION_EVENT = "Legend.Location";
38
39 private static final int POSITION_TOP = 10;
40
41 private static final int POSITION_RIGHT = 500;
42
43
44
45
46 protected Point location = new Point(2, 2);
47
48
49
50
51 private PropertyChangeProviderHelper pcpHelper = new PropertyChangeProviderHelper(this);
52
53
54
55
56
57 public Legend() {
58 super();
59 location = new Point(POSITION_RIGHT, POSITION_TOP);
60 }
61
62 public Point getLocation() {
63 return location;
64 }
65
66 public void setLocation(Point newLocation) {
67 Point oldLocation = location;
68 location = newLocation;
69 pcpHelper.firePropertyChange(Legend.LOCATION_EVENT, oldLocation, newLocation);
70 }
71
72
73
74
75
76
77
78 @Override
79 public final void addPropertyChangeListener(PropertyChangeListener l) {
80 pcpHelper.addPropertyChangeListener(l);
81 }
82
83
84
85
86
87
88
89 @Override
90 public final void removePropertyChangeListener(PropertyChangeListener l) {
91 pcpHelper.removePropertyChangeListener(l);
92 }
93
94 }