Mercurial > projects > dwt2
comparison org.eclipse.draw2d/src/org/eclipse/draw2d/AbstractRouter.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.AbstractRouter; | |
14 | |
15 import java.lang.all; | |
16 | |
17 import org.eclipse.draw2d.geometry.Point; | |
18 import org.eclipse.draw2d.Connection; | |
19 import org.eclipse.draw2d.ConnectionRouter; | |
20 | |
21 /** | |
22 * Base class for implementing a connection router. This class provides stubs for | |
23 * constraint usage, and some utility methods. | |
24 */ | |
25 public abstract class AbstractRouter | |
26 : ConnectionRouter | |
27 { | |
28 | |
29 private static Point START_; | |
30 private static Point END_; | |
31 | |
32 private static Point START(){ | |
33 if( !initStaticCtor_done ) initStaticCtor(); | |
34 assert(START_); | |
35 return START_; | |
36 } | |
37 private static Point END(){ | |
38 if( !initStaticCtor_done ) initStaticCtor(); | |
39 assert(END_); | |
40 return END_; | |
41 } | |
42 | |
43 private static bool initStaticCtor_done = false; | |
44 private static void initStaticCtor(){ | |
45 synchronized( AbstractRouter.classinfo ){ | |
46 if( !initStaticCtor_done ){ | |
47 START_ = new Point(); | |
48 END_ = new Point(); | |
49 initStaticCtor_done = true; | |
50 } | |
51 } | |
52 } | |
53 | |
54 /** | |
55 * Returns the constraint for the given Connection. | |
56 * | |
57 * @param connection The connection | |
58 * @return The constraint | |
59 * @since 2.0 | |
60 */ | |
61 public Object getConstraint(Connection connection) { | |
62 return null; | |
63 } | |
64 | |
65 /** | |
66 * A convenience method for obtaining a connection's endpoint. The connection's endpoint | |
67 * is a point in absolute coordinates obtained by using its source and target {@link | |
68 * ConnectionAnchor}. The returned Point is a static singleton that is reused to reduce | |
69 * garbage collection. The caller may modify this point in any way. However, the point | |
70 * will be reused and its values overwritten during the next call to this method. | |
71 * | |
72 * @param connection The connection | |
73 * @return The endpoint | |
74 * @since 2.0 | |
75 */ | |
76 protected Point getEndPoint(Connection connection) { | |
77 Point ref_ = connection.getSourceAnchor().getReferencePoint(); | |
78 return END.setLocation(connection.getTargetAnchor().getLocation(ref_)); | |
79 } | |
80 | |
81 /** | |
82 * A convenience method for obtaining a connection's start point. The connection's | |
83 * startpoint is a point in absolute coordinates obtained by using its source and target | |
84 * {@link ConnectionAnchor}. The returned Point is a static singleton that is reused to | |
85 * reduce garbage collection. The caller may modify this point in any way. However, the | |
86 * point will be reused and its values overwritten during the next call to this method. | |
87 * | |
88 * @param conn The connection | |
89 * @return The start point | |
90 * @since 2.0 | |
91 */ | |
92 protected Point getStartPoint(Connection conn) { | |
93 Point ref_ = conn.getTargetAnchor().getReferencePoint(); | |
94 return START.setLocation(conn.getSourceAnchor().getLocation(ref_)); | |
95 } | |
96 | |
97 /** | |
98 * Causes the router to discard any cached information about the given Connection. | |
99 * | |
100 * @param connection The connection to invalidate | |
101 * @since 2.0 | |
102 */ | |
103 public void invalidate(Connection connection) { } | |
104 | |
105 /** | |
106 * Removes the given Connection from this routers list of Connections it is responsible | |
107 * for. | |
108 * | |
109 * @param connection The connection to remove | |
110 * @since 2.0 | |
111 */ | |
112 public void remove(Connection connection) { } | |
113 | |
114 /** | |
115 * Sets the constraint for the given Connection. | |
116 * | |
117 * @param connection The connection | |
118 * @param constraint The constraint | |
119 * @since 2.0 | |
120 */ | |
121 public void setConstraint(Connection connection, Object constraint) { } | |
122 | |
123 } |