Mercurial > projects > dwt2
comparison org.eclipse.draw2d/src/org/eclipse/draw2d/BendpointLocator.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
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 org.eclipse.draw2d.BendpointLocator; | |
14 | |
15 import java.lang.all; | |
16 | |
17 import org.eclipse.draw2d.geometry.Point; | |
18 import org.eclipse.draw2d.ConnectionLocator; | |
19 import org.eclipse.draw2d.Connection; | |
20 | |
21 /** | |
22 * Places a figure relative to a specified bend in a {@link Connection}. A bendpoint is | |
23 * one of the points returned in the connection's {@link Connection#getPoints()} method. | |
24 * It is not related to the bendpoint class used as routing constraints. | |
25 */ | |
26 public class BendpointLocator | |
27 : ConnectionLocator | |
28 { | |
29 | |
30 private int index; | |
31 | |
32 /** | |
33 * Creates a BendpointLocator associated with passed Connection c and index i. | |
34 * | |
35 * @param c Connection associated with BendpointLocator | |
36 * @param i Index of bendpoint, represents the position of the bendpoint on Connection c | |
37 * @since 2.0 | |
38 */ | |
39 public this(Connection c, int i) { | |
40 super(c); | |
41 index = i; | |
42 } | |
43 | |
44 /** | |
45 * Returns the index of this BendpointLocator. This index is the position of the reference | |
46 * point in this BendpointLocator's {@link Connection}. | |
47 * | |
48 * @return The index | |
49 * @since 2.0 | |
50 */ | |
51 protected int getIndex() { | |
52 return index; | |
53 } | |
54 | |
55 /** | |
56 * Returns reference point associated with the BendpointLocator. This Point is taken from | |
57 * the BendpointLocator's connection and is point number 'index'. | |
58 * | |
59 * @return The reference point | |
60 * @since 2.0 | |
61 */ | |
62 protected Point getReferencePoint() { | |
63 Point p = getConnection().getPoints().getPoint(Point.SINGLETON, getIndex()); | |
64 getConnection().translateToAbsolute(p); | |
65 return p; | |
66 } | |
67 | |
68 } |