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

Function insideLayout

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

Source from the content-addressed store, hash-verified

79}
80
81function insideLayout(portPosition, elBBox, autoOrient, opt) {
82
83 opt = util.defaults({}, opt, { offset: 15 });
84 var angle = elBBox.center().theta(portPosition);
85
86 var tx, ty, y, textAnchor;
87 var offset = opt.offset;
88 var orientAngle = 0;
89
90 const [topLeftAngle, bottomLeftAngle, bottomRightAngle, topRightAngle] = getBBoxAngles(elBBox);
91 if ((angle < bottomLeftAngle) || (angle > bottomRightAngle)) {
92 y = '.3em';
93 tx = -offset;
94 ty = 0;
95 textAnchor = 'end';
96 } else if (angle < topLeftAngle) {
97 tx = 0;
98 ty = offset;
99 if (autoOrient) {
100 orientAngle = 90;
101 textAnchor = 'start';
102 y = '.3em';
103 } else {
104 textAnchor = 'middle';
105 y = '.6em';
106 }
107 } else if (angle < topRightAngle) {
108 y = '.3em';
109 tx = offset;
110 ty = 0;
111 textAnchor = 'start';
112 } else {
113 tx = 0;
114 ty = -offset;
115 if (autoOrient) {
116 orientAngle = -90;
117 textAnchor = 'start';
118 y = '.3em';
119 } else {
120 textAnchor = 'middle';
121 y = '0';
122 }
123 }
124
125 var round = Math.round;
126 return labelAttributes(opt, {
127 x: round(tx),
128 y: round(ty),
129 angle: orientAngle,
130 attrs: { labelText: { y, textAnchor }}
131 });
132}
133
134function radialLayout(portCenterOffset, autoOrient, opt) {
135

Callers 2

insideOrientedFunction · 0.85
insideFunction · 0.85

Calls 4

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

Tested by

no test coverage detected