Project

General

Profile

Download (3.28 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 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
 *******************************************************************************/
11
package org.eclipse.draw2d;
12

    
13
import org.eclipse.draw2d.geometry.Point;
14

    
15
/**
16
 * Base class for implementing a connection router. This class provides stubs
17
 * for constraint usage, and some utility methods.
18
 */
19
public abstract class AbstractRouter implements ConnectionRouter {
20

    
21
	private static final Point START = new Point();
22
	private static final Point END = new Point();
23

    
24
	/**
25
	 * Returns the constraint for the given Connection.
26
	 * 
27
	 * @param connection
28
	 *            The connection
29
	 * @return The constraint
30
	 * @since 2.0
31
	 */
32
	public Object getConstraint(Connection connection) {
33
		return null;
34
	}
35

    
36
	/**
37
	 * A convenience method for obtaining a connection's endpoint. The
38
	 * connection's endpoint is a point in absolute coordinates obtained by
39
	 * using its source and target {@link ConnectionAnchor}. The returned Point
40
	 * is a static singleton that is reused to reduce garbage collection. The
41
	 * caller may modify this point in any way. However, the point will be
42
	 * reused and its values overwritten during the next call to this method.
43
	 * 
44
	 * @param connection
45
	 *            The connection
46
	 * @return The endpoint
47
	 * @since 2.0
48
	 */
49
	protected Point getEndPoint(Connection connection) {
50
		Point ref = connection.getSourceAnchor().getReferencePoint();
51
		return END.setLocation(connection.getTargetAnchor().getLocation(ref));
52
	}
53

    
54
	/**
55
	 * A convenience method for obtaining a connection's start point. The
56
	 * connection's startpoint is a point in absolute coordinates obtained by
57
	 * using its source and target {@link ConnectionAnchor}. The returned Point
58
	 * is a static singleton that is reused to reduce garbage collection. The
59
	 * caller may modify this point in any way. However, the point will be
60
	 * reused and its values overwritten during the next call to this method.
61
	 * 
62
	 * @param conn
63
	 *            The connection
64
	 * @return The start point
65
	 * @since 2.0
66
	 */
67
	protected Point getStartPoint(Connection conn) {
68
		Point ref = conn.getTargetAnchor().getReferencePoint();
69
		return START.setLocation(conn.getSourceAnchor().getLocation(ref));
70
	}
71

    
72
	/**
73
	 * Causes the router to discard any cached information about the given
74
	 * Connection.
75
	 * 
76
	 * @param connection
77
	 *            The connection to invalidate
78
	 * @since 2.0
79
	 */
80
	public void invalidate(Connection connection) {
81
	}
82

    
83
	/**
84
	 * Removes the given Connection from this routers list of Connections it is
85
	 * responsible for.
86
	 * 
87
	 * @param connection
88
	 *            The connection to remove
89
	 * @since 2.0
90
	 */
91
	public void remove(Connection connection) {
92
	}
93

    
94
	/**
95
	 * Sets the constraint for the given Connection.
96
	 * 
97
	 * @param connection
98
	 *            The connection
99
	 * @param constraint
100
	 *            The constraint
101
	 * @since 2.0
102
	 */
103
	public void setConstraint(Connection connection, Object constraint) {
104
	}
105

    
106
}
(11-11/171)