import { Link } from '../types/Link'; import { Node } from '../types/Node'; import { Point } from '../types/Point'; import { Router } from './Router'; class StraightRouter extends Router { constructor () { super(); } calculateLink (link: Link, source: Node, target: Node): void { const sourceShape = this._nodeShapeMap.get(source); const targetShape = this._nodeShapeMap.get(target); const srcPoint: Point = { x: source.x, y: source.y }; const trgPoint: Point = { x: target.x, y: target.y }; link.points = [srcPoint, trgPoint]; if (source === target && sourceShape) { // If source and target are the same, get a point outside // of the shape to make a self loop const loopPoint = sourceShape.selfLoopPoint(source); // Add it for now link.points.splice(1, 0, loopPoint); } this._calcalateShapeOffsets(link, sourceShape, targetShape); } } export { StraightRouter }