BarLink.js 1.85 KB
Newer Older
李纪文's avatar
李纪文 committed
1 2 3 4 5 6
/*
 * @Author: ljiwen
 * @Date: 2023-09-21 19:07:23
 * @Description: 
 * @FilePath: \wisdom-components\packages\extend-components\EC_ConfigurationView\src\js\BarLink.js
 */
7
/* eslint-disable */
李纪文's avatar
李纪文 committed
8
import * as go from '@wisdom-components/gojs';
涂茜's avatar
涂茜 committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

export default class BarLink extends go.Link {
  constructor() {
    super(...arguments);
    go.Link.call(this);
  }
  getLinkPoint(node, port, spot, from, ortho, othernode, otherport) {
    if (node.category === 'HBar') {
      window.οncοntextmenu = function (event) {
        var e = event || window.event;
        document.getElementById('Menu').style.left = e.clientX + 'px';
        document.getElementById('Menu').style.top = e.clientY + 'px';
        document.getElementById('Menu').style.display = 'block';
        return false;
      };
      var op = go.Link.prototype.getLinkPoint.call(
        this,
        othernode,
        otherport,
        this.computeSpot(!from),
        !from,
        ortho,
        node,
        port,
      );
      var r = port.getDocumentBounds();
      // 横向合管
      var r = port.getDocumentBounds();
      var angle = node.angle;
      var spare = (angle / 90) % 2;
      if (!spare) {
        var y = op.y > r.centerY ? r.bottom : r.top;
        if (op.x < r.left) return new go.Point(r.left, y);
        if (op.x > r.right) return new go.Point(r.right, y);
        return new go.Point(op.x, y);
      }
      // 纵向合管
      var x = op.x > r.centerX ? r.right : r.left;
      if (op.y < r.top) return new go.Point(x, r.top);
      if (op.y > r.bottom) return new go.Point(x, r.bottom);
      // return new go.Point(x, op.y - r.width / 2 + 3);
      return new go.Point(x, op.y);
    } else {
      return go.Link.prototype.getLinkPoint.call(
        this,
        node,
        port,
        spot,
        from,
        ortho,
        othernode,
        otherport,
      );
    }
  }
}