function (state, source, target, points, result)
	{
		var pts = state.absolutePoints;
		
		var p0 = pts[0];
		var pe = pts[pts.length-1];

		if (p0 != null && pe != null)
		{
			if (points != null && points.length > 0)
			{
				for (var i = 0; i < points.length; i++)
				{
					var pt = points[i];
					pt = state.view.transformControlPoint(state, pt);
					result.push(new mxPoint(pt.x, pt.y));
				}
			}

			return;
		}
		
		if (source != null)
		{
			var view = state.view;
			var graph = view.graph;
			var pt = (points != null && points.length > 0) ? points[0] : null;

			if (pt != null)
			{
				pt = view.transformControlPoint(state, pt);
					
				if (mxUtils.contains(source, pt.x, pt.y))
				{
					pt = null;
				}
			}
			
			var x = 0;
			var dx = 0;
			var y = 0;
			var dy = 0;
			
		 	var seg = mxUtils.getValue(state.style, mxConstants.STYLE_SEGMENT,
		 		graph.gridSize) * view.scale;
			var dir = mxUtils.getValue(state.style, mxConstants.STYLE_DIRECTION,
				mxConstants.DIRECTION_WEST);
			
			if (dir == mxConstants.DIRECTION_NORTH ||
				dir == mxConstants.DIRECTION_SOUTH)
			{
				x = view.getRoutingCenterX(source);
				dx = seg;
			}
			else
			{
				y = view.getRoutingCenterY(source);
				dy = seg;
			}
			
			if (pt == null ||
				pt.x < source.x ||
				pt.x > source.x + source.width)
			{
				if (pt != null)
				{
					x = pt.x;
					dy = Math.max(Math.abs(y - pt.y), dy);
				}
				else
				{
					if (dir == mxConstants.DIRECTION_NORTH)
					{
						y = source.y - 2 * dx;
					}
					else if (dir == mxConstants.DIRECTION_SOUTH)
					{
						y = source.y + source.height + 2 * dx;
					}
					else if (dir == mxConstants.DIRECTION_EAST)
					{
						x = source.x - 2 * dy;
					}
					else
					{
						x = source.x + source.width + 2 * dy;
					}
				}
			}
			else if (pt != null)
			{
				x = view.getRoutingCenterX(source);
				dx = Math.max(Math.abs(x - pt.x), dy);
				y = pt.y;
				dy = 0;
			}
			
			result.push(new mxPoint(x - dx, y - dy));
			result.push(new mxPoint(x + dx, y + dy));
		}
	}
function (state, source, target, points, result)
	{
		var pts = state.absolutePoints;
		
		var p0 = pts[0];
		var pe = pts[pts.length-1];

		if (p0 != null && pe != null)
		{
			if (points != null && points.length > 0)
			{
				for (var i = 0; i < points.length; i++)
				{
					var pt = points[i];
					pt = state.view.transformControlPoint(state, pt);
					result.push(new mxPoint(pt.x, pt.y));
				}
			}

			return;
		}
		
		if (source != null)
		{
			var view = state.view;
			var graph = view.graph;
			var pt = (points != null && points.length > 0) ? points[0] : null;

			if (pt != null)
			{
				pt = view.transformControlPoint(state, pt);
					
				if (mxUtils.contains(source, pt.x, pt.y))
				{
					pt = null;
				}
			}
			
			var x = 0;
			var dx = 0;
			var y = 0;
			var dy = 0;
			
		 	var seg = mxUtils.getValue(state.style, mxConstants.STYLE_SEGMENT,
		 		graph.gridSize) * view.scale;
			var dir = mxUtils.getValue(state.style, mxConstants.STYLE_DIRECTION,
				mxConstants.DIRECTION_WEST);
			
			if (dir == mxConstants.DIRECTION_NORTH ||
				dir == mxConstants.DIRECTION_SOUTH)
			{
				x = view.getRoutingCenterX(source);
				dx = seg;
			}
			else
			{
				y = view.getRoutingCenterY(source);
				dy = seg;
			}
			
			if (pt == null ||
				pt.x < source.x ||
				pt.x > source.x + source.width)
			{
				if (pt != null)
				{
					x = pt.x;
					dy = Math.max(Math.abs(y - pt.y), dy);
				}
				else
				{
					if (dir == mxConstants.DIRECTION_NORTH)
					{
						y = source.y - 2 * dx;
					}
					else if (dir == mxConstants.DIRECTION_SOUTH)
					{
						y = source.y + source.height + 2 * dx;
					}
					else if (dir == mxConstants.DIRECTION_EAST)
					{
						x = source.x - 2 * dy;
					}
					else
					{
						x = source.x + source.width + 2 * dy;
					}
				}
			}
			else if (pt != null)
			{
				x = view.getRoutingCenterX(source);
				dx = Math.max(Math.abs(x - pt.x), dy);
				y = pt.y;
				dy = 0;
			}
			
			result.push(new mxPoint(x - dx, y - dy));
			result.push(new mxPoint(x + dx, y + dy));
		}
	}
function ( state , source , target , points , result ) { var pts = state . absolutePoints ; var p0 = pts [ 0 ] ; var pe = pts [ pts . length - 1 ] ; if ( p0 != null && pe != null ) { if ( points != null && points . length > 0 ) { for ( var i = 0 ; i < points . length ; i ++ ) { var pt = points [ i ] ; pt = state . view . transformControlPoint ( state , pt ) ; result . push ( new mxPoint ( pt . x , pt . y ) ) ; } } return ; } if ( source != null ) { var view = state . view ; var graph = view . graph ; var pt = ( points != null && points . length > 0 ) ? points [ 0 ] : null ; if ( pt != null ) { pt = view . transformControlPoint ( state , pt ) ; if ( mxUtils . contains ( source , pt . x , pt . y ) ) { pt = null ; } } var x = 0 ; var dx = 0 ; var y = 0 ; var dy = 0 ; var seg = mxUtils . getValue ( state . style , mxConstants . STYLE_SEGMENT , graph . gridSize ) * view . scale ; var dir = mxUtils . getValue ( state . style , mxConstants . STYLE_DIRECTION , mxConstants . DIRECTION_WEST ) ; if ( dir == mxConstants . DIRECTION_NORTH || dir == mxConstants . DIRECTION_SOUTH ) { x = view . getRoutingCenterX ( source ) ; dx = seg ; } else { y = view . getRoutingCenterY ( source ) ; dy = seg ; } if ( pt == null || pt . x < source . x || pt . x > source . x + source . width ) { if ( pt != null ) { x = pt . x ; dy = Math . max ( Math . abs ( y - pt . y ) , dy ) ; } else { if ( dir == mxConstants . DIRECTION_NORTH ) { y = source . y - 2 * dx ; } else if ( dir == mxConstants . DIRECTION_SOUTH ) { y = source . y + source . height + 2 * dx ; } else if ( dir == mxConstants . DIRECTION_EAST ) { x = source . x - 2 * dy ; } else { x = source . x + source . width + 2 * dy ; } } } else if ( pt != null ) { x = view . getRoutingCenterX ( source ) ; dx = Math . max ( Math . abs ( x - pt . x ) , dy ) ; y = pt . y ; dy = 0 ; } result . push ( new mxPoint ( x - dx , y - dy ) ) ; result . push ( new mxPoint ( x + dx , y + dy ) ) ; } }
Function: Loop

Implements a self-reference, aka. loop.
Function : Loop
Returns the point at which the point is closest to the target point