dist/joint.nowrap.js
function router(vertices, opt, linkView) {

        var sourceBBox = getSourceBBox(linkView, opt);
        var targetBBox = getTargetBBox(linkView, opt);

        var sourceAnchor = getSourceAnchor(linkView, opt);
        var targetAnchor = getTargetAnchor(linkView, opt);

        // if anchor lies outside of bbox, the bbox expands to include it
        sourceBBox = sourceBBox.union(getPointBox(sourceAnchor));
        targetBBox = targetBBox.union(getPointBox(targetAnchor));

        vertices = util.toArray(vertices).map(g.Point);
        vertices.unshift(sourceAnchor);
        vertices.push(targetAnchor);

        var bearing; // bearing of previous route segment

        var orthogonalVertices = []; // the array of found orthogonal vertices to be returned
        for (var i = 0, max = vertices.length - 1; i < max; i++) {

            var route = null;

            var from = vertices[i];
            var to = vertices[i + 1];

            var isOrthogonal = !!getBearing(from, to);

            if (i === 0) { // source

                if (i + 1 === max) { // route source -> target

                    // Expand one of the elements by 1px to detect situations when the two
                    // elements are positioned next to each other with no gap in between.
                    if (sourceBBox.intersect(targetBBox.clone().inflate(1))) {
                        route = insideElement(from, to, sourceBBox, targetBBox);

                    } else if (!isOrthogonal) {
                        route = elementElement(from, to, sourceBBox, targetBBox);
                    }

                } else { // route source -> vertex

                    if (sourceBBox.containsPoint(to)) {
                        route = insideElement(from, to, sourceBBox, getPointBox(to).moveAndExpand(getPaddingBox(opt)));

                    } else if (!isOrthogonal) {
                        route = elementVertex(from, to, sourceBBox);
                    }
                }

            } else if (i + 1 === max) { // route vertex -> target

                // prevent overlaps with previous line segment
                var isOrthogonalLoop = isOrthogonal && getBearing(to, from) === bearing;

                if (targetBBox.containsPoint(from) || isOrthogonalLoop) {
                    route = insideElement(from, to, getPointBox(from).moveAndExpand(getPaddingBox(opt)), targetBBox, bearing);

                } else if (!isOrthogonal) {
                    route = vertexElement(from, to, targetBBox, bearing);
                }

            } else if (!isOrthogonal) { // route vertex -> vertex
                route = vertexVertex(from, to, bearing);
            }

            // applicable to all routes:

            // set bearing for next iteration
            if (route) {
                Array.prototype.push.apply(orthogonalVertices, route.points);
                bearing = route.direction;

            } else {
                // orthogonal route and not looped
                bearing = getBearing(from, to);
            }

            // push `to` point to identified orthogonal vertices array
            if (i + 1 < max) {
                orthogonalVertices.push(to);
            }
        }

        return orthogonalVertices;
    }
function router(vertices, opt, linkView) {

        var sourceBBox = getSourceBBox(linkView, opt);
        var targetBBox = getTargetBBox(linkView, opt);

        var sourceAnchor = getSourceAnchor(linkView, opt);
        var targetAnchor = getTargetAnchor(linkView, opt);

        // if anchor lies outside of bbox, the bbox expands to include it
        sourceBBox = sourceBBox.union(getPointBox(sourceAnchor));
        targetBBox = targetBBox.union(getPointBox(targetAnchor));

        vertices = util.toArray(vertices).map(g.Point);
        vertices.unshift(sourceAnchor);
        vertices.push(targetAnchor);

        var bearing; // bearing of previous route segment

        var orthogonalVertices = []; // the array of found orthogonal vertices to be returned
        for (var i = 0, max = vertices.length - 1; i < max; i++) {

            var route = null;

            var from = vertices[i];
            var to = vertices[i + 1];

            var isOrthogonal = !!getBearing(from, to);

            if (i === 0) { // source

                if (i + 1 === max) { // route source -> target

                    // Expand one of the elements by 1px to detect situations when the two
                    // elements are positioned next to each other with no gap in between.
                    if (sourceBBox.intersect(targetBBox.clone().inflate(1))) {
                        route = insideElement(from, to, sourceBBox, targetBBox);

                    } else if (!isOrthogonal) {
                        route = elementElement(from, to, sourceBBox, targetBBox);
                    }

                } else { // route source -> vertex

                    if (sourceBBox.containsPoint(to)) {
                        route = insideElement(from, to, sourceBBox, getPointBox(to).moveAndExpand(getPaddingBox(opt)));

                    } else if (!isOrthogonal) {
                        route = elementVertex(from, to, sourceBBox);
                    }
                }

            } else if (i + 1 === max) { // route vertex -> target

                // prevent overlaps with previous line segment
                var isOrthogonalLoop = isOrthogonal && getBearing(to, from) === bearing;

                if (targetBBox.containsPoint(from) || isOrthogonalLoop) {
                    route = insideElement(from, to, getPointBox(from).moveAndExpand(getPaddingBox(opt)), targetBBox, bearing);

                } else if (!isOrthogonal) {
                    route = vertexElement(from, to, targetBBox, bearing);
                }

            } else if (!isOrthogonal) { // route vertex -> vertex
                route = vertexVertex(from, to, bearing);
            }

            // applicable to all routes:

            // set bearing for next iteration
            if (route) {
                Array.prototype.push.apply(orthogonalVertices, route.points);
                bearing = route.direction;

            } else {
                // orthogonal route and not looped
                bearing = getBearing(from, to);
            }

            // push `to` point to identified orthogonal vertices array
            if (i + 1 < max) {
                orthogonalVertices.push(to);
            }
        }

        return orthogonalVertices;
    }
