@formicoidea/labre-framework-uml 0.42.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/LICENSE +384 -0
- package/dist/actions.d.ts +430 -0
- package/dist/actions.js +724 -0
- package/dist/background.d.ts +153 -0
- package/dist/background.js +557 -0
- package/dist/board-hit.d.ts +137 -0
- package/dist/board-hit.js +191 -0
- package/dist/commands-manifest.d.ts +19 -0
- package/dist/commands-manifest.js +571 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +983 -0
- package/dist/component.d.ts +521 -0
- package/dist/component.js +708 -0
- package/dist/consts.d.ts +365 -0
- package/dist/consts.js +463 -0
- package/dist/descriptor.d.ts +12 -0
- package/dist/descriptor.js +10 -0
- package/dist/drawio-decode.d.ts +32 -0
- package/dist/drawio-decode.js +96 -0
- package/dist/drawio-import.d.ts +133 -0
- package/dist/drawio-import.js +885 -0
- package/dist/edge-morph.d.ts +154 -0
- package/dist/edge-morph.js +153 -0
- package/dist/edge-styles.d.ts +78 -0
- package/dist/edge-styles.js +210 -0
- package/dist/effects.d.ts +9 -0
- package/dist/effects.js +6 -0
- package/dist/element-renderer.d.ts +64 -0
- package/dist/element-renderer.js +114 -0
- package/dist/element-view.d.ts +234 -0
- package/dist/element-view.js +430 -0
- package/dist/export.d.ts +61 -0
- package/dist/export.js +41 -0
- package/dist/filename.d.ts +17 -0
- package/dist/filename.js +26 -0
- package/dist/frame-tag.d.ts +70 -0
- package/dist/frame-tag.js +78 -0
- package/dist/grammar.d.ts +695 -0
- package/dist/grammar.js +1436 -0
- package/dist/import.d.ts +306 -0
- package/dist/import.js +1270 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +67 -0
- package/dist/interchange.d.ts +125 -0
- package/dist/interchange.js +372 -0
- package/dist/keywords.d.ts +204 -0
- package/dist/keywords.js +361 -0
- package/dist/kinds.d.ts +73 -0
- package/dist/kinds.js +91 -0
- package/dist/legend.d.ts +30 -0
- package/dist/legend.js +255 -0
- package/dist/model.d.ts +862 -0
- package/dist/model.js +1316 -0
- package/dist/morph.d.ts +178 -0
- package/dist/morph.js +496 -0
- package/dist/node/act-glyphs.d.ts +30 -0
- package/dist/node/act-glyphs.js +142 -0
- package/dist/node/compartment-watcher.d.ts +107 -0
- package/dist/node/compartment-watcher.js +163 -0
- package/dist/node/fit.d.ts +85 -0
- package/dist/node/fit.js +129 -0
- package/dist/node/node-renderer.d.ts +49 -0
- package/dist/node/node-renderer.js +611 -0
- package/dist/node/node-view.d.ts +51 -0
- package/dist/node/node-view.js +89 -0
- package/dist/node/paint.d.ts +84 -0
- package/dist/node/paint.js +143 -0
- package/dist/node/sd-glyphs.d.ts +36 -0
- package/dist/node/sd-glyphs.js +79 -0
- package/dist/node/stm-glyphs.d.ts +22 -0
- package/dist/node/stm-glyphs.js +111 -0
- package/dist/node/tier-metrics.d.ts +38 -0
- package/dist/node/tier-metrics.js +45 -0
- package/dist/operators.d.ts +45 -0
- package/dist/operators.js +75 -0
- package/dist/plantuml-import.d.ts +113 -0
- package/dist/plantuml-import.js +1723 -0
- package/dist/plantuml.d.ts +94 -0
- package/dist/plantuml.js +985 -0
- package/dist/presets.d.ts +149 -0
- package/dist/presets.js +302 -0
- package/dist/profiles.d.ts +2 -0
- package/dist/profiles.js +358 -0
- package/dist/reading.d.ts +160 -0
- package/dist/reading.js +648 -0
- package/dist/roles.d.ts +257 -0
- package/dist/roles.js +997 -0
- package/dist/rules.d.ts +267 -0
- package/dist/rules.js +3090 -0
- package/dist/templates.d.ts +2 -0
- package/dist/templates.js +197 -0
- package/dist/toolbar/config.d.ts +228 -0
- package/dist/toolbar/config.js +833 -0
- package/dist/toolbar/icons.d.ts +440 -0
- package/dist/toolbar/icons.js +711 -0
- package/dist/toolbar/senior-tool.d.ts +11 -0
- package/dist/toolbar/senior-tool.js +21 -0
- package/dist/toolbar/uml-menu.d.ts +17 -0
- package/dist/toolbar/uml-menu.js +20 -0
- package/dist/toolbar/uml-senior-button.d.ts +18 -0
- package/dist/toolbar/uml-senior-button.js +22 -0
- package/dist/translations.d.ts +27 -0
- package/dist/translations.js +117 -0
- package/dist/view.d.ts +33 -0
- package/dist/view.js +236 -0
- package/dist/xmi-import.d.ts +174 -0
- package/dist/xmi-import.js +2268 -0
- package/dist/xmi.d.ts +61 -0
- package/dist/xmi.js +1860 -0
- package/dist/xml-reader.d.ts +157 -0
- package/dist/xml-reader.js +430 -0
- package/dist/xml.d.ts +72 -0
- package/dist/xml.js +96 -0
- package/package.json +38 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { backgroundLabelText, createFrameworkBackgroundRenderer, } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
/**
|
|
3
|
+
* The tag's box, in ELEMENT-LOCAL model units — everything but the corner bite.
|
|
4
|
+
*
|
|
5
|
+
* Split out and exported so the geometry can be asserted without a canvas, and
|
|
6
|
+
* so a future gesture (aim at the tag, not at the band) has one place to ask.
|
|
7
|
+
* `null` when there is nothing to draw: a frame dragged to nothing, or a heading
|
|
8
|
+
* of no words at all.
|
|
9
|
+
*/
|
|
10
|
+
export function umlFrameTagRect(width, height, textWidth, opts) {
|
|
11
|
+
if (!(width > 0) || !(height > 0))
|
|
12
|
+
return null;
|
|
13
|
+
if (!(textWidth > 0))
|
|
14
|
+
return null;
|
|
15
|
+
const inset = opts.lineWidth / 2;
|
|
16
|
+
// Clamped to the element on both axes: a frame dragged shorter than its own
|
|
17
|
+
// heading keeps a tag, cut down to what there is, exactly as the band is.
|
|
18
|
+
const w = Math.min(textWidth + opts.padding * 2, width - inset * 2);
|
|
19
|
+
const h = Math.min(opts.bandHeight - opts.foot, height - inset * 2);
|
|
20
|
+
if (!(w > 0) || !(h > 0))
|
|
21
|
+
return null;
|
|
22
|
+
return { x: inset, y: inset, w, h };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Wrap a frame declaration's renderer so the heading is drawn inside Annex A's
|
|
26
|
+
* pentagon.
|
|
27
|
+
*
|
|
28
|
+
* Stroke only, in the frame's own ink: the tag is an outline pinned to the
|
|
29
|
+
* sheet's corner, and filling it would hide the card behind the words — which
|
|
30
|
+
* matters the moment a user drags an element under the heading.
|
|
31
|
+
*/
|
|
32
|
+
export function withUmlFrameTag(def, opts) {
|
|
33
|
+
const base = createFrameworkBackgroundRenderer(def);
|
|
34
|
+
const family = def.chrome?.fontFamily ?? 'Inter, sans-serif';
|
|
35
|
+
const label = def.chrome?.sideBands?.find(band => band.label?.prop === opts.prop)?.label;
|
|
36
|
+
return (model, ctx, matrix, renderer, rc, bound) => {
|
|
37
|
+
const [, , w, h] = model.deserializedXYWH;
|
|
38
|
+
const cx = w / 2;
|
|
39
|
+
const cy = h / 2;
|
|
40
|
+
// BEFORE the base renderer — see the note at the top of this file.
|
|
41
|
+
const tagMatrix = DOMMatrix.fromMatrix(matrix)
|
|
42
|
+
.translateSelf(cx, cy)
|
|
43
|
+
.rotateSelf(model.rotate)
|
|
44
|
+
.translateSelf(-cx, -cy);
|
|
45
|
+
base(model, ctx, matrix, renderer, rc, bound);
|
|
46
|
+
if (!label)
|
|
47
|
+
return;
|
|
48
|
+
const words = backgroundLabelText(label, model);
|
|
49
|
+
if (!words)
|
|
50
|
+
return;
|
|
51
|
+
ctx.setTransform(tagMatrix);
|
|
52
|
+
// The declaration's own font, so the box fits the glyphs that were painted
|
|
53
|
+
// rather than the glyphs this file would have chosen.
|
|
54
|
+
const weight = label.style.weight ? `${label.style.weight} ` : '';
|
|
55
|
+
ctx.font = `${weight}${label.style.size}px ${label.style.family ?? family}`;
|
|
56
|
+
const textWidth = ctx.measureText(words).width;
|
|
57
|
+
const rect = umlFrameTagRect(w, h, textWidth, opts);
|
|
58
|
+
if (!rect)
|
|
59
|
+
return;
|
|
60
|
+
const { x, y } = rect;
|
|
61
|
+
const right = x + rect.w;
|
|
62
|
+
const bottom = y + rect.h;
|
|
63
|
+
// The bite can be no larger than the box it is taken out of — a tag squeezed
|
|
64
|
+
// by a short heading or a squashed frame degrades to a triangle rather than
|
|
65
|
+
// folding back on itself.
|
|
66
|
+
const cut = Math.max(0, Math.min(opts.cut, rect.w, rect.h));
|
|
67
|
+
ctx.strokeStyle = opts.stroke;
|
|
68
|
+
ctx.lineWidth = opts.lineWidth;
|
|
69
|
+
ctx.beginPath();
|
|
70
|
+
ctx.moveTo(x, y);
|
|
71
|
+
ctx.lineTo(right, y);
|
|
72
|
+
ctx.lineTo(right, bottom - cut);
|
|
73
|
+
ctx.lineTo(right - cut, bottom);
|
|
74
|
+
ctx.lineTo(x, bottom);
|
|
75
|
+
ctx.closePath();
|
|
76
|
+
ctx.stroke();
|
|
77
|
+
};
|
|
78
|
+
}
|