@yuneta/gobj-ui 7.23.153 → 7.23.155
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/README.md +22 -2
- package/dist/gobj-ui.cjs.js +424 -43
- package/dist/gobj-ui.es.js +425 -44
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +81 -12
- package/src/treedb_elbow.js +292 -22
- package/src/treedb_elbow.test.js +130 -1
- package/src/treedb_layout.js +146 -14
- package/src/treedb_layout.test.js +84 -12
package/dist/gobj-ui.es.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createJSONEditor } from "vanilla-jsoneditor";
|
|
|
6
6
|
import { TabulatorFull } from "tabulator-tables";
|
|
7
7
|
import * as maplibregl from "maplibre-gl";
|
|
8
8
|
import uPlot from "uplot";
|
|
9
|
-
import { BaseLayout, BrushSelect, CanvasEvent, Circle, CommonEvent, DragCanvas, EdgeEvent, ExtensionCategory, Graph, HTML, HistoryEvent, NodeEvent, Polyline, Toolbar, ZoomCanvas, register } from "@antv/g6";
|
|
9
|
+
import { BaseLayout, BrushSelect, CanvasEvent, Circle, CommonEvent, Cubic, CubicHorizontal, DragCanvas, EdgeEvent, ExtensionCategory, Graph, HTML, HistoryEvent, NodeEvent, Polyline, Toolbar, ZoomCanvas, register } from "@antv/g6";
|
|
10
10
|
//#region \0rolldown/runtime.js
|
|
11
11
|
var __create = Object.create;
|
|
12
12
|
var __defProp = Object.defineProperty;
|
|
@@ -29326,6 +29326,14 @@ function tidy_tree_lr(nodes, edges, o) {
|
|
|
29326
29326
|
* the packing across the depths differs, so switching between the
|
|
29327
29327
|
* two moves cards sideways and never reorders them.
|
|
29328
29328
|
*
|
|
29329
|
+
* And a run of three or more LEAF children -- a hall's devices, a
|
|
29330
|
+
* region's places when none is open -- is STACKED: two columns
|
|
29331
|
+
* under the parent with a corridor between them, row after row.
|
|
29332
|
+
* That is what makes it compact when a whole level is open, where
|
|
29333
|
+
* the contour alone gains nothing: every parent needed the whole
|
|
29334
|
+
* row of its children beside it. The tree grows taller instead of
|
|
29335
|
+
* wider. Its elbow edges run down the corridor (elbow_combs).
|
|
29336
|
+
*
|
|
29329
29337
|
* The contour arithmetic is Moen's ("Drawing dynamic trees", IEEE
|
|
29330
29338
|
* Software, 1990) in the form mxGraph gave it in mxCompactTreeLayout
|
|
29331
29339
|
* -- Copyright (c) 2006-2015 JGraph Ltd, Apache License 2.0 -- read in
|
|
@@ -29406,10 +29414,81 @@ function contour_merge(p1, p2) {
|
|
|
29406
29414
|
p1.lower_head = p2.lower_head;
|
|
29407
29415
|
return total;
|
|
29408
29416
|
}
|
|
29417
|
+
function stack_trunk_width(k) {
|
|
29418
|
+
let lanes = Math.max(0, k - 2);
|
|
29419
|
+
return Math.max(36, 20 + Math.max(0, lanes - 1) * 6);
|
|
29420
|
+
}
|
|
29421
|
+
function stack_geometry(t, st, col_x, col_w) {
|
|
29422
|
+
let d = st.depth;
|
|
29423
|
+
let k = st.ids.length;
|
|
29424
|
+
let rows = Math.ceil(k / 2);
|
|
29425
|
+
let side = [0, 0];
|
|
29426
|
+
let row_len = [];
|
|
29427
|
+
for (let i = 0; i < k; i++) {
|
|
29428
|
+
let n = t.by_id.get(st.ids[i]);
|
|
29429
|
+
let r = Math.floor(i / 2);
|
|
29430
|
+
side[i % 2] = Math.max(side[i % 2], n.h);
|
|
29431
|
+
row_len[r] = Math.max(row_len[r] || 0, n.w);
|
|
29432
|
+
}
|
|
29433
|
+
row_len[0] = col_w[d];
|
|
29434
|
+
let trunk = stack_trunk_width(k);
|
|
29435
|
+
let starts = [col_x[d]];
|
|
29436
|
+
for (let r = 1; r < rows; r++) starts[r] = starts[r - 1] + row_len[r - 1] + 40;
|
|
29437
|
+
return {
|
|
29438
|
+
side,
|
|
29439
|
+
trunk,
|
|
29440
|
+
starts,
|
|
29441
|
+
row_len,
|
|
29442
|
+
len: starts[rows - 1] + row_len[rows - 1] - col_x[d],
|
|
29443
|
+
ext: side[0] + trunk + side[1]
|
|
29444
|
+
};
|
|
29445
|
+
}
|
|
29446
|
+
function place_stack(t, st, g, top, pos) {
|
|
29447
|
+
for (let i = 0; i < st.ids.length; i++) {
|
|
29448
|
+
let n = t.by_id.get(st.ids[i]);
|
|
29449
|
+
let r = Math.floor(i / 2);
|
|
29450
|
+
let across = i % 2 === 0 ? top + g.side[0] - n.h / 2 : top + g.side[0] + g.trunk + n.h / 2;
|
|
29451
|
+
pos.set(st.ids[i], {
|
|
29452
|
+
x: g.starts[r] + g.row_len[r] / 2,
|
|
29453
|
+
y: across
|
|
29454
|
+
});
|
|
29455
|
+
}
|
|
29456
|
+
}
|
|
29409
29457
|
function compact_tree_lr(nodes, edges, o) {
|
|
29410
29458
|
let t = spanning_tree(nodes, edges);
|
|
29411
|
-
let order = walk_order(t);
|
|
29412
29459
|
let pos = /* @__PURE__ */ new Map();
|
|
29460
|
+
let kids_of = /* @__PURE__ */ new Map();
|
|
29461
|
+
let stacks = /* @__PURE__ */ new Map();
|
|
29462
|
+
for (let [id, kids] of t.children) {
|
|
29463
|
+
let out = [];
|
|
29464
|
+
let run = [];
|
|
29465
|
+
let flush = () => {
|
|
29466
|
+
if (run.length >= 3) {
|
|
29467
|
+
let key = { stack: stacks.size };
|
|
29468
|
+
stacks.set(key, {
|
|
29469
|
+
ids: run,
|
|
29470
|
+
depth: t.depth.get(run[0])
|
|
29471
|
+
});
|
|
29472
|
+
out.push(key);
|
|
29473
|
+
} else out.push(...run);
|
|
29474
|
+
run = [];
|
|
29475
|
+
};
|
|
29476
|
+
for (let kid of kids) if ((t.children.get(kid) || []).length === 0) run.push(kid);
|
|
29477
|
+
else {
|
|
29478
|
+
flush();
|
|
29479
|
+
out.push(kid);
|
|
29480
|
+
}
|
|
29481
|
+
flush();
|
|
29482
|
+
kids_of.set(id, out);
|
|
29483
|
+
}
|
|
29484
|
+
let order = [];
|
|
29485
|
+
let todo = t.roots.slice().reverse();
|
|
29486
|
+
while (todo.length) {
|
|
29487
|
+
let id = todo.pop();
|
|
29488
|
+
order.push(id);
|
|
29489
|
+
let kids = kids_of.get(id) || [];
|
|
29490
|
+
for (let i = kids.length - 1; i >= 0; i--) todo.push(kids[i]);
|
|
29491
|
+
}
|
|
29413
29492
|
let col_w = [];
|
|
29414
29493
|
for (let [id, d] of t.depth) col_w[d] = Math.max(col_w[d] || 0, t.by_id.get(id).w);
|
|
29415
29494
|
let col_x = [];
|
|
@@ -29422,18 +29501,32 @@ function compact_tree_lr(nodes, edges, o) {
|
|
|
29422
29501
|
let dist = o.nodesep;
|
|
29423
29502
|
let level_distance = o.ranksep - pad;
|
|
29424
29503
|
let tn = /* @__PURE__ */ new Map();
|
|
29425
|
-
for (let id of order)
|
|
29426
|
-
|
|
29427
|
-
|
|
29428
|
-
|
|
29429
|
-
|
|
29430
|
-
|
|
29431
|
-
|
|
29432
|
-
|
|
29504
|
+
for (let id of order) {
|
|
29505
|
+
let st = stacks.get(id);
|
|
29506
|
+
if (st) {
|
|
29507
|
+
let g = stack_geometry(t, st, col_x, col_w);
|
|
29508
|
+
tn.set(id, {
|
|
29509
|
+
len: g.len,
|
|
29510
|
+
ext: g.ext,
|
|
29511
|
+
geom: g,
|
|
29512
|
+
off_x: 0,
|
|
29513
|
+
off_y: 0,
|
|
29514
|
+
y: 0,
|
|
29515
|
+
contour: null
|
|
29516
|
+
});
|
|
29517
|
+
} else tn.set(id, {
|
|
29518
|
+
len: col_w[t.depth.get(id)],
|
|
29519
|
+
ext: t.by_id.get(id).h,
|
|
29520
|
+
off_x: 0,
|
|
29521
|
+
off_y: 0,
|
|
29522
|
+
y: 0,
|
|
29523
|
+
contour: null
|
|
29524
|
+
});
|
|
29525
|
+
}
|
|
29433
29526
|
for (let i = order.length - 1; i >= 0; i--) {
|
|
29434
29527
|
let id = order[i];
|
|
29435
29528
|
let n = tn.get(id);
|
|
29436
|
-
let kids =
|
|
29529
|
+
let kids = kids_of.get(id) || [];
|
|
29437
29530
|
if (!kids.length) {
|
|
29438
29531
|
let upper = contour_line(n.len + dist, 0);
|
|
29439
29532
|
let lower_tail = contour_line(0, -n.ext - dist);
|
|
@@ -29469,7 +29562,7 @@ function compact_tree_lr(nodes, edges, o) {
|
|
|
29469
29562
|
for (let id of order) {
|
|
29470
29563
|
let n = tn.get(id);
|
|
29471
29564
|
if (!root_of.has(id)) root_of.set(id, id);
|
|
29472
|
-
let kids =
|
|
29565
|
+
let kids = kids_of.get(id) || [];
|
|
29473
29566
|
if (!kids.length) continue;
|
|
29474
29567
|
let running = n.y + tn.get(kids[0]).off_y;
|
|
29475
29568
|
tn.get(kids[0]).y = running;
|
|
@@ -29496,9 +29589,14 @@ function compact_tree_lr(nodes, edges, o) {
|
|
|
29496
29589
|
top += hi.get(r) - lo.get(r) + o.nodesep * 2;
|
|
29497
29590
|
}
|
|
29498
29591
|
for (let id of order) {
|
|
29499
|
-
let d = t.depth.get(id);
|
|
29500
29592
|
let n = tn.get(id);
|
|
29501
29593
|
let y = n.y + shift.get(root_of.get(id));
|
|
29594
|
+
let st = stacks.get(id);
|
|
29595
|
+
if (st) {
|
|
29596
|
+
place_stack(t, st, n.geom, y, pos);
|
|
29597
|
+
continue;
|
|
29598
|
+
}
|
|
29599
|
+
let d = t.depth.get(id);
|
|
29502
29600
|
pos.set(id, {
|
|
29503
29601
|
x: col_x[d] + col_w[d] / 2,
|
|
29504
29602
|
y: y + n.ext / 2
|
|
@@ -29663,6 +29761,136 @@ function swap_box(b) {
|
|
|
29663
29761
|
y2: b.x2
|
|
29664
29762
|
};
|
|
29665
29763
|
}
|
|
29764
|
+
function staggered_turn(lo, hi, st) {
|
|
29765
|
+
let mid = (lo + hi) / 2;
|
|
29766
|
+
let group = null;
|
|
29767
|
+
let k = 0;
|
|
29768
|
+
if (st.dep && st.dep.count > 1) {
|
|
29769
|
+
group = st.dep;
|
|
29770
|
+
k = st.dep.rank;
|
|
29771
|
+
} else if (st.arr && st.arr.count > 1) {
|
|
29772
|
+
group = st.arr;
|
|
29773
|
+
k = st.arr.count - 1 - st.arr.rank;
|
|
29774
|
+
}
|
|
29775
|
+
if (group) {
|
|
29776
|
+
let room = Math.max(0, hi - lo - 12);
|
|
29777
|
+
let step = Math.min(10, room / (group.count - 1));
|
|
29778
|
+
mid = mid - (group.count - 1) * step / 2 + k * step;
|
|
29779
|
+
}
|
|
29780
|
+
return mid;
|
|
29781
|
+
}
|
|
29782
|
+
/************************************************************
|
|
29783
|
+
* The combs of the stacks under one card.
|
|
29784
|
+
*
|
|
29785
|
+
* treedb_layout.js lays a run of leaf children out as two columns
|
|
29786
|
+
* with a corridor between them. A card in the first row is reached
|
|
29787
|
+
* from the channel like any other; one in a lower row cannot be --
|
|
29788
|
+
* the card above it stands in the way -- so its edge runs down
|
|
29789
|
+
* the corridor in a LANE of its own and turns into the gap above
|
|
29790
|
+
* its card, which it shares only with the other card of its row,
|
|
29791
|
+
* reached from the other side.
|
|
29792
|
+
*
|
|
29793
|
+
* targets [{id, box}]: the forward edges leaving one card,
|
|
29794
|
+
* each with the box of the card it reaches
|
|
29795
|
+
* vertical as in elbow_points; false swaps the boxes
|
|
29796
|
+
*
|
|
29797
|
+
* Returns Map id -> {lane, z, top}: the lane, the height of the
|
|
29798
|
+
* gap it turns into, and the top of the stack's first row (where
|
|
29799
|
+
* the channel over the stack ends). Only for a card that stands
|
|
29800
|
+
* under another of the group, within a stack gap and lined up
|
|
29801
|
+
* with it on the corridor side -- what a stack looks like.
|
|
29802
|
+
*
|
|
29803
|
+
* Lanes go outermost first, row by row: a line into a higher row
|
|
29804
|
+
* keeps outside the lines going deeper, and none crosses another.
|
|
29805
|
+
************************************************************/
|
|
29806
|
+
function elbow_combs(targets, vertical) {
|
|
29807
|
+
let list = vertical ? targets : targets.map((it) => ({
|
|
29808
|
+
id: it.id,
|
|
29809
|
+
box: swap_box(it.box)
|
|
29810
|
+
}));
|
|
29811
|
+
let cy = (b) => (b.y1 + b.y2) / 2;
|
|
29812
|
+
let near = (a, b) => Math.abs(a - b) < 1.5;
|
|
29813
|
+
let under = [];
|
|
29814
|
+
for (let it of list) {
|
|
29815
|
+
let b = it.box;
|
|
29816
|
+
let above = null;
|
|
29817
|
+
for (let o of list) {
|
|
29818
|
+
let a = o.box;
|
|
29819
|
+
if (o === it || a.y2 > b.y1 || b.y1 - a.y2 > 40) continue;
|
|
29820
|
+
if (!(near(a.x2, b.x2) || near(a.x1, b.x1))) continue;
|
|
29821
|
+
if (!above || a.y2 > above.y2) above = a;
|
|
29822
|
+
}
|
|
29823
|
+
if (!above) continue;
|
|
29824
|
+
let side;
|
|
29825
|
+
if (near(above.x2, b.x2) && !near(above.x1, b.x1)) side = 0;
|
|
29826
|
+
else if (near(above.x1, b.x1) && !near(above.x2, b.x2)) side = 1;
|
|
29827
|
+
else side = list.some((o) => o !== it && near(cy(o.box), cy(b)) && o.box.x2 <= b.x1) ? 1 : 0;
|
|
29828
|
+
under.push({
|
|
29829
|
+
id: it.id,
|
|
29830
|
+
box: b,
|
|
29831
|
+
above,
|
|
29832
|
+
side
|
|
29833
|
+
});
|
|
29834
|
+
}
|
|
29835
|
+
let corridor = (u) => {
|
|
29836
|
+
if (u.side === 0) {
|
|
29837
|
+
let l = u.box.x2;
|
|
29838
|
+
let col = list.filter((o) => near(o.box.x2, l));
|
|
29839
|
+
let r = Infinity;
|
|
29840
|
+
for (let c of col) for (let o of list) if (o !== c && near(cy(o.box), cy(c.box)) && o.box.x1 >= l - .5) r = Math.min(r, o.box.x1);
|
|
29841
|
+
return {
|
|
29842
|
+
l,
|
|
29843
|
+
r: isFinite(r) ? r : l + 36,
|
|
29844
|
+
col
|
|
29845
|
+
};
|
|
29846
|
+
}
|
|
29847
|
+
let r = u.box.x1;
|
|
29848
|
+
let col = list.filter((o) => near(o.box.x1, r));
|
|
29849
|
+
let l = -Infinity;
|
|
29850
|
+
for (let c of col) for (let o of list) if (o !== c && near(cy(o.box), cy(c.box)) && o.box.x2 <= r + .5) l = Math.max(l, o.box.x2);
|
|
29851
|
+
return {
|
|
29852
|
+
l: isFinite(l) ? l : r - 36,
|
|
29853
|
+
r,
|
|
29854
|
+
col
|
|
29855
|
+
};
|
|
29856
|
+
};
|
|
29857
|
+
let groups = /* @__PURE__ */ new Map();
|
|
29858
|
+
for (let u of under) {
|
|
29859
|
+
let c = corridor(u);
|
|
29860
|
+
u.top = Math.min(...c.col.map((o) => o.box.y1));
|
|
29861
|
+
let key = `${Math.round(c.l)}|${Math.round(c.r)}`;
|
|
29862
|
+
if (!groups.has(key)) groups.set(key, {
|
|
29863
|
+
l: c.l,
|
|
29864
|
+
r: c.r,
|
|
29865
|
+
left: [],
|
|
29866
|
+
right: []
|
|
29867
|
+
});
|
|
29868
|
+
groups.get(key)[u.side === 0 ? "left" : "right"].push(u);
|
|
29869
|
+
}
|
|
29870
|
+
let out = /* @__PURE__ */ new Map();
|
|
29871
|
+
for (let g of groups.values()) {
|
|
29872
|
+
g.left.sort((a, b) => a.box.y1 - b.box.y1);
|
|
29873
|
+
g.right.sort((a, b) => a.box.y1 - b.box.y1);
|
|
29874
|
+
let n = g.left.length + g.right.length;
|
|
29875
|
+
let room = g.r - g.l - 20;
|
|
29876
|
+
let step = n > 1 ? Math.max(0, Math.min(6, room / (n - 1))) : 0;
|
|
29877
|
+
g.left.forEach((u, i) => {
|
|
29878
|
+
out.set(u.id, {
|
|
29879
|
+
lane: g.l + 10 + i * step,
|
|
29880
|
+
z: (u.above.y2 + u.box.y1) / 2,
|
|
29881
|
+
top: u.top
|
|
29882
|
+
});
|
|
29883
|
+
});
|
|
29884
|
+
g.right.forEach((u, j) => {
|
|
29885
|
+
out.set(u.id, {
|
|
29886
|
+
lane: g.r - 10 - j * step,
|
|
29887
|
+
z: (u.above.y2 + u.box.y1) / 2,
|
|
29888
|
+
top: u.top
|
|
29889
|
+
});
|
|
29890
|
+
});
|
|
29891
|
+
}
|
|
29892
|
+
return out;
|
|
29893
|
+
}
|
|
29666
29894
|
/************************************************************
|
|
29667
29895
|
* The control points of an elbow from the port `s` to the port
|
|
29668
29896
|
* `t` ([x, y] each), knowing the boxes of the two cards
|
|
@@ -29670,34 +29898,32 @@ function swap_box(b) {
|
|
|
29670
29898
|
*
|
|
29671
29899
|
* vertical the rows are stacked (top to bottom); false
|
|
29672
29900
|
* when they are side by side (left to right)
|
|
29673
|
-
* stagger {dep, arr}: the edge's rank among the
|
|
29674
|
-
* edges leaving its source card and among
|
|
29675
|
-
* reaching its target card (elbow_rank)
|
|
29676
|
-
* the
|
|
29901
|
+
* stagger {dep, arr, comb}: the edge's rank among the
|
|
29902
|
+
* forward edges leaving its source card and among
|
|
29903
|
+
* those reaching its target card (elbow_rank), and
|
|
29904
|
+
* its comb when the target is in a lower row of a
|
|
29905
|
+
* stack (elbow_combs). Absent, the channel is the
|
|
29906
|
+
* middle.
|
|
29677
29907
|
************************************************************/
|
|
29678
29908
|
function elbow_points(s, t, box_s, box_t, lane, vertical, stagger) {
|
|
29679
29909
|
if (!vertical) return elbow_points(swap(s), swap(t), swap_box(box_s), swap_box(box_t), lane, true, stagger).map(swap);
|
|
29680
29910
|
let shift = lane * 10;
|
|
29681
29911
|
if (t[1] - s[1] > 20) {
|
|
29912
|
+
let st = stagger || {};
|
|
29682
29913
|
let lo = Math.max(s[1], box_s.y2);
|
|
29914
|
+
if (st.comb) {
|
|
29915
|
+
let c = st.comb;
|
|
29916
|
+
let turn = staggered_turn(lo, c.top, { dep: st.dep }) + shift;
|
|
29917
|
+
turn = Math.min(Math.max(turn, lo + 4), c.top - 4);
|
|
29918
|
+
return [
|
|
29919
|
+
[s[0], turn],
|
|
29920
|
+
[c.lane, turn],
|
|
29921
|
+
[c.lane, c.z],
|
|
29922
|
+
[t[0], c.z]
|
|
29923
|
+
];
|
|
29924
|
+
}
|
|
29683
29925
|
let hi = Math.min(t[1], box_t.y1);
|
|
29684
|
-
let mid = (lo
|
|
29685
|
-
let st = stagger || {};
|
|
29686
|
-
let group = null;
|
|
29687
|
-
let k = 0;
|
|
29688
|
-
if (st.dep && st.dep.count > 1) {
|
|
29689
|
-
group = st.dep;
|
|
29690
|
-
k = st.dep.rank;
|
|
29691
|
-
} else if (st.arr && st.arr.count > 1) {
|
|
29692
|
-
group = st.arr;
|
|
29693
|
-
k = st.arr.count - 1 - st.arr.rank;
|
|
29694
|
-
}
|
|
29695
|
-
if (group) {
|
|
29696
|
-
let room = Math.max(0, hi - lo - 12);
|
|
29697
|
-
let step = Math.min(10, room / (group.count - 1));
|
|
29698
|
-
mid = mid - (group.count - 1) * step / 2 + k * step;
|
|
29699
|
-
}
|
|
29700
|
-
mid += shift;
|
|
29926
|
+
let mid = staggered_turn(lo, hi, st) + shift;
|
|
29701
29927
|
mid = Math.min(Math.max(mid, lo + 4), hi - 4);
|
|
29702
29928
|
return [[s[0], mid], [t[0], mid]];
|
|
29703
29929
|
}
|
|
@@ -29916,6 +30142,7 @@ function orth_search(a, z, boxes) {
|
|
|
29916
30142
|
function elbow_route(s, t, box_s, box_t, lane, vertical, boxes, stagger) {
|
|
29917
30143
|
let others = boxes || [];
|
|
29918
30144
|
if (!vertical) return elbow_route(swap(s), swap(t), swap_box(box_s), swap_box(box_t), lane, true, others.map(swap_box), stagger).map(swap);
|
|
30145
|
+
if (stagger && stagger.comb) return elbow_points(s, t, box_s, box_t, lane, true, stagger);
|
|
29919
30146
|
let simple = elbow_points(s, t, box_s, box_t, lane, true, stagger);
|
|
29920
30147
|
if (!elbow_path_hits([
|
|
29921
30148
|
s,
|
|
@@ -29936,6 +30163,112 @@ function elbow_route(s, t, box_s, box_t, lane, vertical, boxes, stagger) {
|
|
|
29936
30163
|
if (!route && near.length < others.length) route = orth_search(a, z, others.map((b) => box_expand(b, m)));
|
|
29937
30164
|
return route || simple;
|
|
29938
30165
|
}
|
|
30166
|
+
function path_points(path) {
|
|
30167
|
+
let pts = [];
|
|
30168
|
+
let cur = null;
|
|
30169
|
+
for (let c of path) if (c[0] === "M" || c[0] === "L") {
|
|
30170
|
+
cur = [c[1], c[2]];
|
|
30171
|
+
pts.push(cur);
|
|
30172
|
+
} else if (c[0] === "C" && cur) {
|
|
30173
|
+
let [x0, y0] = cur;
|
|
30174
|
+
for (let k = 1; k <= 16; k++) {
|
|
30175
|
+
let u = k / 16;
|
|
30176
|
+
let v = 1 - u;
|
|
30177
|
+
pts.push([v * v * v * x0 + 3 * v * v * u * c[1] + 3 * v * u * u * c[3] + u * u * u * c[5], v * v * v * y0 + 3 * v * v * u * c[2] + 3 * v * u * u * c[4] + u * u * u * c[6]]);
|
|
30178
|
+
}
|
|
30179
|
+
cur = [c[5], c[6]];
|
|
30180
|
+
} else if (c[0] === "Q" && cur) {
|
|
30181
|
+
let [x0, y0] = cur;
|
|
30182
|
+
for (let k = 1; k <= 16; k++) {
|
|
30183
|
+
let u = k / 16;
|
|
30184
|
+
let v = 1 - u;
|
|
30185
|
+
pts.push([v * v * x0 + 2 * v * u * c[1] + u * u * c[3], v * v * y0 + 2 * v * u * c[2] + u * u * c[4]]);
|
|
30186
|
+
}
|
|
30187
|
+
cur = [c[3], c[4]];
|
|
30188
|
+
}
|
|
30189
|
+
return pts;
|
|
30190
|
+
}
|
|
30191
|
+
/************************************************************
|
|
30192
|
+
* Does the G6 path `path` of a curved edge cross a card other than
|
|
30193
|
+
* its own two? Measured on the curve itself -- the path G6 would
|
|
30194
|
+
* draw, sampled -- and not on the rectangle round it, which took
|
|
30195
|
+
* every card the curve merely passed near: the ports of a row
|
|
30196
|
+
* stick well into the space above it. Its own two cards are left
|
|
30197
|
+
* out: the curve starts and ends on their ports.
|
|
30198
|
+
************************************************************/
|
|
30199
|
+
function curve_hits(path, boxes, box_s, box_t) {
|
|
30200
|
+
let pts = path_points(path);
|
|
30201
|
+
if (pts.length < 2) return false;
|
|
30202
|
+
let bb = {
|
|
30203
|
+
x1: Infinity,
|
|
30204
|
+
y1: Infinity,
|
|
30205
|
+
x2: -Infinity,
|
|
30206
|
+
y2: -Infinity
|
|
30207
|
+
};
|
|
30208
|
+
for (let p of pts) {
|
|
30209
|
+
bb.x1 = Math.min(bb.x1, p[0]);
|
|
30210
|
+
bb.y1 = Math.min(bb.y1, p[1]);
|
|
30211
|
+
bb.x2 = Math.max(bb.x2, p[0]);
|
|
30212
|
+
bb.y2 = Math.max(bb.y2, p[1]);
|
|
30213
|
+
}
|
|
30214
|
+
for (let b of boxes || []) {
|
|
30215
|
+
if (same_box(b, box_s) || same_box(b, box_t) || !box_overlaps(b, box_expand(bb, 1))) continue;
|
|
30216
|
+
let inner = box_expand(b, -1);
|
|
30217
|
+
for (let k = 0; k + 1 < pts.length; k++) if (segment_hits(pts[k], pts[k + 1], inner)) return true;
|
|
30218
|
+
}
|
|
30219
|
+
return false;
|
|
30220
|
+
}
|
|
30221
|
+
/************************************************************
|
|
30222
|
+
* A G6 path (['M'|'L'|'Q', ...]) along `points` with every corner
|
|
30223
|
+
* rounded -- by `radius`, or by half the shorter of its two
|
|
30224
|
+
* segments, so a short run is never overshot. The rounding is the
|
|
30225
|
+
* quadratic G6's own polyline uses.
|
|
30226
|
+
************************************************************/
|
|
30227
|
+
function rounded_path(points, radius) {
|
|
30228
|
+
let path = [[
|
|
30229
|
+
"M",
|
|
30230
|
+
points[0][0],
|
|
30231
|
+
points[0][1]
|
|
30232
|
+
]];
|
|
30233
|
+
for (let i = 1; i + 1 < points.length; i++) {
|
|
30234
|
+
let a = points[i - 1];
|
|
30235
|
+
let m = points[i];
|
|
30236
|
+
let b = points[i + 1];
|
|
30237
|
+
let len_in = Math.hypot(m[0] - a[0], m[1] - a[1]);
|
|
30238
|
+
let len_out = Math.hypot(b[0] - m[0], b[1] - m[1]);
|
|
30239
|
+
let r = Math.min(radius, len_in / 2, len_out / 2);
|
|
30240
|
+
let collinear = Math.abs((m[0] - a[0]) * (b[1] - m[1]) - (m[1] - a[1]) * (b[0] - m[0])) < 1e-9;
|
|
30241
|
+
if (r <= 0 || collinear) {
|
|
30242
|
+
path.push([
|
|
30243
|
+
"L",
|
|
30244
|
+
m[0],
|
|
30245
|
+
m[1]
|
|
30246
|
+
]);
|
|
30247
|
+
continue;
|
|
30248
|
+
}
|
|
30249
|
+
let p1 = [m[0] - (m[0] - a[0]) / len_in * r, m[1] - (m[1] - a[1]) / len_in * r];
|
|
30250
|
+
let p2 = [m[0] + (b[0] - m[0]) / len_out * r, m[1] + (b[1] - m[1]) / len_out * r];
|
|
30251
|
+
path.push([
|
|
30252
|
+
"L",
|
|
30253
|
+
p1[0],
|
|
30254
|
+
p1[1]
|
|
30255
|
+
]);
|
|
30256
|
+
path.push([
|
|
30257
|
+
"Q",
|
|
30258
|
+
m[0],
|
|
30259
|
+
m[1],
|
|
30260
|
+
p2[0],
|
|
30261
|
+
p2[1]
|
|
30262
|
+
]);
|
|
30263
|
+
}
|
|
30264
|
+
let last = points[points.length - 1];
|
|
30265
|
+
path.push([
|
|
30266
|
+
"L",
|
|
30267
|
+
last[0],
|
|
30268
|
+
last[1]
|
|
30269
|
+
]);
|
|
30270
|
+
return path;
|
|
30271
|
+
}
|
|
29939
30272
|
//#endregion
|
|
29940
30273
|
//#region node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
29941
30274
|
function _typeof(o) {
|
|
@@ -54823,7 +55156,7 @@ Easing Functions from anime.js, they are tried and true, so, its better to use t
|
|
|
54823
55156
|
var Quad = function Quad(t) {
|
|
54824
55157
|
return Math.pow(t, 2);
|
|
54825
55158
|
};
|
|
54826
|
-
var Cubic = function Cubic(t) {
|
|
55159
|
+
var Cubic$1 = function Cubic(t) {
|
|
54827
55160
|
return Math.pow(t, 3);
|
|
54828
55161
|
};
|
|
54829
55162
|
var Quart = function Quart(t) {
|
|
@@ -54960,10 +55293,10 @@ var EasingFunctions = {
|
|
|
54960
55293
|
"out-quad": EaseOut(Quad),
|
|
54961
55294
|
"in-out-quad": EaseInOut(Quad),
|
|
54962
55295
|
"out-in-quad": EaseOutIn(Quad),
|
|
54963
|
-
"in-cubic": Cubic,
|
|
54964
|
-
"out-cubic": EaseOut(Cubic),
|
|
54965
|
-
"in-out-cubic": EaseInOut(Cubic),
|
|
54966
|
-
"out-in-cubic": EaseOutIn(Cubic),
|
|
55296
|
+
"in-cubic": Cubic$1,
|
|
55297
|
+
"out-cubic": EaseOut(Cubic$1),
|
|
55298
|
+
"in-out-cubic": EaseInOut(Cubic$1),
|
|
55299
|
+
"out-in-cubic": EaseOutIn(Cubic$1),
|
|
54967
55300
|
"in-quart": Quart,
|
|
54968
55301
|
"out-quart": EaseOut(Quart),
|
|
54969
55302
|
"in-out-quart": EaseInOut(Quart),
|
|
@@ -57136,6 +57469,8 @@ function register_layouts(gobj) {
|
|
|
57136
57469
|
register(ExtensionCategory.LAYOUT, "treedb-compact", TreedbCompactLayout);
|
|
57137
57470
|
register(ExtensionCategory.EDGE, "treedb-elbow-v", TreedbElbowV);
|
|
57138
57471
|
register(ExtensionCategory.EDGE, "treedb-elbow-h", TreedbElbowH);
|
|
57472
|
+
register(ExtensionCategory.EDGE, "treedb-curve-v", TreedbCurveV);
|
|
57473
|
+
register(ExtensionCategory.EDGE, "treedb-curve-h", TreedbCurveH);
|
|
57139
57474
|
register(ExtensionCategory.LAYOUT, "treedb-radial", TreedbRadialLayout);
|
|
57140
57475
|
register(ExtensionCategory.NODE, "light", LightNode);
|
|
57141
57476
|
register(ExtensionCategory.NODE, "treedb-card", TreedbCard);
|
|
@@ -57830,7 +58165,9 @@ function layout_direction(gobj) {
|
|
|
57830
58165
|
function edge_type_for(gobj) {
|
|
57831
58166
|
let lr = layout_direction(gobj) === "LR";
|
|
57832
58167
|
let rowless = gobj_read_attr(gobj, "rowless_layouts") || [];
|
|
57833
|
-
|
|
58168
|
+
let rows = !str_in_list(rowless, gobj.priv.layout);
|
|
58169
|
+
if (rows && gobj_read_str_attr(gobj, "edge_shape") === "elbow") return lr ? "treedb-elbow-h" : "treedb-elbow-v";
|
|
58170
|
+
if (rows) return lr ? "treedb-curve-h" : "treedb-curve-v";
|
|
57834
58171
|
return lr ? "cubic-horizontal" : "cubic";
|
|
57835
58172
|
}
|
|
57836
58173
|
/************************************************************
|
|
@@ -59389,17 +59726,27 @@ function elbow_stagger_of(edge, vertical) {
|
|
|
59389
59726
|
try {
|
|
59390
59727
|
let ps = pos(s);
|
|
59391
59728
|
let pt = pos(t);
|
|
59392
|
-
let
|
|
59729
|
+
let leaving = graph.getRelatedEdgesData(s, "out").filter((d) => d.source === s && pos(d.target)[along] > ps[along]);
|
|
59730
|
+
let combs = elbow_combs(leaving.map((d) => ({
|
|
59393
59731
|
id: d.id,
|
|
59394
|
-
|
|
59395
|
-
}));
|
|
59732
|
+
box: elbow_box(element.getElement(d.target))
|
|
59733
|
+
})), vertical);
|
|
59734
|
+
let dep = leaving.map((d) => {
|
|
59735
|
+
let comb = combs.get(d.id);
|
|
59736
|
+
let far = comb ? comb.lane : pos(d.target)[across];
|
|
59737
|
+
return {
|
|
59738
|
+
id: d.id,
|
|
59739
|
+
span: Math.abs(far - port_of(s, d.style && d.style.sourcePort)[across])
|
|
59740
|
+
};
|
|
59741
|
+
});
|
|
59396
59742
|
let arr = graph.getRelatedEdgesData(t, "in").filter((d) => d.target === t && pos(d.source)[along] < pt[along]).map((d) => ({
|
|
59397
59743
|
id: d.id,
|
|
59398
59744
|
span: Math.abs(port_of(d.source, d.style && d.style.sourcePort)[across] - pt[across])
|
|
59399
59745
|
}));
|
|
59400
59746
|
return {
|
|
59401
59747
|
dep: elbow_rank(dep, edge.id),
|
|
59402
|
-
arr: elbow_rank(arr, edge.id)
|
|
59748
|
+
arr: elbow_rank(arr, edge.id),
|
|
59749
|
+
comb: combs.get(edge.id) || null
|
|
59403
59750
|
};
|
|
59404
59751
|
} catch (e) {
|
|
59405
59752
|
log_error(`elbow edge ${edge.id}: cannot read the edges sharing its ends: ${e}`);
|
|
@@ -59424,6 +59771,40 @@ var TreedbElbowH = class extends Polyline {
|
|
|
59424
59771
|
return super.getKeyPath(Object.assign({}, attributes, { radius: attributes.radius || ELBOW_RADIUS }));
|
|
59425
59772
|
}
|
|
59426
59773
|
};
|
|
59774
|
+
/************************************************************
|
|
59775
|
+
* A CURVED edge that keeps off the cards. G6's cubic, as before,
|
|
59776
|
+
* unless that very curve -- sampled, not guessed from the
|
|
59777
|
+
* rectangle round it -- would cross a card other than its own two,
|
|
59778
|
+
* or when it does not run forward and so would cross its own:
|
|
59779
|
+
* the card above a lower row of a stack, a row between a parent
|
|
59780
|
+
* and a far child. Then it goes the way an elbow would (the comb,
|
|
59781
|
+
* the detour, the route: the same lanes and staggered turns) with
|
|
59782
|
+
* round corners, so it still reads as a curve. `-v` for rows
|
|
59783
|
+
* stacked top to bottom, `-h` for columns.
|
|
59784
|
+
************************************************************/
|
|
59785
|
+
function curve_key_path(edge, attributes, vertical, plain) {
|
|
59786
|
+
let [s, t] = edge.getEndpoints(attributes, false);
|
|
59787
|
+
let along = vertical ? 1 : 0;
|
|
59788
|
+
let box_s = elbow_box(edge.sourceNode);
|
|
59789
|
+
let box_t = elbow_box(edge.targetNode);
|
|
59790
|
+
let boxes = elbow_obstacles(edge);
|
|
59791
|
+
if (t[along] - s[along] > 20 && !curve_hits(plain, boxes, box_s, box_t)) return plain;
|
|
59792
|
+
return rounded_path([
|
|
59793
|
+
s,
|
|
59794
|
+
...elbow_route(s, t, box_s, box_t, elbow_lane_of(edge), vertical, boxes, elbow_stagger_of(edge, vertical)),
|
|
59795
|
+
t
|
|
59796
|
+
], 24);
|
|
59797
|
+
}
|
|
59798
|
+
var TreedbCurveV = class extends Cubic {
|
|
59799
|
+
getKeyPath(attributes) {
|
|
59800
|
+
return curve_key_path(this, attributes, true, super.getKeyPath(attributes));
|
|
59801
|
+
}
|
|
59802
|
+
};
|
|
59803
|
+
var TreedbCurveH = class extends CubicHorizontal {
|
|
59804
|
+
getKeyPath(attributes) {
|
|
59805
|
+
return curve_key_path(this, attributes, false, super.getKeyPath(attributes));
|
|
59806
|
+
}
|
|
59807
|
+
};
|
|
59427
59808
|
var TreedbCompactLayout = class extends BaseLayout {
|
|
59428
59809
|
async execute(data, options) {
|
|
59429
59810
|
let input = treedb_layout_input(data);
|