function router ( vertices , opt , linkView ) { var sourceBBox = getSourceBBox ( linkView , opt ) ; var targetBBox = getTargetBBox ( linkView , opt ) ; var sourceAnchor = getSourceAnchor ( linkView , opt ) ; var targetAnchor = getTargetAnchor ( linkView , opt ) ; // if anchor lies outside of bbox, the bbox expands to include it sourceBBox = sourceBBox . union ( getPointBox ( sourceAnchor ) ) ; targetBBox = targetBBox . union ( getPointBox ( targetAnchor ) ) ; vertices = util . toArray ( vertices ) . map ( g . Point ) ; vertices . unshift ( sourceAnchor ) ; vertices . push ( targetAnchor ) ; var bearing ; // bearing of previous route segment var orthogonalVertices = [ ] ; // the array of found orthogonal vertices to be returned for ( var i = 0 , max = vertices . length - 1 ; i < max ; i ++ ) { var route = null ; var from = vertices [ i ] ; var to = vertices [ i + 1 ] ; var isOrthogonal = ! ! getBearing ( from , to ) ; if ( i === 0 ) { // source if ( i + 1 === max ) { // route source -> target // Expand one of the elements by 1px to detect situations when the two // elements are positioned next to each other with no gap in between. if ( sourceBBox . intersect ( targetBBox . clone ( ) . inflate ( 1 ) ) ) { route = insideElement ( from , to , sourceBBox , targetBBox ) ; } else if ( ! isOrthogonal ) { route = elementElement ( from , to , sourceBBox , targetBBox ) ; } } else { // route source -> vertex if ( sourceBBox . containsPoint ( to ) ) { route = insideElement ( from , to , sourceBBox , getPointBox ( to ) . moveAndExpand ( getPaddingBox ( opt ) ) ) ; } else if ( ! isOrthogonal ) { route = elementVertex ( from , to , sourceBBox ) ; } } } else if ( i + 1 === max ) { // route vertex -> target // prevent overlaps with previous line segment var isOrthogonalLoop = isOrthogonal && getBearing ( to , from ) === bearing ; if ( targetBBox . containsPoint ( from ) || isOrthogonalLoop ) { route = insideElement ( from , to , getPointBox ( from ) . moveAndExpand ( getPaddingBox ( opt ) ) , targetBBox , bearing ) ; } else if ( ! isOrthogonal ) { route = vertexElement ( from , to , targetBBox , bearing ) ; } } else if ( ! isOrthogonal ) { // route vertex -> vertex route = vertexVertex ( from , to , bearing ) ; } // applicable to all routes: // set bearing for next iteration if ( route ) { Array . prototype . push . apply ( orthogonalVertices , route . points ) ; bearing = route . direction ; } else { // orthogonal route and not looped bearing = getBearing ( from , to ) ; } // push `to` point to identified orthogonal vertices array if ( i + 1 < max ) { orthogonalVertices . push ( to ) ; } } return orthogonalVertices ; }
Return points through which a connection needs to be drawn in order to obtain an orthogonal link routing from source to target going through `vertices`.
Return points through which a connection needs to be drawn in order to obtain an orthogonal link routing from source to target going through vertices .