Mercurial > projects > dwt-addons
comparison dwtx/draw2d/ConnectionAnchorBase.d @ 98:95307ad235d9
Added Draw2d code, still work in progress
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 00:52:14 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
96:b492ba44e44d | 98:95307ad235d9 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2005 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.draw2d.ConnectionAnchorBase; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 import dwtx.dwtxhelper.Collection; | |
17 | |
18 import dwtx.draw2d.ConnectionAnchor; | |
19 import dwtx.draw2d.AnchorListener; | |
20 | |
21 /** | |
22 * Provides support for a ConnectionAnchor. A ConnectionAnchor is one of the end points | |
23 * of a {@link Connection}. It holds listeners and notifies them if the anchor is moved. | |
24 */ | |
25 public abstract class ConnectionAnchorBase | |
26 : ConnectionAnchor | |
27 { | |
28 | |
29 /** | |
30 * The list of listeners | |
31 */ | |
32 protected List listeners; | |
33 | |
34 this(){ | |
35 listeners = new ArrayList(1); | |
36 } | |
37 | |
38 /** | |
39 * @see dwtx.draw2d.ConnectionAnchor#addAnchorListener(AnchorListener) | |
40 */ | |
41 public void addAnchorListener(AnchorListener listener) { | |
42 listeners.add(cast(Object)listener); | |
43 } | |
44 | |
45 /** | |
46 * @see dwtx.draw2d.ConnectionAnchor#removeAnchorListener(AnchorListener) | |
47 */ | |
48 public void removeAnchorListener(AnchorListener listener) { | |
49 listeners.remove(cast(Object)listener); | |
50 } | |
51 | |
52 /** | |
53 * Notifies all the listeners in the list of a change in position of this anchor. This is | |
54 * called from one of the implementing anchors when its location is changed. | |
55 * | |
56 * @since 2.0 | |
57 */ | |
58 protected void fireAnchorMoved() { | |
59 Iterator iter = listeners.iterator(); | |
60 while (iter.hasNext()) | |
61 (cast(AnchorListener)iter.next()).anchorMoved(this); | |
62 } | |
63 | |
64 } |