@html-graph/html-graph 8.22.0 → 8.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-graph.d.ts +64 -1
- package/dist/html-graph.js +398 -106
- package/dist/html-graph.min.js +698 -489
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +398 -105
- package/package.json +1 -1
package/dist/html-graph.umd.cjs
CHANGED
|
@@ -1392,13 +1392,13 @@
|
|
|
1392
1392
|
return parts.join(" ");
|
|
1393
1393
|
};
|
|
1394
1394
|
//#endregion
|
|
1395
|
-
//#region src/edges/paths/
|
|
1396
|
-
var
|
|
1395
|
+
//#region src/edges/paths/shared/create-horizontal-line/create-horizontal-line.ts
|
|
1396
|
+
var createHorizontalLine = (from, to) => {
|
|
1397
1397
|
const fromLine = from.linePoint;
|
|
1398
1398
|
const toLine = to.linePoint;
|
|
1399
1399
|
const horizontalLineDir = toLine.x - fromLine.x >= 0;
|
|
1400
|
-
const fromPortDir = from.
|
|
1401
|
-
if (fromPortDir === to.
|
|
1400
|
+
const fromPortDir = from.dir.x >= 0;
|
|
1401
|
+
if (fromPortDir === to.dir.x >= 0) {
|
|
1402
1402
|
const isSameDirLine = fromPortDir === horizontalLineDir;
|
|
1403
1403
|
const midpoint = {
|
|
1404
1404
|
x: (fromLine.x + toLine.x) / 2,
|
|
@@ -1475,6 +1475,198 @@
|
|
|
1475
1475
|
};
|
|
1476
1476
|
};
|
|
1477
1477
|
//#endregion
|
|
1478
|
+
//#region src/edges/paths/shared/shared/transpose-point/transpose-point.ts
|
|
1479
|
+
var transposePoint = (point) => {
|
|
1480
|
+
return {
|
|
1481
|
+
x: point.y,
|
|
1482
|
+
y: point.x
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1485
|
+
//#endregion
|
|
1486
|
+
//#region src/edges/paths/shared/create-vertical-line/create-vertical-line.ts
|
|
1487
|
+
var createVerticalLine = (from, to) => {
|
|
1488
|
+
const transposedLine = createHorizontalLine({
|
|
1489
|
+
arrowPoint: transposePoint(from.arrowPoint),
|
|
1490
|
+
linePoint: transposePoint(from.linePoint),
|
|
1491
|
+
dir: transposePoint(from.dir)
|
|
1492
|
+
}, {
|
|
1493
|
+
arrowPoint: transposePoint(to.arrowPoint),
|
|
1494
|
+
linePoint: transposePoint(to.linePoint),
|
|
1495
|
+
dir: transposePoint(to.dir)
|
|
1496
|
+
});
|
|
1497
|
+
return {
|
|
1498
|
+
points: transposedLine.points.map((p) => transposePoint(p)),
|
|
1499
|
+
midpoint: transposePoint(transposedLine.midpoint)
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
//#endregion
|
|
1503
|
+
//#region src/edges/paths/shared/create-horizontal-source-orthogonal-line/calculate-midpoint/calculate-midpoint.ts
|
|
1504
|
+
var calculateMidpoint = (points) => {
|
|
1505
|
+
const parts = [];
|
|
1506
|
+
for (let i = 1; i < points.length; i++) {
|
|
1507
|
+
const start = points[i - 1];
|
|
1508
|
+
const end = points[i];
|
|
1509
|
+
const dx = end.x - start.x;
|
|
1510
|
+
const dy = end.y - start.y;
|
|
1511
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
1512
|
+
parts.push({
|
|
1513
|
+
start,
|
|
1514
|
+
end,
|
|
1515
|
+
distance
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
const halfLength = parts.reduce((acc, cur) => acc + cur.distance, 0) / 2;
|
|
1519
|
+
let accLength = 0;
|
|
1520
|
+
for (const part of parts) {
|
|
1521
|
+
const nextAccLength = accLength + part.distance;
|
|
1522
|
+
if (nextAccLength >= halfLength) {
|
|
1523
|
+
const residue = halfLength - accLength;
|
|
1524
|
+
const { start, end, distance } = part;
|
|
1525
|
+
if (distance === 0) continue;
|
|
1526
|
+
const ratio = residue / distance;
|
|
1527
|
+
const dx = end.x - start.x;
|
|
1528
|
+
const dy = end.y - start.y;
|
|
1529
|
+
return {
|
|
1530
|
+
x: start.x + dx * ratio,
|
|
1531
|
+
y: start.y + dy * ratio
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
accLength = nextAccLength;
|
|
1535
|
+
}
|
|
1536
|
+
if (accLength === 0 && points.length > 0) return points[0];
|
|
1537
|
+
throw new Error("Failed to calculate midpoint");
|
|
1538
|
+
};
|
|
1539
|
+
//#endregion
|
|
1540
|
+
//#region src/edges/paths/shared/create-horizontal-source-orthogonal-line/create-horizontal-source-orthogonal-line.ts
|
|
1541
|
+
var createHorizontalSourceOrthogonalLine = (from, to) => {
|
|
1542
|
+
const fromLine = from.linePoint;
|
|
1543
|
+
const fromArrow = from.arrowPoint;
|
|
1544
|
+
const toLine = to.linePoint;
|
|
1545
|
+
const toArrow = to.arrowPoint;
|
|
1546
|
+
const targetPortDir = to.dir.y >= 0;
|
|
1547
|
+
const sourcePortDir = from.dir.x >= 0;
|
|
1548
|
+
const verticalLineDir = toLine.y - fromLine.y >= 0;
|
|
1549
|
+
const isSameSourceHorizontal = sourcePortDir === toLine.x - fromLine.x >= 0;
|
|
1550
|
+
const isSameTargetVertical = targetPortDir === verticalLineDir;
|
|
1551
|
+
if (isSameSourceHorizontal) {
|
|
1552
|
+
if (isSameTargetVertical) {
|
|
1553
|
+
const joint = {
|
|
1554
|
+
x: toArrow.x,
|
|
1555
|
+
y: fromArrow.y
|
|
1556
|
+
};
|
|
1557
|
+
return {
|
|
1558
|
+
points: [
|
|
1559
|
+
fromArrow,
|
|
1560
|
+
joint,
|
|
1561
|
+
toArrow
|
|
1562
|
+
],
|
|
1563
|
+
midpoint: calculateMidpoint([
|
|
1564
|
+
fromLine,
|
|
1565
|
+
joint,
|
|
1566
|
+
toLine
|
|
1567
|
+
])
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
const middleX = (fromLine.x + toLine.x) / 2;
|
|
1571
|
+
const jointStart = {
|
|
1572
|
+
x: middleX,
|
|
1573
|
+
y: fromLine.y
|
|
1574
|
+
};
|
|
1575
|
+
const jointEnd = {
|
|
1576
|
+
x: middleX,
|
|
1577
|
+
y: toLine.y
|
|
1578
|
+
};
|
|
1579
|
+
return {
|
|
1580
|
+
points: [
|
|
1581
|
+
fromArrow,
|
|
1582
|
+
jointStart,
|
|
1583
|
+
jointEnd,
|
|
1584
|
+
toLine,
|
|
1585
|
+
toArrow
|
|
1586
|
+
],
|
|
1587
|
+
midpoint: calculateMidpoint([
|
|
1588
|
+
fromLine,
|
|
1589
|
+
jointStart,
|
|
1590
|
+
jointEnd,
|
|
1591
|
+
toLine
|
|
1592
|
+
])
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
if (isSameTargetVertical) {
|
|
1596
|
+
const middleY = (fromLine.y + toLine.y) / 2;
|
|
1597
|
+
const jointStart = {
|
|
1598
|
+
x: fromLine.x,
|
|
1599
|
+
y: middleY
|
|
1600
|
+
};
|
|
1601
|
+
const jointEnd = {
|
|
1602
|
+
x: toLine.x,
|
|
1603
|
+
y: middleY
|
|
1604
|
+
};
|
|
1605
|
+
return {
|
|
1606
|
+
points: [
|
|
1607
|
+
fromArrow,
|
|
1608
|
+
fromLine,
|
|
1609
|
+
jointStart,
|
|
1610
|
+
jointEnd,
|
|
1611
|
+
toArrow
|
|
1612
|
+
],
|
|
1613
|
+
midpoint: calculateMidpoint([
|
|
1614
|
+
fromLine,
|
|
1615
|
+
jointStart,
|
|
1616
|
+
jointEnd,
|
|
1617
|
+
toLine
|
|
1618
|
+
])
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
const joint = {
|
|
1622
|
+
x: fromLine.x,
|
|
1623
|
+
y: toLine.y
|
|
1624
|
+
};
|
|
1625
|
+
return {
|
|
1626
|
+
points: [
|
|
1627
|
+
fromArrow,
|
|
1628
|
+
fromLine,
|
|
1629
|
+
joint,
|
|
1630
|
+
toLine,
|
|
1631
|
+
toArrow
|
|
1632
|
+
],
|
|
1633
|
+
midpoint: calculateMidpoint([
|
|
1634
|
+
fromLine,
|
|
1635
|
+
joint,
|
|
1636
|
+
toLine
|
|
1637
|
+
])
|
|
1638
|
+
};
|
|
1639
|
+
};
|
|
1640
|
+
//#endregion
|
|
1641
|
+
//#region src/edges/paths/shared/create-vertical-source-orthogonal-line/create-vertical-source-orthogonal-line.ts
|
|
1642
|
+
var createVerticalSourceOrthogonalLine = (from, to) => {
|
|
1643
|
+
const transposedLine = createHorizontalSourceOrthogonalLine({
|
|
1644
|
+
arrowPoint: transposePoint(from.arrowPoint),
|
|
1645
|
+
linePoint: transposePoint(from.linePoint),
|
|
1646
|
+
dir: transposePoint(from.dir)
|
|
1647
|
+
}, {
|
|
1648
|
+
arrowPoint: transposePoint(to.arrowPoint),
|
|
1649
|
+
linePoint: transposePoint(to.linePoint),
|
|
1650
|
+
dir: transposePoint(to.dir)
|
|
1651
|
+
});
|
|
1652
|
+
return {
|
|
1653
|
+
points: transposedLine.points.map((p) => transposePoint(p)),
|
|
1654
|
+
midpoint: transposePoint(transposedLine.midpoint)
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
//#endregion
|
|
1658
|
+
//#region src/edges/paths/shared/create-orthogonal-line/create-orthogonal-line.ts
|
|
1659
|
+
var createOrthogonalLine = (from, to) => {
|
|
1660
|
+
const isSourceHor = Math.abs(from.dir.y) < 1e-10;
|
|
1661
|
+
const isTargetHor = Math.abs(to.dir.y) < 1e-10;
|
|
1662
|
+
if (isSourceHor) {
|
|
1663
|
+
if (isTargetHor) return createHorizontalLine(from, to);
|
|
1664
|
+
return createHorizontalSourceOrthogonalLine(from, to);
|
|
1665
|
+
}
|
|
1666
|
+
if (!isTargetHor) return createVerticalLine(from, to);
|
|
1667
|
+
return createVerticalSourceOrthogonalLine(from, to);
|
|
1668
|
+
};
|
|
1669
|
+
//#endregion
|
|
1478
1670
|
//#region src/edges/paths/horizontal-edge-path/horizontal-edge-path.ts
|
|
1479
1671
|
var HorizontalEdgePath = class {
|
|
1480
1672
|
path;
|
|
@@ -1498,14 +1690,14 @@
|
|
|
1498
1690
|
x: to.x - gap,
|
|
1499
1691
|
y: to.y
|
|
1500
1692
|
}, toDir, to);
|
|
1501
|
-
const line =
|
|
1693
|
+
const line = createHorizontalLine({
|
|
1502
1694
|
arrowPoint: beginArrow,
|
|
1503
1695
|
linePoint: beginLine,
|
|
1504
|
-
|
|
1696
|
+
dir: fromDir
|
|
1505
1697
|
}, {
|
|
1506
1698
|
arrowPoint: endArrow,
|
|
1507
1699
|
linePoint: endLine,
|
|
1508
|
-
|
|
1700
|
+
dir: toDir
|
|
1509
1701
|
});
|
|
1510
1702
|
this.path = createRoundedPath(line.points, roundness);
|
|
1511
1703
|
this.midpoint = line.midpoint;
|
|
@@ -1599,89 +1791,6 @@
|
|
|
1599
1791
|
}
|
|
1600
1792
|
};
|
|
1601
1793
|
//#endregion
|
|
1602
|
-
//#region src/edges/paths/vertical-edge-path/create-line/create-line.ts
|
|
1603
|
-
var createLine = (from, to) => {
|
|
1604
|
-
const fromLine = from.linePoint;
|
|
1605
|
-
const toLine = to.linePoint;
|
|
1606
|
-
const verticalLineDir = toLine.y - fromLine.y >= 0;
|
|
1607
|
-
const fromPortDir = from.dirY >= 0;
|
|
1608
|
-
if (fromPortDir === to.dirY >= 0) {
|
|
1609
|
-
const isSameDirLine = fromPortDir === verticalLineDir;
|
|
1610
|
-
const midpoint = {
|
|
1611
|
-
x: (fromLine.x + toLine.x) / 2,
|
|
1612
|
-
y: (fromLine.y + toLine.y) / 2
|
|
1613
|
-
};
|
|
1614
|
-
if (isSameDirLine) return {
|
|
1615
|
-
points: [
|
|
1616
|
-
from.arrowPoint,
|
|
1617
|
-
{
|
|
1618
|
-
x: fromLine.x,
|
|
1619
|
-
y: midpoint.y
|
|
1620
|
-
},
|
|
1621
|
-
{
|
|
1622
|
-
x: toLine.x,
|
|
1623
|
-
y: midpoint.y
|
|
1624
|
-
},
|
|
1625
|
-
to.arrowPoint
|
|
1626
|
-
],
|
|
1627
|
-
midpoint
|
|
1628
|
-
};
|
|
1629
|
-
return {
|
|
1630
|
-
points: [
|
|
1631
|
-
from.arrowPoint,
|
|
1632
|
-
fromLine,
|
|
1633
|
-
{
|
|
1634
|
-
x: midpoint.x,
|
|
1635
|
-
y: fromLine.y
|
|
1636
|
-
},
|
|
1637
|
-
{
|
|
1638
|
-
x: midpoint.x,
|
|
1639
|
-
y: toLine.y
|
|
1640
|
-
},
|
|
1641
|
-
toLine,
|
|
1642
|
-
to.arrowPoint
|
|
1643
|
-
],
|
|
1644
|
-
midpoint
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
const isSameSourceDir = fromPortDir === verticalLineDir;
|
|
1648
|
-
const centerX = (fromLine.x + toLine.x) / 2;
|
|
1649
|
-
if (isSameSourceDir) {
|
|
1650
|
-
const joint = {
|
|
1651
|
-
x: fromLine.x,
|
|
1652
|
-
y: toLine.y
|
|
1653
|
-
};
|
|
1654
|
-
return {
|
|
1655
|
-
points: [
|
|
1656
|
-
from.arrowPoint,
|
|
1657
|
-
joint,
|
|
1658
|
-
toLine,
|
|
1659
|
-
to.arrowPoint
|
|
1660
|
-
],
|
|
1661
|
-
midpoint: {
|
|
1662
|
-
x: centerX,
|
|
1663
|
-
y: joint.y
|
|
1664
|
-
}
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
const joint = {
|
|
1668
|
-
x: toLine.x,
|
|
1669
|
-
y: fromLine.y
|
|
1670
|
-
};
|
|
1671
|
-
return {
|
|
1672
|
-
points: [
|
|
1673
|
-
from.arrowPoint,
|
|
1674
|
-
fromLine,
|
|
1675
|
-
joint,
|
|
1676
|
-
to.arrowPoint
|
|
1677
|
-
],
|
|
1678
|
-
midpoint: {
|
|
1679
|
-
x: centerX,
|
|
1680
|
-
y: joint.y
|
|
1681
|
-
}
|
|
1682
|
-
};
|
|
1683
|
-
};
|
|
1684
|
-
//#endregion
|
|
1685
1794
|
//#region src/edges/paths/vertical-edge-path/vertical-edge-path.ts
|
|
1686
1795
|
var VerticalEdgePath = class {
|
|
1687
1796
|
path;
|
|
@@ -1705,14 +1814,51 @@
|
|
|
1705
1814
|
x: to.x - gap,
|
|
1706
1815
|
y: to.y
|
|
1707
1816
|
}, toDir, to);
|
|
1708
|
-
const line =
|
|
1817
|
+
const line = createVerticalLine({
|
|
1818
|
+
arrowPoint: beginArrow,
|
|
1819
|
+
linePoint: beginLine,
|
|
1820
|
+
dir: fromDir
|
|
1821
|
+
}, {
|
|
1822
|
+
arrowPoint: endArrow,
|
|
1823
|
+
linePoint: endLine,
|
|
1824
|
+
dir: toDir
|
|
1825
|
+
});
|
|
1826
|
+
this.path = createRoundedPath(line.points, roundness);
|
|
1827
|
+
this.midpoint = line.midpoint;
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
//#endregion
|
|
1831
|
+
//#region src/edges/paths/orthogonal-edge-path/orthogonal-edge-path.ts
|
|
1832
|
+
var OrthogonalEdgePath = class {
|
|
1833
|
+
path;
|
|
1834
|
+
midpoint;
|
|
1835
|
+
constructor(params) {
|
|
1836
|
+
const { from, to, fromDir, toDir, arrowLength, arrowOffset, roundness, hasSourceArrow, hasTargetArrow } = params;
|
|
1837
|
+
const beginArrow = hasSourceArrow ? createRotatedPoint({
|
|
1838
|
+
x: from.x + arrowLength,
|
|
1839
|
+
y: from.y
|
|
1840
|
+
}, fromDir, from) : from;
|
|
1841
|
+
const endArrow = hasTargetArrow ? createRotatedPoint({
|
|
1842
|
+
x: to.x - arrowLength,
|
|
1843
|
+
y: to.y
|
|
1844
|
+
}, toDir, to) : to;
|
|
1845
|
+
const gap = arrowLength + arrowOffset;
|
|
1846
|
+
const beginLine = createRotatedPoint({
|
|
1847
|
+
x: from.x + gap,
|
|
1848
|
+
y: from.y
|
|
1849
|
+
}, fromDir, from);
|
|
1850
|
+
const endLine = createRotatedPoint({
|
|
1851
|
+
x: to.x - gap,
|
|
1852
|
+
y: to.y
|
|
1853
|
+
}, toDir, to);
|
|
1854
|
+
const line = createOrthogonalLine({
|
|
1709
1855
|
arrowPoint: beginArrow,
|
|
1710
1856
|
linePoint: beginLine,
|
|
1711
|
-
|
|
1857
|
+
dir: fromDir
|
|
1712
1858
|
}, {
|
|
1713
1859
|
arrowPoint: endArrow,
|
|
1714
1860
|
linePoint: endLine,
|
|
1715
|
-
|
|
1861
|
+
dir: toDir
|
|
1716
1862
|
});
|
|
1717
1863
|
this.path = createRoundedPath(line.points, roundness);
|
|
1718
1864
|
this.midpoint = line.midpoint;
|
|
@@ -1928,6 +2074,31 @@
|
|
|
1928
2074
|
}
|
|
1929
2075
|
};
|
|
1930
2076
|
//#endregion
|
|
2077
|
+
//#region src/edges/paths/detour-orthogonal-edge-path/detour-orthogonal-edge-shape.ts
|
|
2078
|
+
var DetourOrthogonalEdgePath = class {
|
|
2079
|
+
path;
|
|
2080
|
+
midpoint;
|
|
2081
|
+
constructor(params) {
|
|
2082
|
+
const isSourceHor = Math.abs(params.fromDir.y) < 1e-10;
|
|
2083
|
+
const isTargetHor = Math.abs(params.toDir.y) < 1e-10;
|
|
2084
|
+
if (isSourceHor && isTargetHor) {
|
|
2085
|
+
const path = new DetourHorizontalEdgePath(params);
|
|
2086
|
+
this.path = path.path;
|
|
2087
|
+
this.midpoint = path.midpoint;
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2090
|
+
if (!isSourceHor && !isTargetHor) {
|
|
2091
|
+
const path = new DetourVerticalEdgePath(params);
|
|
2092
|
+
this.path = path.path;
|
|
2093
|
+
this.midpoint = path.midpoint;
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
const path = new OrthogonalEdgePath(params);
|
|
2097
|
+
this.path = path.path;
|
|
2098
|
+
this.midpoint = path.midpoint;
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
//#endregion
|
|
1931
2102
|
//#region src/edges/edge-constants.ts
|
|
1932
2103
|
var edgeConstants = Object.freeze({
|
|
1933
2104
|
color: "#777777",
|
|
@@ -2233,6 +2404,10 @@
|
|
|
2233
2404
|
};
|
|
2234
2405
|
//#endregion
|
|
2235
2406
|
//#region src/edges/shapes/horizontal-edge-shape/horizontal-edge-shape.ts
|
|
2407
|
+
/**
|
|
2408
|
+
* @deprecated
|
|
2409
|
+
* use OrthogonalEdgeShape instead
|
|
2410
|
+
*/
|
|
2236
2411
|
var HorizontalEdgeShape = class {
|
|
2237
2412
|
svg;
|
|
2238
2413
|
group;
|
|
@@ -2415,6 +2590,10 @@
|
|
|
2415
2590
|
};
|
|
2416
2591
|
//#endregion
|
|
2417
2592
|
//#region src/edges/shapes/vertical-edge-shape/vertical-edge-shape.ts
|
|
2593
|
+
/**
|
|
2594
|
+
* @deprecated
|
|
2595
|
+
* use OrthogonalEdgeShape instead
|
|
2596
|
+
*/
|
|
2418
2597
|
var VerticalEdgeShape = class {
|
|
2419
2598
|
svg;
|
|
2420
2599
|
group;
|
|
@@ -2506,6 +2685,111 @@
|
|
|
2506
2685
|
}
|
|
2507
2686
|
};
|
|
2508
2687
|
//#endregion
|
|
2688
|
+
//#region src/edges/shapes/orthogonal-edge-shape/orthogonalize-direction/orthogonalize-direction.ts
|
|
2689
|
+
var orthogonalizeDirection = (direction) => {
|
|
2690
|
+
const adjDir = direction + Math.PI / 4;
|
|
2691
|
+
const adjCos = Math.cos(adjDir);
|
|
2692
|
+
const adjSin = Math.sin(adjDir);
|
|
2693
|
+
if (adjCos > 0) {
|
|
2694
|
+
if (adjSin > 0) return 0;
|
|
2695
|
+
return -Math.PI / 2;
|
|
2696
|
+
}
|
|
2697
|
+
if (adjSin > 0) return Math.PI / 2;
|
|
2698
|
+
return Math.PI;
|
|
2699
|
+
};
|
|
2700
|
+
//#endregion
|
|
2701
|
+
//#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
|
|
2702
|
+
var OrthogonalEdgeShape = class {
|
|
2703
|
+
svg;
|
|
2704
|
+
group;
|
|
2705
|
+
line;
|
|
2706
|
+
sourceArrow;
|
|
2707
|
+
targetArrow;
|
|
2708
|
+
onAfterRender;
|
|
2709
|
+
arrowLength;
|
|
2710
|
+
arrowOffset;
|
|
2711
|
+
roundness;
|
|
2712
|
+
cycleSquareSide;
|
|
2713
|
+
detourDistance;
|
|
2714
|
+
hasSourceArrow;
|
|
2715
|
+
hasTargetArrow;
|
|
2716
|
+
pathShape;
|
|
2717
|
+
createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
|
|
2718
|
+
origin: from,
|
|
2719
|
+
dir: fromDir,
|
|
2720
|
+
arrowLength: this.arrowLength,
|
|
2721
|
+
side: this.cycleSquareSide,
|
|
2722
|
+
arrowOffset: this.arrowOffset,
|
|
2723
|
+
roundness: this.roundness,
|
|
2724
|
+
hasArrow: this.hasSourceArrow || this.hasTargetArrow
|
|
2725
|
+
});
|
|
2726
|
+
createDetourPath = (from, to, fromDir, toDir) => new DetourOrthogonalEdgePath({
|
|
2727
|
+
from,
|
|
2728
|
+
to,
|
|
2729
|
+
fromDir,
|
|
2730
|
+
toDir,
|
|
2731
|
+
arrowLength: this.arrowLength,
|
|
2732
|
+
arrowOffset: this.arrowOffset,
|
|
2733
|
+
roundness: this.roundness,
|
|
2734
|
+
detourDistance: this.detourDistance,
|
|
2735
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2736
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2737
|
+
});
|
|
2738
|
+
createLinePath = (from, to, fromDir, toDir) => new OrthogonalEdgePath({
|
|
2739
|
+
from,
|
|
2740
|
+
to,
|
|
2741
|
+
fromDir,
|
|
2742
|
+
toDir,
|
|
2743
|
+
arrowLength: this.arrowLength,
|
|
2744
|
+
arrowOffset: this.arrowOffset,
|
|
2745
|
+
roundness: this.roundness,
|
|
2746
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2747
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2748
|
+
});
|
|
2749
|
+
constructor(params) {
|
|
2750
|
+
this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
|
|
2751
|
+
this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
|
|
2752
|
+
this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
|
|
2753
|
+
const roundness = params?.roundness ?? edgeConstants.roundness;
|
|
2754
|
+
this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
|
|
2755
|
+
this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
|
|
2756
|
+
this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
|
|
2757
|
+
this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
|
|
2758
|
+
this.pathShape = new PathEdgeShape({
|
|
2759
|
+
color: params?.color ?? edgeConstants.color,
|
|
2760
|
+
width: params?.width ?? edgeConstants.width,
|
|
2761
|
+
arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
|
|
2762
|
+
arrowLength: this.arrowLength,
|
|
2763
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2764
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2765
|
+
createCyclePath: this.createCyclePath,
|
|
2766
|
+
createDetourPath: this.createDetourPath,
|
|
2767
|
+
createLinePath: this.createLinePath,
|
|
2768
|
+
padding: 50
|
|
2769
|
+
});
|
|
2770
|
+
this.svg = this.pathShape.svg;
|
|
2771
|
+
this.group = this.pathShape.group;
|
|
2772
|
+
this.line = this.pathShape.line;
|
|
2773
|
+
this.sourceArrow = this.pathShape.sourceArrow;
|
|
2774
|
+
this.targetArrow = this.pathShape.targetArrow;
|
|
2775
|
+
this.onAfterRender = this.pathShape.onAfterRender;
|
|
2776
|
+
}
|
|
2777
|
+
render(params) {
|
|
2778
|
+
const { from, to, category } = params;
|
|
2779
|
+
this.pathShape.render({
|
|
2780
|
+
category,
|
|
2781
|
+
from: {
|
|
2782
|
+
...from,
|
|
2783
|
+
direction: orthogonalizeDirection(from.direction)
|
|
2784
|
+
},
|
|
2785
|
+
to: {
|
|
2786
|
+
...to,
|
|
2787
|
+
direction: orthogonalizeDirection(to.direction)
|
|
2788
|
+
}
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2792
|
+
//#endregion
|
|
2509
2793
|
//#region src/edges/shapes/direct-edge-shape/resolve-port-offset-fn/box-port-offset-fn/box-port-offset-fn.ts
|
|
2510
2794
|
var boxPortOffsetFn = (params) => {
|
|
2511
2795
|
const { direction, radius } = params;
|
|
@@ -4998,6 +5282,18 @@
|
|
|
4998
5282
|
roundness: config.roundness,
|
|
4999
5283
|
detourDistance: config.detourDistance
|
|
5000
5284
|
});
|
|
5285
|
+
case "orthogonal": return () => new OrthogonalEdgeShape({
|
|
5286
|
+
color: config.color,
|
|
5287
|
+
width: config.width,
|
|
5288
|
+
arrowLength: config.arrowLength,
|
|
5289
|
+
arrowOffset: config.arrowOffset,
|
|
5290
|
+
arrowRenderer: config.arrowRenderer,
|
|
5291
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5292
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5293
|
+
cycleSquareSide: config.cycleSquareSide,
|
|
5294
|
+
roundness: config.roundness,
|
|
5295
|
+
detourDistance: config.detourDistance
|
|
5296
|
+
});
|
|
5001
5297
|
case "direct": return () => new DirectEdgeShape({
|
|
5002
5298
|
color: config.color,
|
|
5003
5299
|
width: config.width,
|
|
@@ -5082,28 +5378,24 @@
|
|
|
5082
5378
|
const prev = params.prevTransform;
|
|
5083
5379
|
const next = params.nextTransform;
|
|
5084
5380
|
let nextScale = next.scale;
|
|
5085
|
-
let
|
|
5086
|
-
let
|
|
5381
|
+
let nextX = next.x;
|
|
5382
|
+
let nextY = next.y;
|
|
5087
5383
|
if (next.scale > maxViewScale && next.scale > prev.scale) {
|
|
5088
5384
|
nextScale = Math.max(prev.scale, maxViewScale);
|
|
5089
|
-
nextDx = prev.x;
|
|
5090
|
-
nextDy = prev.y;
|
|
5091
5385
|
const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
|
|
5092
|
-
|
|
5093
|
-
|
|
5386
|
+
nextX = prev.x + (next.x - prev.x) * ratio;
|
|
5387
|
+
nextY = prev.y + (next.y - prev.y) * ratio;
|
|
5094
5388
|
}
|
|
5095
5389
|
if (next.scale < minViewScale && next.scale < prev.scale) {
|
|
5096
5390
|
nextScale = Math.min(prev.scale, minViewScale);
|
|
5097
|
-
nextDx = prev.x;
|
|
5098
|
-
nextDy = prev.y;
|
|
5099
5391
|
const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
|
|
5100
|
-
|
|
5101
|
-
|
|
5392
|
+
nextX = prev.x + (next.x - prev.x) * ratio;
|
|
5393
|
+
nextY = prev.y + (next.y - prev.y) * ratio;
|
|
5102
5394
|
}
|
|
5103
5395
|
return {
|
|
5104
5396
|
scale: nextScale,
|
|
5105
|
-
x:
|
|
5106
|
-
y:
|
|
5397
|
+
x: nextX,
|
|
5398
|
+
y: nextY
|
|
5107
5399
|
};
|
|
5108
5400
|
};
|
|
5109
5401
|
};
|
|
@@ -6827,6 +7119,7 @@
|
|
|
6827
7119
|
exports.InteractiveEdgeError = InteractiveEdgeError;
|
|
6828
7120
|
exports.InteractiveEdgeShape = InteractiveEdgeShape;
|
|
6829
7121
|
exports.MidpointEdgeShape = MidpointEdgeShape;
|
|
7122
|
+
exports.OrthogonalEdgeShape = OrthogonalEdgeShape;
|
|
6830
7123
|
exports.StraightEdgeShape = StraightEdgeShape;
|
|
6831
7124
|
exports.VerticalEdgeShape = VerticalEdgeShape;
|
|
6832
7125
|
exports.boxPortOffsetFn = boxPortOffsetFn;
|