| 1491 | } |
| 1492 | |
| 1493 | private redrawDragEdges(node: PixiNode): void { |
| 1494 | if (!this.edgeBgGfx) return; |
| 1495 | this.edgeBgGfx.clear(); |
| 1496 | |
| 1497 | if (!this.edgesEnabled) return; |
| 1498 | |
| 1499 | const myEdges = this.edgeIndex.get(node.id) ?? []; |
| 1500 | const neighborIds = new Set<string>(); |
| 1501 | |
| 1502 | // Group drag edges by color |
| 1503 | const dragGroups = new Map< |
| 1504 | string, |
| 1505 | { sx: number; sy: number; tx: number; ty: number }[] |
| 1506 | >(); |
| 1507 | for (const idx of myEdges) { |
| 1508 | const e = this.edges[idx]; |
| 1509 | if (this.hiddenLinkTypes.has(e.label)) continue; |
| 1510 | const s = this.nodes.get(e.sourceId); |
| 1511 | const t = this.nodes.get(e.targetId); |
| 1512 | if (!s || !t) continue; |
| 1513 | let group = dragGroups.get(e.color); |
| 1514 | if (!group) { |
| 1515 | group = []; |
| 1516 | dragGroups.set(e.color, group); |
| 1517 | } |
| 1518 | group.push({ sx: s.x, sy: s.y, tx: t.x, ty: t.y }); |
| 1519 | const neighborId = e.sourceId === node.id ? e.targetId : e.sourceId; |
| 1520 | neighborIds.add(neighborId); |
| 1521 | } |
| 1522 | for (const [color, lines] of dragGroups) { |
| 1523 | for (const l of lines) { |
| 1524 | this.drawEdge(this.edgeBgGfx, l.sx, l.sy, l.tx, l.ty); |
| 1525 | } |
| 1526 | this.edgeBgGfx.stroke({ |
| 1527 | width: 1 * this.zoomInvScale(), |
| 1528 | color: hexToNum(color), |
| 1529 | alpha: 0.6, |
| 1530 | }); |
| 1531 | } |
| 1532 | |
| 1533 | // Neighbor-to-neighbor edges for context |
| 1534 | for (const nid of neighborIds) { |
| 1535 | const nEdges = this.edgeIndex.get(nid) ?? []; |
| 1536 | for (const idx of nEdges) { |
| 1537 | const e = this.edges[idx]; |
| 1538 | if (neighborIds.has(e.sourceId) && neighborIds.has(e.targetId)) { |
| 1539 | const s = this.nodes.get(e.sourceId); |
| 1540 | const t = this.nodes.get(e.targetId); |
| 1541 | if (s && t) { |
| 1542 | this.drawEdge(this.edgeBgGfx, s.x, s.y, t.x, t.y); |
| 1543 | } |
| 1544 | } |
| 1545 | } |
| 1546 | } |
| 1547 | this.edgeBgGfx.stroke({ |
| 1548 | width: 0.4 * this.zoomInvScale(), |
| 1549 | color: EDGE_FALLBACK_COLOR, |
| 1550 | alpha: 0.2, |