I'm trying to combine interactive and bridged routers for my project. I created my own Router class, which inherits InteractiveManhattanConnectionRouter, where I overwrite route method, using code from Bridged router.
So far no luck, this is my attempt:
class CustomRouter extends draw2d.layout.connection.InteractiveManhattanConnectionRouter {
init = function () {
this._super();
}
route = (conn, routingHints) => {
super.route(conn, routingHints);
var intersectionsASC = conn.getCanvas().getIntersection(conn).sort("x");
var intersectionsDESC = intersectionsASC.clone().reverse();
var intersectionForCalc = intersectionsASC;
var i = 0;
var ps = conn.getVertices();
var p = ps.get(0);
var path = ["M", (p.x | 0) + 0.5, " ", (p.y | 0) + 0.5];
var oldP = p;
for (i = 1; i < ps.getSize(); i++) {
p = ps.get(i);
var bridgeWidth = 5;
var bridgeCode = this.BRIDGE_HORIZONTAL_LR;
if (oldP.x > p.x) {
intersectionForCalc = intersectionsDESC;
bridgeCode = this.BRIDGE_HORIZONTAL_RL;
bridgeWidth = -bridgeWidth;
}
intersectionForCalc.each(function (ii, interP) {
if (interP.justTouching) {
return;
}
if (draw2d.shape.basic.Line.hit(1, oldP.x, oldP.y, p.x, p.y, interP.x, interP.y) === true) {
if (Math.floor(p.y) === Math.floor(interP.y)) {
console.log("pushon");
path.push(" L", ((interP.x - bridgeWidth) | 0) + 0.5, " ", (interP.y | 0) + 0.5);
path.push(bridgeCode);
}
}
});
path.push(" L", (p.x | 0) + 0.5, " ", (p.y | 0) + 0.5);
oldP = p;
}
conn.svgPathString = path.join("");
}
};
This doesn't show bridges, just behave as a regular Interactive router.