MCPcopy
hub / github.com/clientIO/joint / outsideLayout

Function outsideLayout

packages/joint-core/src/layout/ports/portLabel.mjs:28–79  ·  view source on GitHub ↗
(portPosition, elBBox, autoOrient, opt)

Source from the content-addressed store, hash-verified

26}
27
28function outsideLayout(portPosition, elBBox, autoOrient, opt) {
29
30 opt = util.defaults({}, opt, { offset: 15 });
31 var angle = elBBox.center().theta(portPosition);
32
33 var tx, ty, y, textAnchor;
34 var offset = opt.offset;
35 var orientAngle = 0;
36
37 const [topLeftAngle, bottomLeftAngle, bottomRightAngle, topRightAngle] = getBBoxAngles(elBBox);
38 if ((angle < bottomLeftAngle) || (angle > bottomRightAngle)) {
39 y = '.3em';
40 tx = offset;
41 ty = 0;
42 textAnchor = 'start';
43 } else if (angle < topLeftAngle) {
44 tx = 0;
45 ty = -offset;
46 if (autoOrient) {
47 orientAngle = -90;
48 textAnchor = 'start';
49 y = '.3em';
50 } else {
51 textAnchor = 'middle';
52 y = '0';
53 }
54 } else if (angle < topRightAngle) {
55 y = '.3em';
56 tx = -offset;
57 ty = 0;
58 textAnchor = 'end';
59 } else {
60 tx = 0;
61 ty = offset;
62 if (autoOrient) {
63 orientAngle = 90;
64 textAnchor = 'start';
65 y = '.3em';
66 } else {
67 textAnchor = 'middle';
68 y = '.6em';
69 }
70 }
71
72 var round = Math.round;
73 return labelAttributes(opt, {
74 x: round(tx),
75 y: round(ty),
76 angle: orientAngle,
77 attrs: { labelText: { y, textAnchor }}
78 });
79}
80
81function insideLayout(portPosition, elBBox, autoOrient, opt) {
82

Callers 2

outsideOrientedFunction · 0.85
outsideFunction · 0.85

Calls 4

getBBoxAnglesFunction · 0.85
labelAttributesFunction · 0.85
roundFunction · 0.85
defaultsMethod · 0.45

Tested by

no test coverage detected