1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.draw2d;
|
12
|
|
13
|
import org.eclipse.draw2d.geometry.Point;
|
14
|
|
15
|
/**
|
16
|
* Supports an anchor in the XY layout. This anchor exists independently without
|
17
|
* an owner.
|
18
|
*/
|
19
|
public class XYAnchor extends ConnectionAnchorBase {
|
20
|
|
21
|
private Point location;
|
22
|
|
23
|
/**
|
24
|
* Constructs an XYAnchor at the Point p.
|
25
|
*
|
26
|
* @param p
|
27
|
* the point where this anchor will be located
|
28
|
* @since 2.0
|
29
|
*/
|
30
|
public XYAnchor(Point p) {
|
31
|
location = new Point(p);
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* Returns the location of this anchor relative to the reference point given
|
36
|
* in as input. Since this is XY layout, the location of the point is
|
37
|
* independent of the reference point.
|
38
|
*
|
39
|
* @see ConnectionAnchor#getLocation(Point)
|
40
|
*/
|
41
|
public Point getLocation(Point reference) {
|
42
|
return location;
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* Returns <code>null</code> as these anchors inherently do not depend on
|
47
|
* other figures for their location.
|
48
|
*
|
49
|
* @see ConnectionAnchor#getOwner()
|
50
|
* @since 2.0
|
51
|
*/
|
52
|
public IFigure getOwner() {
|
53
|
return null;
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* Returns the point which is used as the reference by this connection
|
58
|
* anchor. In the case of the XYAnchor, this point is the same as its
|
59
|
* location.
|
60
|
*
|
61
|
* @see ConnectionAnchor#getReferencePoint()
|
62
|
*/
|
63
|
public Point getReferencePoint() {
|
64
|
return location;
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* Sets the location of this anchor and notifies all the listeners of the
|
69
|
* update.
|
70
|
*
|
71
|
* @param p
|
72
|
* the new location of this anchor
|
73
|
* @see #getLocation(Point)
|
74
|
* @since 2.0
|
75
|
*/
|
76
|
public void setLocation(Point p) {
|
77
|
location.setLocation(p);
|
78
|
fireAnchorMoved();
|
79
|
}
|
80
|
|
81
|
}
|