Mercurial > projects > dwt-addons
comparison dwtx/draw2d/XYAnchor.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.XYAnchor; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 import dwtx.draw2d.geometry.Point; | |
18 import dwtx.draw2d.ConnectionAnchorBase; | |
19 import dwtx.draw2d.IFigure; | |
20 | |
21 /** | |
22 * Supports an anchor in the XY layout. This anchor exists independently without an owner. | |
23 */ | |
24 public class XYAnchor | |
25 : ConnectionAnchorBase | |
26 { | |
27 | |
28 private Point location; | |
29 | |
30 /** | |
31 * Constructs an XYAnchor at the Point p. | |
32 * | |
33 * @param p the point where this anchor will be located | |
34 * @since 2.0 | |
35 */ | |
36 public this(Point p) { | |
37 location = new Point(p); | |
38 } | |
39 | |
40 /** | |
41 * Returns the location of this anchor relative to the reference point given in as input. | |
42 * Since this is XY layout, the location of the point is independent of the reference | |
43 * point. | |
44 * | |
45 * @see ConnectionAnchor#getLocation(Point) | |
46 */ | |
47 public Point getLocation(Point reference) { | |
48 return location; | |
49 } | |
50 | |
51 /** | |
52 * Returns <code>null</code> as these anchors inherently do not depend on other figures | |
53 * for their location. | |
54 * | |
55 * @see ConnectionAnchor#getOwner() | |
56 * @since 2.0 | |
57 */ | |
58 public IFigure getOwner() { | |
59 return null; | |
60 } | |
61 | |
62 /** | |
63 * Returns the point which is used as the reference by this connection anchor. In the case | |
64 * of the XYAnchor, this point is the same as its location. | |
65 * | |
66 * @see ConnectionAnchor#getReferencePoint() | |
67 */ | |
68 public Point getReferencePoint() { | |
69 return location; | |
70 } | |
71 | |
72 /** | |
73 * Sets the location of this anchor and notifies all the listeners of the update. | |
74 * | |
75 * @param p the new location of this anchor | |
76 * @see #getLocation(Point) | |
77 * @since 2.0 | |
78 */ | |
79 public void setLocation(Point p) { | |
80 location.setLocation(p); | |
81 fireAnchorMoved(); | |
82 } | |
83 | |
84 } |