1 |
|
2 |
|
3 |
|
4 | var __extends = (this && this.__extends) || (function () {
|
5 | var extendStatics = function (d, b) {
|
6 | extendStatics = Object.setPrototypeOf ||
|
7 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
8 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
9 | return extendStatics(d, b);
|
10 | };
|
11 | return function (d, b) {
|
12 | extendStatics(d, b);
|
13 | function __() { this.constructor = d; }
|
14 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15 | };
|
16 | })();
|
17 | (function (factory) {
|
18 | if (typeof module === "object" && typeof module.exports === "object") {
|
19 | var v = factory(require, exports);
|
20 | if (v !== undefined) module.exports = v;
|
21 | }
|
22 | else if (typeof define === "function" && define.amd) {
|
23 | define(["require", "exports", "../release/go.js"], factory);
|
24 | }
|
25 | })(function (require, exports) {
|
26 | "use strict";
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | exports.ParallelRouteLink = void 0;
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | var go = require("../release/go.js");
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | var ParallelRouteLink = (function (_super) {
|
45 | __extends(ParallelRouteLink, _super);
|
46 | function ParallelRouteLink() {
|
47 | return _super !== null && _super.apply(this, arguments) || this;
|
48 | }
|
49 | |
50 |
|
51 |
|
52 |
|
53 | ParallelRouteLink.prototype.computePoints = function () {
|
54 | var result = _super.prototype.computePoints.call(this);
|
55 | if (!this.isOrthogonal && this.curve !== go.Link.Bezier && this.hasCurviness()) {
|
56 | var curv = this.computeCurviness();
|
57 | if (curv !== 0) {
|
58 | var num = this.pointsCount;
|
59 | var pidx = 0;
|
60 | var qidx = num - 1;
|
61 | if (num >= 4) {
|
62 | pidx++;
|
63 | qidx--;
|
64 | }
|
65 | var frompt = this.getPoint(pidx);
|
66 | var topt = this.getPoint(qidx);
|
67 | var dx = topt.x - frompt.x;
|
68 | var dy = topt.y - frompt.y;
|
69 | var mx = frompt.x + dx * 1 / 8;
|
70 | var my = frompt.y + dy * 1 / 8;
|
71 | var px = mx;
|
72 | var py = my;
|
73 | if (-0.01 < dy && dy < 0.01) {
|
74 | if (dx > 0)
|
75 | py -= curv;
|
76 | else
|
77 | py += curv;
|
78 | }
|
79 | else {
|
80 | var slope = -dx / dy;
|
81 | var e = Math.sqrt(curv * curv / (slope * slope + 1));
|
82 | if (curv < 0)
|
83 | e = -e;
|
84 | px = (dy < 0 ? -1 : 1) * e + mx;
|
85 | py = slope * (px - mx) + my;
|
86 | }
|
87 | mx = frompt.x + dx * 7 / 8;
|
88 | my = frompt.y + dy * 7 / 8;
|
89 | var qx = mx;
|
90 | var qy = my;
|
91 | if (-0.01 < dy && dy < 0.01) {
|
92 | if (dx > 0)
|
93 | qy -= curv;
|
94 | else
|
95 | qy += curv;
|
96 | }
|
97 | else {
|
98 | var slope = -dx / dy;
|
99 | var e = Math.sqrt(curv * curv / (slope * slope + 1));
|
100 | if (curv < 0)
|
101 | e = -e;
|
102 | qx = (dy < 0 ? -1 : 1) * e + mx;
|
103 | qy = slope * (qx - mx) + my;
|
104 | }
|
105 | this.insertPointAt(pidx + 1, px, py);
|
106 | this.insertPointAt(qidx + 1, qx, qy);
|
107 | }
|
108 | }
|
109 | return result;
|
110 | };
|
111 | return ParallelRouteLink;
|
112 | }(go.Link));
|
113 | exports.ParallelRouteLink = ParallelRouteLink;
|
114 | });
|