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 java.util.ArrayList;
|
14
|
import java.util.Iterator;
|
15
|
import java.util.List;
|
16
|
|
17
|
/**
|
18
|
* Provides support for a ConnectionAnchor. A ConnectionAnchor is one of the end
|
19
|
* points of a {@link Connection}. It holds listeners and notifies them if the
|
20
|
* anchor is moved.
|
21
|
*/
|
22
|
public abstract class ConnectionAnchorBase implements ConnectionAnchor {
|
23
|
|
24
|
/**
|
25
|
* The list of listeners
|
26
|
*/
|
27
|
protected List listeners = new ArrayList(1);
|
28
|
|
29
|
/**
|
30
|
* @see org.eclipse.draw2d.ConnectionAnchor#addAnchorListener(AnchorListener)
|
31
|
*/
|
32
|
public void addAnchorListener(AnchorListener listener) {
|
33
|
listeners.add(listener);
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* @see org.eclipse.draw2d.ConnectionAnchor#removeAnchorListener(AnchorListener)
|
38
|
*/
|
39
|
public void removeAnchorListener(AnchorListener listener) {
|
40
|
listeners.remove(listener);
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* Notifies all the listeners in the list of a change in position of this
|
45
|
* anchor. This is called from one of the implementing anchors when its
|
46
|
* location is changed.
|
47
|
*
|
48
|
* @since 2.0
|
49
|
*/
|
50
|
protected void fireAnchorMoved() {
|
51
|
Iterator iter = listeners.iterator();
|
52
|
while (iter.hasNext())
|
53
|
((AnchorListener) iter.next()).anchorMoved(this);
|
54
|
}
|
55
|
|
56
|
}
|