1
/* This notice must be untouched at all times.
4
The latest version is available at
5
http://www.openjacob.org
7
Copyright (c) 2006 Andreas Herz. All rights reserved.
8
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )
12
This library is free software; you can redistribute it and/or
13
modify it under the terms of the GNU Lesser General Public
14
License (LGPL) as published by the Free Software Foundation; either
15
version 2.1 of the License, or (at your option) any later version.
17
This library is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
Lesser General Public License for more details.
22
You should have received a copy of the GNU Lesser General Public
23
License along with this library; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
25
or see http://www.gnu.org/copyleft/lesser.html
29
* @class Routes a {@link draw2d.Connection}, possibly using a constraint.
32
* @author Andreas Herz
35
draw2d.ConnectionRouter=function()
39
draw2d.ConnectionRouter.prototype.type="ConnectionRouter";
43
* Returns the direction the point <i>p</i> is in relation to the given rectangle.
44
* Possible values are LEFT (-1,0), RIGHT (1,0), UP (0,-1) and DOWN (0,1).
46
* @param r the rectangle
48
* @return the direction from <i>r</i> to <i>p</i>
50
draw2d.ConnectionRouter.prototype.getDirection=function(/*:draw2d.Dimension*/ r, /*:draw2d.Point*/ p)
56
var distance = Math.abs(r.x - p.x);
59
var i=Math.abs(r.y - p.y);
66
i = Math.abs(r.getBottom() - p.y);
73
i = Math.abs(r.getRight() - p.x);
83
draw2d.ConnectionRouter.prototype.getEndDirection=function(/*:draw2d.Connection*/ conn)
85
var p = conn.getEndPoint();
86
var rect = conn.getTarget().getParent().getBounds();
87
return this.getDirection(rect, p);
92
draw2d.ConnectionRouter.prototype.getStartDirection=function(/*:draw2d.Connection*/ conn)
94
var p = conn.getStartPoint();
95
var rect = conn.getSource().getParent().getBounds();
96
return this.getDirection(rect, p);
101
* Routes the Connection.
102
* @param connection The Connection to route
104
draw2d.ConnectionRouter.prototype.route=function(/*:draw2d.Connection*/ connection)