Mercurial > projects > dwt-addons
comparison dwtx/draw2d/ArrowLocator.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.ArrowLocator; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 import dwtx.draw2d.geometry.PointList; | |
18 import dwtx.draw2d.ConnectionLocator; | |
19 import dwtx.draw2d.IFigure; | |
20 import dwtx.draw2d.Connection; | |
21 import dwtx.draw2d.RotatableDecoration; | |
22 | |
23 /** | |
24 * Locator used to place a {@link RotatableDecoration} on a {@link Connection}. The | |
25 * decoration can be placed at the source or target end of the connection figure. The | |
26 * default connection implementation uses a {@link DelegatingLayout} which requires | |
27 * locators. | |
28 */ | |
29 public class ArrowLocator : ConnectionLocator { | |
30 | |
31 /** | |
32 * Constructs an ArrowLocator associated with passed connection and tip location (either | |
33 * {@link ConnectionLocator#SOURCE} or {@link ConnectionLocator#TARGET}). | |
34 * | |
35 * @param connection The connection associated with the locator | |
36 * @param location Location of the arrow decoration | |
37 * @since 2.0 | |
38 */ | |
39 public this(Connection connection, int location) { | |
40 super(connection, location); | |
41 } | |
42 | |
43 /** | |
44 * Relocates the passed in figure (which must be a {@link RotatableDecoration}) at either | |
45 * the start or end of the connection. | |
46 * @param target The RotatableDecoration to relocate | |
47 */ | |
48 public void relocate(IFigure target) { | |
49 PointList points = getConnection().getPoints(); | |
50 RotatableDecoration arrow = cast(RotatableDecoration)target; | |
51 arrow.setLocation(getLocation(points)); | |
52 | |
53 if (getAlignment() is SOURCE) | |
54 arrow.setReferencePoint(points.getPoint(1)); | |
55 else if (getAlignment() is TARGET) | |
56 arrow.setReferencePoint(points.getPoint(points.size() - 2)); | |
57 } | |
58 | |
59 } |