@metadev/daga 5.0.4 → 5.1.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/Changelog.md +17 -1
- package/index.cjs.js +582 -367
- package/index.esm.js +582 -367
- package/package.json +3 -2
- package/src/index.d.ts +2 -2
- package/src/lib/diagram/canvas/diagram-canvas-util.d.ts +9 -9
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +6 -8
- package/src/lib/diagram/config/diagram-canvas-config.d.ts +98 -14
- package/src/lib/diagram/config/diagram-components-config.d.ts +23 -8
- package/src/lib/diagram/config/diagram-config.d.ts +17 -39
- package/src/lib/diagram/config/diagram-look-config.d.ts +40 -0
- package/src/lib/diagram/converters/daga-model.d.ts +29 -2
- package/src/lib/diagram/diagram-event.d.ts +2 -1
- package/src/lib/diagram/model/diagram-decorator.d.ts +5 -5
- package/src/lib/diagram/model/diagram-field.d.ts +20 -27
- package/src/lib/diagram/model/diagram-object.d.ts +5 -5
- package/src/lib/interfaces/canvas.d.ts +6 -26
package/index.esm.js
CHANGED
|
@@ -2666,6 +2666,11 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
}
|
|
2668
2668
|
|
|
2669
|
+
var ResizableMode;
|
|
2670
|
+
(function (ResizableMode) {
|
|
2671
|
+
ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
|
|
2672
|
+
})(ResizableMode || (ResizableMode = {}));
|
|
2673
|
+
|
|
2669
2674
|
/**
|
|
2670
2675
|
* Default values of the parameters of a diagram field.
|
|
2671
2676
|
* @private
|
|
@@ -2673,19 +2678,22 @@ class DiagramConnectionSet extends DiagramElementSet {
|
|
|
2673
2678
|
*/
|
|
2674
2679
|
const DIAGRAM_FIELD_DEFAULTS = {
|
|
2675
2680
|
editable: true,
|
|
2676
|
-
fontSize: 0,
|
|
2677
2681
|
margin: 0,
|
|
2678
2682
|
padding: 0,
|
|
2679
|
-
fontFamily: "'Wonder Unit Sans', sans-serif",
|
|
2680
|
-
color: '#000000',
|
|
2681
|
-
selectedColor: '#000000',
|
|
2682
|
-
backgroundColor: '#00000000',
|
|
2683
2683
|
horizontalAlign: HorizontalAlign.Center,
|
|
2684
2684
|
verticalAlign: VerticalAlign.Center,
|
|
2685
2685
|
orientation: Side.Top,
|
|
2686
2686
|
multiline: false,
|
|
2687
2687
|
fit: false,
|
|
2688
|
-
shrink: true
|
|
2688
|
+
shrink: true,
|
|
2689
|
+
look: {
|
|
2690
|
+
lookType: 'field-look',
|
|
2691
|
+
fillColor: 'transparent',
|
|
2692
|
+
fontColor: '#000000',
|
|
2693
|
+
fontFamily: "'Wonder Unit Sans', sans-serif",
|
|
2694
|
+
fontSize: 10,
|
|
2695
|
+
fontWeight: 400
|
|
2696
|
+
}
|
|
2689
2697
|
};
|
|
2690
2698
|
/**
|
|
2691
2699
|
* A field which displays text and is part of a diagram element.
|
|
@@ -2713,7 +2721,26 @@ class DiagramField extends DiagramElement {
|
|
|
2713
2721
|
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
|
|
2714
2722
|
}
|
|
2715
2723
|
}
|
|
2716
|
-
|
|
2724
|
+
/**
|
|
2725
|
+
* Current look of this field.
|
|
2726
|
+
* @private
|
|
2727
|
+
*/
|
|
2728
|
+
get look() {
|
|
2729
|
+
if (this.selected) {
|
|
2730
|
+
if (this.highlighted) {
|
|
2731
|
+
return this.selectedAndHighlightedLook;
|
|
2732
|
+
} else {
|
|
2733
|
+
return this.selectedLook;
|
|
2734
|
+
}
|
|
2735
|
+
} else {
|
|
2736
|
+
if (this.highlighted) {
|
|
2737
|
+
return this.highlightedLook;
|
|
2738
|
+
} else {
|
|
2739
|
+
return this.defaultLook;
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
constructor(model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
|
|
2717
2744
|
const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
|
|
2718
2745
|
if (model.fields.get(id) !== undefined) {
|
|
2719
2746
|
throw new Error('DiagramField for rootElement already exists');
|
|
@@ -2728,12 +2755,9 @@ class DiagramField extends DiagramElement {
|
|
|
2728
2755
|
this.coords = coords;
|
|
2729
2756
|
this.width = width;
|
|
2730
2757
|
this.height = height;
|
|
2731
|
-
this.fontSize = fontSize;
|
|
2732
|
-
this.fontFamily = fontFamily;
|
|
2733
|
-
this.color = color;
|
|
2734
|
-
this.selectedColor = selectedColor;
|
|
2735
2758
|
this.horizontalAlign = horizontalAlign;
|
|
2736
2759
|
this.verticalAlign = verticalAlign;
|
|
2760
|
+
this.multiline = multiline;
|
|
2737
2761
|
if (!isNaN(Number(orientation))) {
|
|
2738
2762
|
this.orientation = Number(orientation);
|
|
2739
2763
|
} else {
|
|
@@ -2754,7 +2778,11 @@ class DiagramField extends DiagramElement {
|
|
|
2754
2778
|
this.orientation = 0;
|
|
2755
2779
|
}
|
|
2756
2780
|
}
|
|
2757
|
-
|
|
2781
|
+
const looks = extractLooksFromConfig(look);
|
|
2782
|
+
this.defaultLook = looks.defaultLook;
|
|
2783
|
+
this.selectedLook = looks.selectedLook;
|
|
2784
|
+
this.highlightedLook = looks.highlightedLook;
|
|
2785
|
+
this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
|
|
2758
2786
|
this.defaultText = text;
|
|
2759
2787
|
this._text = text;
|
|
2760
2788
|
this.editable = editable;
|
|
@@ -2799,8 +2827,8 @@ class DiagramFieldSet extends DiagramElementSet {
|
|
|
2799
2827
|
* Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
|
|
2800
2828
|
* @private
|
|
2801
2829
|
*/
|
|
2802
|
-
new(rootElement, coords,
|
|
2803
|
-
const field = new DiagramField(this.model, rootElement, coords, width, height,
|
|
2830
|
+
new(rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
|
|
2831
|
+
const field = new DiagramField(this.model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink);
|
|
2804
2832
|
super.add(field);
|
|
2805
2833
|
field.updateInView();
|
|
2806
2834
|
// add this field to its root element
|
|
@@ -2979,11 +3007,6 @@ const getTopPadding$1 = config => {
|
|
|
2979
3007
|
}
|
|
2980
3008
|
};
|
|
2981
3009
|
|
|
2982
|
-
var ResizableMode;
|
|
2983
|
-
(function (ResizableMode) {
|
|
2984
|
-
ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
|
|
2985
|
-
})(ResizableMode || (ResizableMode = {}));
|
|
2986
|
-
|
|
2987
3010
|
/**
|
|
2988
3011
|
* Default value of the default width of a diagram section.
|
|
2989
3012
|
* @private
|
|
@@ -3424,8 +3447,9 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
3424
3447
|
const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
|
|
3425
3448
|
if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
|
|
3426
3449
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
|
|
3427
|
-
|
|
3428
|
-
const
|
|
3450
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
3451
|
+
const labelWidth = 6 * (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
3452
|
+
const labelHeight = (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
3429
3453
|
let labelCoords;
|
|
3430
3454
|
switch (port.direction) {
|
|
3431
3455
|
case Side.Bottom:
|
|
@@ -3439,7 +3463,7 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
3439
3463
|
default:
|
|
3440
3464
|
labelCoords = port.coords;
|
|
3441
3465
|
}
|
|
3442
|
-
this.model.fields.new(port, labelCoords,
|
|
3466
|
+
this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
3443
3467
|
}
|
|
3444
3468
|
}
|
|
3445
3469
|
}
|
|
@@ -3447,7 +3471,8 @@ class DiagramSectionSet extends DiagramElementSet {
|
|
|
3447
3471
|
const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
|
|
3448
3472
|
if (sectionLabel) {
|
|
3449
3473
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
|
|
3450
|
-
|
|
3474
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
3475
|
+
this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
3451
3476
|
}
|
|
3452
3477
|
return section;
|
|
3453
3478
|
}
|
|
@@ -4352,8 +4377,9 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
4352
4377
|
const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
|
|
4353
4378
|
if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
|
|
4354
4379
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
|
|
4355
|
-
|
|
4356
|
-
const
|
|
4380
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
4381
|
+
const labelWidth = 6 * (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
4382
|
+
const labelHeight = (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
4357
4383
|
let labelCoords;
|
|
4358
4384
|
switch (port.direction) {
|
|
4359
4385
|
case Side.Bottom:
|
|
@@ -4367,20 +4393,21 @@ class DiagramNodeSet extends DiagramElementSet {
|
|
|
4367
4393
|
default:
|
|
4368
4394
|
labelCoords = port.coords;
|
|
4369
4395
|
}
|
|
4370
|
-
this.model.fields.new(port, labelCoords,
|
|
4396
|
+
this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4371
4397
|
}
|
|
4372
4398
|
}
|
|
4373
4399
|
}
|
|
4374
4400
|
// add node label
|
|
4375
4401
|
if (nodeType.label) {
|
|
4376
4402
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
|
|
4377
|
-
|
|
4403
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
4404
|
+
this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4378
4405
|
}
|
|
4379
4406
|
// add node decorators
|
|
4380
4407
|
if (nodeType.decorators.length > 0) {
|
|
4381
4408
|
for (let i = 0; i < nodeType.decorators.length; ++i) {
|
|
4382
4409
|
const decoratorConfig = nodeType.decorators[i];
|
|
4383
|
-
this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.
|
|
4410
|
+
this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.svg, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
|
|
4384
4411
|
}
|
|
4385
4412
|
}
|
|
4386
4413
|
node.valueSet.resetValues();
|
|
@@ -4552,6 +4579,183 @@ const getTopPadding = config => {
|
|
|
4552
4579
|
}
|
|
4553
4580
|
};
|
|
4554
4581
|
|
|
4582
|
+
/**
|
|
4583
|
+
* A foreign object which is inserted with arbitrary SVG code into a diagram.
|
|
4584
|
+
* Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
|
|
4585
|
+
* Diagram decorators are not serialized with other diagram elements.
|
|
4586
|
+
* @public
|
|
4587
|
+
* @see DiagramNode
|
|
4588
|
+
* @see DiagramObject
|
|
4589
|
+
* @see DiagramSection
|
|
4590
|
+
*/
|
|
4591
|
+
class DiagramDecorator extends DiagramElement {
|
|
4592
|
+
constructor(model, rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
|
|
4593
|
+
if (model.objects.get(id) !== undefined) {
|
|
4594
|
+
throw new Error(`DiagramDecorator with id "${id}" already exists`);
|
|
4595
|
+
}
|
|
4596
|
+
if (!id) {
|
|
4597
|
+
throw new Error(`DiagramDecorator cannot have an empty or null id`);
|
|
4598
|
+
}
|
|
4599
|
+
super(model, id);
|
|
4600
|
+
this.rootElement = rootElement;
|
|
4601
|
+
this.coords = coords;
|
|
4602
|
+
this.width = width;
|
|
4603
|
+
this.height = height;
|
|
4604
|
+
this.priority = priority;
|
|
4605
|
+
this.svg = svg;
|
|
4606
|
+
this.anchorPointX = anchorPointX;
|
|
4607
|
+
this.anchorPointY = anchorPointY;
|
|
4608
|
+
}
|
|
4609
|
+
get removed() {
|
|
4610
|
+
return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
|
|
4611
|
+
}
|
|
4612
|
+
updateInView() {
|
|
4613
|
+
var _a;
|
|
4614
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
|
|
4615
|
+
}
|
|
4616
|
+
raise() {
|
|
4617
|
+
var _a;
|
|
4618
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
4619
|
+
}
|
|
4620
|
+
/**
|
|
4621
|
+
* Change the coordinates of this decorator to the given coordinates.
|
|
4622
|
+
* @public
|
|
4623
|
+
* @param coords A point in the diagram.
|
|
4624
|
+
*/
|
|
4625
|
+
move(coords) {
|
|
4626
|
+
this.coords = coords;
|
|
4627
|
+
this.updateInView();
|
|
4628
|
+
}
|
|
4629
|
+
getPriority() {
|
|
4630
|
+
return this.priority;
|
|
4631
|
+
}
|
|
4632
|
+
}
|
|
4633
|
+
class DiagramDecoratorSet extends DiagramElementSet {
|
|
4634
|
+
/**
|
|
4635
|
+
* Instance a set of decorators for the given model. This method is used internally.
|
|
4636
|
+
* @private
|
|
4637
|
+
*/
|
|
4638
|
+
constructor(model) {
|
|
4639
|
+
super();
|
|
4640
|
+
this.model = model;
|
|
4641
|
+
}
|
|
4642
|
+
/**
|
|
4643
|
+
* Instance a new decorator and add it to this set.
|
|
4644
|
+
* @public
|
|
4645
|
+
* @param coords The coordinates of the top left corner of the decorator in the diagram.
|
|
4646
|
+
* @param width The dimension of the decorator along the x axis.
|
|
4647
|
+
* @param height The dimension of the decorator along the y axis.
|
|
4648
|
+
* @param priority The priority of the decorator. Used when filtering by priority.
|
|
4649
|
+
* @param svg The SVG contents of the decorator.
|
|
4650
|
+
* @param id The id of the decorator. Cannot be an empty string.
|
|
4651
|
+
* @returns The instanced decorator.
|
|
4652
|
+
*/
|
|
4653
|
+
new(rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
|
|
4654
|
+
const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, svg, id, anchorPointX, anchorPointY);
|
|
4655
|
+
super.add(decorator);
|
|
4656
|
+
decorator.updateInView();
|
|
4657
|
+
// add this port to its root element
|
|
4658
|
+
if (rootElement !== undefined) {
|
|
4659
|
+
rootElement.decorators.push(decorator);
|
|
4660
|
+
}
|
|
4661
|
+
return decorator;
|
|
4662
|
+
}
|
|
4663
|
+
remove(id) {
|
|
4664
|
+
const decorator = this.get(id, true);
|
|
4665
|
+
if (decorator) {
|
|
4666
|
+
// remove from root element
|
|
4667
|
+
if (decorator.rootElement instanceof DiagramNode || decorator.rootElement instanceof DiagramSection) {
|
|
4668
|
+
removeIfExists(decorator.rootElement.decorators, decorator);
|
|
4669
|
+
}
|
|
4670
|
+
// remove from set of objects
|
|
4671
|
+
super.remove(id);
|
|
4672
|
+
// remove from canvas
|
|
4673
|
+
decorator.updateInView();
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
|
|
4678
|
+
/**
|
|
4679
|
+
* A foreign object which is inserted with arbitrary SVG code into a diagram.
|
|
4680
|
+
* Diagram objects are not serialized with other diagram elements.
|
|
4681
|
+
* @public
|
|
4682
|
+
*/
|
|
4683
|
+
class DiagramObject extends DiagramElement {
|
|
4684
|
+
constructor(model, coords, width, height, priority, svg, id) {
|
|
4685
|
+
if (model.objects.get(id) !== undefined) {
|
|
4686
|
+
throw new Error(`DiagramObject with id "${id}" already exists`);
|
|
4687
|
+
}
|
|
4688
|
+
if (!id) {
|
|
4689
|
+
throw new Error(`DiagramObject cannot have an empty or null id`);
|
|
4690
|
+
}
|
|
4691
|
+
super(model, id);
|
|
4692
|
+
this.coords = coords;
|
|
4693
|
+
this.width = width;
|
|
4694
|
+
this.height = height;
|
|
4695
|
+
this.priority = priority;
|
|
4696
|
+
this.svg = svg;
|
|
4697
|
+
}
|
|
4698
|
+
get removed() {
|
|
4699
|
+
return this.selfRemoved;
|
|
4700
|
+
}
|
|
4701
|
+
updateInView() {
|
|
4702
|
+
var _a;
|
|
4703
|
+
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
|
|
4704
|
+
}
|
|
4705
|
+
raise() {
|
|
4706
|
+
var _a;
|
|
4707
|
+
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
4708
|
+
}
|
|
4709
|
+
/**
|
|
4710
|
+
* Change the coordinates of this object to the given coordinates.
|
|
4711
|
+
* @public
|
|
4712
|
+
* @param coords A point in the diagram.
|
|
4713
|
+
*/
|
|
4714
|
+
move(coords) {
|
|
4715
|
+
this.coords = coords;
|
|
4716
|
+
this.updateInView();
|
|
4717
|
+
}
|
|
4718
|
+
getPriority() {
|
|
4719
|
+
return this.priority;
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
class DiagramObjectSet extends DiagramElementSet {
|
|
4723
|
+
/**
|
|
4724
|
+
* Instance a set of objects for the given model. This method is used internally.
|
|
4725
|
+
* @private
|
|
4726
|
+
*/
|
|
4727
|
+
constructor(model) {
|
|
4728
|
+
super();
|
|
4729
|
+
this.model = model;
|
|
4730
|
+
}
|
|
4731
|
+
/**
|
|
4732
|
+
* Instance a new object and add it to this set.
|
|
4733
|
+
* @public
|
|
4734
|
+
* @param coords The coordinates of the top left corner of the object in the diagram.
|
|
4735
|
+
* @param width The dimension of the object along the x axis.
|
|
4736
|
+
* @param height The dimension of the object along the y axis.
|
|
4737
|
+
* @param priority The priority of the object. Used when filtering by priority.
|
|
4738
|
+
* @param svg The SVG contents of the object.
|
|
4739
|
+
* @param id The id of the object. Cannot be an empty string.
|
|
4740
|
+
* @returns The instanced object.
|
|
4741
|
+
*/
|
|
4742
|
+
new(coords, width, height, priority, svg, id) {
|
|
4743
|
+
const object = new DiagramObject(this.model, coords, width, height, priority, svg, id);
|
|
4744
|
+
super.add(object);
|
|
4745
|
+
object.updateInView();
|
|
4746
|
+
return object;
|
|
4747
|
+
}
|
|
4748
|
+
remove(id) {
|
|
4749
|
+
const object = this.get(id, true);
|
|
4750
|
+
if (object) {
|
|
4751
|
+
// remove from set of objects
|
|
4752
|
+
super.remove(id);
|
|
4753
|
+
// remove from canvas
|
|
4754
|
+
object.updateInView();
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
}
|
|
4758
|
+
|
|
4555
4759
|
/**
|
|
4556
4760
|
* Default values of the look of a diagram port.
|
|
4557
4761
|
* @private
|
|
@@ -4917,6 +5121,14 @@ class DagaImporter {
|
|
|
4917
5121
|
for (const connection of data.connections || []) {
|
|
4918
5122
|
this.importConnection(model, connection);
|
|
4919
5123
|
}
|
|
5124
|
+
for (const object of data.objects || []) {
|
|
5125
|
+
const newObject = new DiagramObject(model, object.coords, object.width, object.height, object.priority, object.svg, object.id);
|
|
5126
|
+
if (object.collabMeta) {
|
|
5127
|
+
newObject.selfRemoved = object.collabMeta.selfRemoved;
|
|
5128
|
+
}
|
|
5129
|
+
model.objects.add(newObject);
|
|
5130
|
+
newObject.updateInView();
|
|
5131
|
+
}
|
|
4920
5132
|
if (data.data) {
|
|
4921
5133
|
model.valueSet.setValues(data.data);
|
|
4922
5134
|
}
|
|
@@ -4934,17 +5146,11 @@ class DagaImporter {
|
|
|
4934
5146
|
model.nodes.add(newNode);
|
|
4935
5147
|
newNode.width = node.width;
|
|
4936
5148
|
newNode.height = node.height;
|
|
4937
|
-
// add node decorators
|
|
4938
|
-
if (newNodeType.decorators) {
|
|
4939
|
-
for (let i = 0; i < newNodeType.decorators.length; ++i) {
|
|
4940
|
-
const decoratorConfig = newNodeType.decorators[i];
|
|
4941
|
-
model.decorators.new(newNode, [newNode.coords[0] + decoratorConfig.coords[0], newNode.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, newNode.getPriority(), decoratorConfig.html, `${newNode.id}_decorator_${i}`);
|
|
4942
|
-
}
|
|
4943
|
-
}
|
|
4944
5149
|
// add node label
|
|
4945
5150
|
if (newNodeType.label) {
|
|
4946
5151
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
|
|
4947
|
-
|
|
5152
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
5153
|
+
const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4948
5154
|
newField.text = node.label;
|
|
4949
5155
|
newNode.label = newField;
|
|
4950
5156
|
model.fields.add(newField);
|
|
@@ -4964,7 +5170,8 @@ class DagaImporter {
|
|
|
4964
5170
|
// add section label
|
|
4965
5171
|
if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
|
|
4966
5172
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
|
|
4967
|
-
|
|
5173
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
5174
|
+
const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4968
5175
|
newField.text = section.label;
|
|
4969
5176
|
newSection.label = newField;
|
|
4970
5177
|
model.fields.add(newField);
|
|
@@ -4980,22 +5187,23 @@ class DagaImporter {
|
|
|
4980
5187
|
// add port label
|
|
4981
5188
|
if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
|
|
4982
5189
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
|
|
5190
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
4983
5191
|
let labelCoords;
|
|
4984
5192
|
switch (newPort.direction) {
|
|
4985
5193
|
case Side.Top:
|
|
4986
5194
|
case Side.Left:
|
|
4987
|
-
labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
|
|
5195
|
+
labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
|
|
4988
5196
|
break;
|
|
4989
5197
|
case Side.Bottom:
|
|
4990
|
-
labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] + labelConfiguration.fontSize];
|
|
5198
|
+
labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
|
|
4991
5199
|
break;
|
|
4992
5200
|
case Side.Right:
|
|
4993
|
-
labelCoords = [newPort.coords[0] + labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
|
|
5201
|
+
labelCoords = [newPort.coords[0] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
|
|
4994
5202
|
break;
|
|
4995
5203
|
default:
|
|
4996
5204
|
labelCoords = newPort.coords;
|
|
4997
5205
|
}
|
|
4998
|
-
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize
|
|
5206
|
+
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
4999
5207
|
newField.text = port.label;
|
|
5000
5208
|
newPort.label = newField;
|
|
5001
5209
|
model.fields.add(newField);
|
|
@@ -5010,6 +5218,15 @@ class DagaImporter {
|
|
|
5010
5218
|
}
|
|
5011
5219
|
newPort.updateInView();
|
|
5012
5220
|
}
|
|
5221
|
+
for (const decorator of section.decorators || []) {
|
|
5222
|
+
const newDecorator = new DiagramDecorator(model, newSection, decorator.coords, decorator.width, decorator.height, decorator.priority, decorator.svg, decorator.id, decorator.anchorPoints[0], decorator.anchorPoints[1]);
|
|
5223
|
+
if (decorator.collabMeta) {
|
|
5224
|
+
newDecorator.selfRemoved = decorator.collabMeta.selfRemoved;
|
|
5225
|
+
}
|
|
5226
|
+
newNode.decorators.push(newDecorator);
|
|
5227
|
+
model.decorators.add(newDecorator);
|
|
5228
|
+
newDecorator.updateInView();
|
|
5229
|
+
}
|
|
5013
5230
|
if (section.collabMeta) {
|
|
5014
5231
|
newSection.selfRemoved = section.collabMeta.selfRemoved;
|
|
5015
5232
|
newSection.selfRemovedTimestamp = section.collabMeta.selfRemovedTimestamp;
|
|
@@ -5027,22 +5244,23 @@ class DagaImporter {
|
|
|
5027
5244
|
// add port label
|
|
5028
5245
|
if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
|
|
5029
5246
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
|
|
5247
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
5030
5248
|
let labelCoords;
|
|
5031
5249
|
switch (newPort.direction) {
|
|
5032
5250
|
case Side.Top:
|
|
5033
5251
|
case Side.Left:
|
|
5034
|
-
labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
|
|
5252
|
+
labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
|
|
5035
5253
|
break;
|
|
5036
5254
|
case Side.Bottom:
|
|
5037
|
-
labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] + labelConfiguration.fontSize];
|
|
5255
|
+
labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
|
|
5038
5256
|
break;
|
|
5039
5257
|
case Side.Right:
|
|
5040
|
-
labelCoords = [newPort.coords[0] + labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
|
|
5258
|
+
labelCoords = [newPort.coords[0] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
|
|
5041
5259
|
break;
|
|
5042
5260
|
default:
|
|
5043
5261
|
labelCoords = newPort.coords;
|
|
5044
5262
|
}
|
|
5045
|
-
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize
|
|
5263
|
+
const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
|
|
5046
5264
|
newField.text = port.label;
|
|
5047
5265
|
newPort.label = newField;
|
|
5048
5266
|
model.fields.add(newField);
|
|
@@ -5057,6 +5275,15 @@ class DagaImporter {
|
|
|
5057
5275
|
}
|
|
5058
5276
|
newPort.updateInView();
|
|
5059
5277
|
}
|
|
5278
|
+
for (const decorator of node.decorators || []) {
|
|
5279
|
+
const newDecorator = new DiagramDecorator(model, newNode, decorator.coords, decorator.width, decorator.height, decorator.priority, decorator.svg, decorator.id, decorator.anchorPoints[0], decorator.anchorPoints[1]);
|
|
5280
|
+
if (decorator.collabMeta) {
|
|
5281
|
+
newDecorator.selfRemoved = decorator.collabMeta.selfRemoved;
|
|
5282
|
+
}
|
|
5283
|
+
newNode.decorators.push(newDecorator);
|
|
5284
|
+
model.decorators.add(newDecorator);
|
|
5285
|
+
newDecorator.updateInView();
|
|
5286
|
+
}
|
|
5060
5287
|
if (node.data) {
|
|
5061
5288
|
newNode.valueSet.setValues(node.data);
|
|
5062
5289
|
}
|
|
@@ -6348,7 +6575,8 @@ class DiagramZoomEvent extends DiagramEvent {
|
|
|
6348
6575
|
/**
|
|
6349
6576
|
* Create a diagram zoom event.
|
|
6350
6577
|
*
|
|
6351
|
-
* @param coords .
|
|
6578
|
+
* @param coords Coordinates to which the user panned. Calling the method `canvas.translateTo()` with these coordinates after this event should cause no changes.
|
|
6579
|
+
* @param zoom Zoom level to which the user zoomed. Calling the method `canvas.zoomTo()` with this zoom level after this event should cause no changes.
|
|
6352
6580
|
*/
|
|
6353
6581
|
constructor(coords, zoom) {
|
|
6354
6582
|
super(DiagramEvents.Zoom);
|
|
@@ -6438,183 +6666,6 @@ class DiagramDraggingNodeEvent extends DiagramEvent {
|
|
|
6438
6666
|
}
|
|
6439
6667
|
}
|
|
6440
6668
|
|
|
6441
|
-
/**
|
|
6442
|
-
* A foreign object which is inserted with arbitrary html into a diagram.
|
|
6443
|
-
* Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
|
|
6444
|
-
* Diagram decorators are not serialized with other diagram elements.
|
|
6445
|
-
* @public
|
|
6446
|
-
* @see DiagramNode
|
|
6447
|
-
* @see DiagramObject
|
|
6448
|
-
* @see DiagramSection
|
|
6449
|
-
*/
|
|
6450
|
-
class DiagramDecorator extends DiagramElement {
|
|
6451
|
-
constructor(model, rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
|
|
6452
|
-
if (model.objects.get(id) !== undefined) {
|
|
6453
|
-
throw new Error(`DiagramDecorator with id "${id}" already exists`);
|
|
6454
|
-
}
|
|
6455
|
-
if (!id) {
|
|
6456
|
-
throw new Error(`DiagramDecorator cannot have an empty or null id`);
|
|
6457
|
-
}
|
|
6458
|
-
super(model, id);
|
|
6459
|
-
this.rootElement = rootElement;
|
|
6460
|
-
this.coords = coords;
|
|
6461
|
-
this.width = width;
|
|
6462
|
-
this.height = height;
|
|
6463
|
-
this.priority = priority;
|
|
6464
|
-
this.html = html;
|
|
6465
|
-
this.anchorPointX = anchorPointX;
|
|
6466
|
-
this.anchorPointY = anchorPointY;
|
|
6467
|
-
}
|
|
6468
|
-
get removed() {
|
|
6469
|
-
return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
|
|
6470
|
-
}
|
|
6471
|
-
updateInView() {
|
|
6472
|
-
var _a;
|
|
6473
|
-
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
|
|
6474
|
-
}
|
|
6475
|
-
raise() {
|
|
6476
|
-
var _a;
|
|
6477
|
-
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
6478
|
-
}
|
|
6479
|
-
/**
|
|
6480
|
-
* Change the coordinates of this decorator to the given coordinates.
|
|
6481
|
-
* @public
|
|
6482
|
-
* @param coords A point in the diagram.
|
|
6483
|
-
*/
|
|
6484
|
-
move(coords) {
|
|
6485
|
-
this.coords = coords;
|
|
6486
|
-
this.updateInView();
|
|
6487
|
-
}
|
|
6488
|
-
getPriority() {
|
|
6489
|
-
return this.priority;
|
|
6490
|
-
}
|
|
6491
|
-
}
|
|
6492
|
-
class DiagramDecoratorSet extends DiagramElementSet {
|
|
6493
|
-
/**
|
|
6494
|
-
* Instance a set of decorators for the given model. This method is used internally.
|
|
6495
|
-
* @private
|
|
6496
|
-
*/
|
|
6497
|
-
constructor(model) {
|
|
6498
|
-
super();
|
|
6499
|
-
this.model = model;
|
|
6500
|
-
}
|
|
6501
|
-
/**
|
|
6502
|
-
* Instance a new decorator and add it to this set.
|
|
6503
|
-
* @public
|
|
6504
|
-
* @param coords The coordinates of the top left corner of the decorator in the diagram.
|
|
6505
|
-
* @param width The dimension of the decorator along the x axis.
|
|
6506
|
-
* @param height The dimension of the decorator along the y axis.
|
|
6507
|
-
* @param priority The priority of the decorator. Used when filtering by priority.
|
|
6508
|
-
* @param html The html contents of the decorator.
|
|
6509
|
-
* @param id The id of the decorator. Cannot be an empty string.
|
|
6510
|
-
* @returns The instanced decorator.
|
|
6511
|
-
*/
|
|
6512
|
-
new(rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
|
|
6513
|
-
const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id, anchorPointX, anchorPointY);
|
|
6514
|
-
super.add(decorator);
|
|
6515
|
-
decorator.updateInView();
|
|
6516
|
-
// add this port to its root element
|
|
6517
|
-
if (rootElement !== undefined) {
|
|
6518
|
-
rootElement.decorators.push(decorator);
|
|
6519
|
-
}
|
|
6520
|
-
return decorator;
|
|
6521
|
-
}
|
|
6522
|
-
remove(id) {
|
|
6523
|
-
const decorator = this.get(id, true);
|
|
6524
|
-
if (decorator) {
|
|
6525
|
-
// remove from root element
|
|
6526
|
-
if (decorator.rootElement instanceof DiagramNode || decorator.rootElement instanceof DiagramSection) {
|
|
6527
|
-
removeIfExists(decorator.rootElement.decorators, decorator);
|
|
6528
|
-
}
|
|
6529
|
-
// remove from set of objects
|
|
6530
|
-
super.remove(id);
|
|
6531
|
-
// remove from canvas
|
|
6532
|
-
decorator.updateInView();
|
|
6533
|
-
}
|
|
6534
|
-
}
|
|
6535
|
-
}
|
|
6536
|
-
|
|
6537
|
-
/**
|
|
6538
|
-
* A foreign object which is inserted with arbitrary html into a diagram.
|
|
6539
|
-
* Diagram objects are not serialized with other diagram elements.
|
|
6540
|
-
* @public
|
|
6541
|
-
*/
|
|
6542
|
-
class DiagramObject extends DiagramElement {
|
|
6543
|
-
constructor(model, coords, width, height, priority, html, id) {
|
|
6544
|
-
if (model.objects.get(id) !== undefined) {
|
|
6545
|
-
throw new Error(`DiagramObject with id "${id}" already exists`);
|
|
6546
|
-
}
|
|
6547
|
-
if (!id) {
|
|
6548
|
-
throw new Error(`DiagramObject cannot have an empty or null id`);
|
|
6549
|
-
}
|
|
6550
|
-
super(model, id);
|
|
6551
|
-
this.coords = coords;
|
|
6552
|
-
this.width = width;
|
|
6553
|
-
this.height = height;
|
|
6554
|
-
this.priority = priority;
|
|
6555
|
-
this.html = html;
|
|
6556
|
-
}
|
|
6557
|
-
get removed() {
|
|
6558
|
-
return this.selfRemoved;
|
|
6559
|
-
}
|
|
6560
|
-
updateInView() {
|
|
6561
|
-
var _a;
|
|
6562
|
-
(_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
|
|
6563
|
-
}
|
|
6564
|
-
raise() {
|
|
6565
|
-
var _a;
|
|
6566
|
-
(_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
|
|
6567
|
-
}
|
|
6568
|
-
/**
|
|
6569
|
-
* Change the coordinates of this object to the given coordinates.
|
|
6570
|
-
* @public
|
|
6571
|
-
* @param coords A point in the diagram.
|
|
6572
|
-
*/
|
|
6573
|
-
move(coords) {
|
|
6574
|
-
this.coords = coords;
|
|
6575
|
-
this.updateInView();
|
|
6576
|
-
}
|
|
6577
|
-
getPriority() {
|
|
6578
|
-
return this.priority;
|
|
6579
|
-
}
|
|
6580
|
-
}
|
|
6581
|
-
class DiagramObjectSet extends DiagramElementSet {
|
|
6582
|
-
/**
|
|
6583
|
-
* Instance a set of objects for the given model. This method is used internally.
|
|
6584
|
-
* @private
|
|
6585
|
-
*/
|
|
6586
|
-
constructor(model) {
|
|
6587
|
-
super();
|
|
6588
|
-
this.model = model;
|
|
6589
|
-
}
|
|
6590
|
-
/**
|
|
6591
|
-
* Instance a new object and add it to this set.
|
|
6592
|
-
* @public
|
|
6593
|
-
* @param coords The coordinates of the top left corner of the object in the diagram.
|
|
6594
|
-
* @param width The dimension of the object along the x axis.
|
|
6595
|
-
* @param height The dimension of the object along the y axis.
|
|
6596
|
-
* @param priority The priority of the object. Used when filtering by priority.
|
|
6597
|
-
* @param html The html contents of the object.
|
|
6598
|
-
* @param id The id of the object. Cannot be an empty string.
|
|
6599
|
-
* @returns The instanced object.
|
|
6600
|
-
*/
|
|
6601
|
-
new(coords, width, height, priority, html, id) {
|
|
6602
|
-
const object = new DiagramObject(this.model, coords, width, height, priority, html, id);
|
|
6603
|
-
super.add(object);
|
|
6604
|
-
object.updateInView();
|
|
6605
|
-
return object;
|
|
6606
|
-
}
|
|
6607
|
-
remove(id) {
|
|
6608
|
-
const object = this.get(id, true);
|
|
6609
|
-
if (object) {
|
|
6610
|
-
// remove from set of objects
|
|
6611
|
-
super.remove(id);
|
|
6612
|
-
// remove from canvas
|
|
6613
|
-
object.updateInView();
|
|
6614
|
-
}
|
|
6615
|
-
}
|
|
6616
|
-
}
|
|
6617
|
-
|
|
6618
6669
|
/**
|
|
6619
6670
|
* Stores the data of a diagram.
|
|
6620
6671
|
* Represents the state of the diagram.
|
|
@@ -6716,7 +6767,7 @@ const isSecondaryButton = event => {
|
|
|
6716
6767
|
const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, points, width, startMarkerWidth, endMarkerWidth) => {
|
|
6717
6768
|
return linePath(shape, [startCoords, ...points, endCoords], startDirection, endDirection, Math.max(
|
|
6718
6769
|
// reasonable value for the minimumDistanceBeforeTurn relative to the line width
|
|
6719
|
-
10, startMarkerWidth
|
|
6770
|
+
10, startMarkerWidth !== null && startMarkerWidth !== void 0 ? startMarkerWidth : 0, endMarkerWidth !== null && endMarkerWidth !== void 0 ? endMarkerWidth : 0) * width);
|
|
6720
6771
|
};
|
|
6721
6772
|
const setCursorStyle = style => {
|
|
6722
6773
|
if (!style) {
|
|
@@ -6726,11 +6777,12 @@ const setCursorStyle = style => {
|
|
|
6726
6777
|
}
|
|
6727
6778
|
};
|
|
6728
6779
|
const getRelatedNodeOrItself = element => {
|
|
6780
|
+
var _a;
|
|
6729
6781
|
if (element instanceof DiagramNode) {
|
|
6730
6782
|
return element;
|
|
6731
6783
|
}
|
|
6732
6784
|
if (element instanceof DiagramSection) {
|
|
6733
|
-
return element.node
|
|
6785
|
+
return (_a = element.node) !== null && _a !== void 0 ? _a : element;
|
|
6734
6786
|
}
|
|
6735
6787
|
return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
|
|
6736
6788
|
};
|
|
@@ -6782,9 +6834,21 @@ const SHAPED_LOOK_DEFAULTS = {
|
|
|
6782
6834
|
borderStyle: LineStyle.Solid
|
|
6783
6835
|
};
|
|
6784
6836
|
const updateLook = selection => {
|
|
6785
|
-
selection.filter('.shaped-look').select('path').attr('d', d =>
|
|
6786
|
-
var _a
|
|
6787
|
-
return
|
|
6837
|
+
selection.filter('.shaped-look').select('path').attr('d', d => {
|
|
6838
|
+
var _a;
|
|
6839
|
+
return generalClosedPath((_a = d.look.shape) !== null && _a !== void 0 ? _a : ClosedShape.Rectangle, 0, 0, d.width, d.height);
|
|
6840
|
+
}).attr('fill', d => {
|
|
6841
|
+
var _a;
|
|
6842
|
+
return (_a = d.look.fillColor) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.fillColor;
|
|
6843
|
+
}).attr('stroke', d => {
|
|
6844
|
+
var _a;
|
|
6845
|
+
return (_a = d.look.borderColor) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderColor;
|
|
6846
|
+
}).attr('stroke-width', d => {
|
|
6847
|
+
var _a;
|
|
6848
|
+
return `${(_a = d.look.borderThickness) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderThickness}px`;
|
|
6849
|
+
}).attr('stroke-dasharray', d => {
|
|
6850
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6851
|
+
return lineStyleDasharray((_a = d.look.borderStyle) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderStyle, (_f = (_d = (_c = (_b = d.type) === null || _b === void 0 ? void 0 : _b.defaultLook) === null || _c === void 0 ? void 0 : _c.borderThickness) !== null && _d !== void 0 ? _d : (_e = d.look) === null || _e === void 0 ? void 0 : _e.borderThickness) !== null && _f !== void 0 ? _f : SHAPED_LOOK_DEFAULTS.borderThickness);
|
|
6788
6852
|
});
|
|
6789
6853
|
selection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => d.look.backgroundImage);
|
|
6790
6854
|
selection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTopLeft);
|
|
@@ -6797,30 +6861,91 @@ const updateLook = selection => {
|
|
|
6797
6861
|
selection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => d.look.leftMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottom);
|
|
6798
6862
|
selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
|
|
6799
6863
|
};
|
|
6864
|
+
const BACKGROUND_DEFAULTS = {
|
|
6865
|
+
style: 'solid',
|
|
6866
|
+
color: '#FFFFFF'
|
|
6867
|
+
};
|
|
6800
6868
|
const GRID_DEFAULTS = {
|
|
6869
|
+
enabled: true,
|
|
6870
|
+
style: 'none',
|
|
6871
|
+
snap: false,
|
|
6872
|
+
spacing: 1
|
|
6873
|
+
};
|
|
6874
|
+
const DOTS_GRID_DEFAULTS = Object.assign(Object.assign({}, GRID_DEFAULTS), {
|
|
6801
6875
|
style: 'dots',
|
|
6802
|
-
color: 'rgba(0, 0, 0, 0.1)',
|
|
6803
6876
|
snap: false,
|
|
6804
6877
|
spacing: 10,
|
|
6805
|
-
thickness: 0.05
|
|
6878
|
+
thickness: 0.05,
|
|
6879
|
+
color: 'rgba(0, 0, 0, 0.1)'
|
|
6880
|
+
});
|
|
6881
|
+
const initializeBackground = (canvas, canvasView, backgroundConfig) => {
|
|
6882
|
+
var _a, _b;
|
|
6883
|
+
switch ((_a = backgroundConfig === null || backgroundConfig === void 0 ? void 0 : backgroundConfig.style) !== null && _a !== void 0 ? _a : '') {
|
|
6884
|
+
case 'image':
|
|
6885
|
+
return canvasView.append('image').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('href', backgroundConfig.image).attr('preserveAspectRatio', 'none');
|
|
6886
|
+
case 'solid':
|
|
6887
|
+
default:
|
|
6888
|
+
return canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', (_b = backgroundConfig.color) !== null && _b !== void 0 ? _b : '#FFFFFF').attr('stroke-width', '0');
|
|
6889
|
+
}
|
|
6890
|
+
};
|
|
6891
|
+
const applyGridDefaults = gridConfig => {
|
|
6892
|
+
if (!gridConfig) {
|
|
6893
|
+
return DOTS_GRID_DEFAULTS;
|
|
6894
|
+
}
|
|
6895
|
+
switch (gridConfig.style) {
|
|
6896
|
+
case 'dots':
|
|
6897
|
+
case 'lines':
|
|
6898
|
+
// lines has the same parameters as dots
|
|
6899
|
+
return Object.assign(Object.assign({}, DOTS_GRID_DEFAULTS), gridConfig);
|
|
6900
|
+
default:
|
|
6901
|
+
return Object.assign(Object.assign({}, GRID_DEFAULTS), gridConfig);
|
|
6902
|
+
}
|
|
6806
6903
|
};
|
|
6807
|
-
const initializeGrid = (canvas, canvasView,
|
|
6808
|
-
|
|
6809
|
-
if (
|
|
6810
|
-
const canvasBackgroundPattern = canvasDefs.append('pattern').attr('id',
|
|
6811
|
-
canvasBackgroundPattern.append('rect').attr('x', 0).attr('y', 0).attr('width',
|
|
6812
|
-
switch (
|
|
6904
|
+
const initializeGrid = (canvas, canvasView, canvasDefs, gridPatternId, gridConfig) => {
|
|
6905
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
6906
|
+
if (getGridSpacingX(gridConfig) !== 0 && getGridSpacingY(gridConfig) !== 0) {
|
|
6907
|
+
const canvasBackgroundPattern = canvasDefs.append('pattern').attr('id', gridPatternId).attr('x', -getGridSpacingX(gridConfig) / 2).attr('y', -getGridSpacingY(gridConfig) / 2).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('patternUnits', 'userSpaceOnUse');
|
|
6908
|
+
canvasBackgroundPattern.append('rect').attr('x', 0).attr('y', 0).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('fill', 'transparent');
|
|
6909
|
+
switch (gridConfig.style) {
|
|
6813
6910
|
case 'dots':
|
|
6814
|
-
canvasBackgroundPattern.append('circle').attr('cx',
|
|
6911
|
+
canvasBackgroundPattern.append('circle').attr('cx', getGridSpacingX(gridConfig) / 2).attr('cy', getGridSpacingY(gridConfig) / 2).attr('r', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_a = gridConfig.thickness) !== null && _a !== void 0 ? _a : 0)).attr('fill', (_b = gridConfig.color) !== null && _b !== void 0 ? _b : '');
|
|
6815
6912
|
break;
|
|
6816
6913
|
case 'lines':
|
|
6817
|
-
canvasBackgroundPattern.append('line').attr('x1',
|
|
6818
|
-
canvasBackgroundPattern.append('line').attr('x1', 0).attr('x2', (
|
|
6819
|
-
canvasBackgroundPattern.append('line').attr('x1', (
|
|
6914
|
+
canvasBackgroundPattern.append('line').attr('x1', getGridSpacingX(gridConfig) / 2).attr('x2', getGridSpacingX(gridConfig) / 2).attr('y1', 0).attr('y2', getGridSpacingY(gridConfig)).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_c = gridConfig.thickness) !== null && _c !== void 0 ? _c : 0)).attr('stroke', (_d = gridConfig.color) !== null && _d !== void 0 ? _d : '');
|
|
6915
|
+
canvasBackgroundPattern.append('line').attr('x1', 0).attr('x2', (getGridSpacingX(gridConfig) - getGridSpacingX(gridConfig) * ((_e = gridConfig.thickness) !== null && _e !== void 0 ? _e : 0)) / 2).attr('y1', getGridSpacingY(gridConfig) / 2).attr('y2', getGridSpacingY(gridConfig) / 2).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_f = gridConfig.thickness) !== null && _f !== void 0 ? _f : 0)).attr('stroke', (_g = gridConfig.color) !== null && _g !== void 0 ? _g : '');
|
|
6916
|
+
canvasBackgroundPattern.append('line').attr('x1', (getGridSpacingX(gridConfig) + getGridSpacingX(gridConfig) * ((_h = gridConfig.thickness) !== null && _h !== void 0 ? _h : 0)) / 2).attr('x2', getGridSpacingX(gridConfig)).attr('y1', getGridSpacingY(gridConfig) / 2).attr('y2', getGridSpacingY(gridConfig) / 2).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_j = gridConfig.thickness) !== null && _j !== void 0 ? _j : 0)).attr('stroke', (_k = gridConfig.color) !== null && _k !== void 0 ? _k : '');
|
|
6917
|
+
break;
|
|
6918
|
+
case 'image':
|
|
6919
|
+
canvasBackgroundPattern.append('image').attr('x', 0).attr('y', 0).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('href', gridConfig.image).attr('preserveAspectRatio', 'none');
|
|
6820
6920
|
break;
|
|
6821
6921
|
}
|
|
6822
|
-
canvasView.
|
|
6922
|
+
return canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', `url(#${gridPatternId})`).attr('stroke-width', '0');
|
|
6923
|
+
}
|
|
6924
|
+
return undefined;
|
|
6925
|
+
};
|
|
6926
|
+
const getGridSpacingX = gridConfig => {
|
|
6927
|
+
let value = 0;
|
|
6928
|
+
if (typeof gridConfig.spacing === 'number') {
|
|
6929
|
+
value = gridConfig.spacing;
|
|
6930
|
+
} else if (Array.isArray(gridConfig.spacing) && typeof gridConfig.spacing[0] === 'number') {
|
|
6931
|
+
value = gridConfig.spacing[0];
|
|
6823
6932
|
}
|
|
6933
|
+
if (!isFinite(value)) {
|
|
6934
|
+
return 0;
|
|
6935
|
+
}
|
|
6936
|
+
return value;
|
|
6937
|
+
};
|
|
6938
|
+
const getGridSpacingY = gridConfig => {
|
|
6939
|
+
let value = 0;
|
|
6940
|
+
if (typeof gridConfig.spacing === 'number') {
|
|
6941
|
+
value = gridConfig.spacing;
|
|
6942
|
+
} else if (Array.isArray(gridConfig.spacing) && typeof gridConfig.spacing[1] === 'number') {
|
|
6943
|
+
value = gridConfig.spacing[1];
|
|
6944
|
+
}
|
|
6945
|
+
if (!isFinite(value)) {
|
|
6946
|
+
return 0;
|
|
6947
|
+
}
|
|
6948
|
+
return value;
|
|
6824
6949
|
};
|
|
6825
6950
|
|
|
6826
6951
|
const CONTEXT_MENU_MENU_RADIUS = 96;
|
|
@@ -7066,6 +7191,7 @@ const DAGA_FILE_VERSION = 1;
|
|
|
7066
7191
|
*/
|
|
7067
7192
|
class DagaExporter {
|
|
7068
7193
|
export(model, includeCollabMeta = false) {
|
|
7194
|
+
var _a;
|
|
7069
7195
|
const result = Object.assign({
|
|
7070
7196
|
name: model.name,
|
|
7071
7197
|
type: model.type,
|
|
@@ -7074,6 +7200,7 @@ class DagaExporter {
|
|
|
7074
7200
|
updatedAt: model.updatedAt,
|
|
7075
7201
|
nodes: [],
|
|
7076
7202
|
connections: [],
|
|
7203
|
+
objects: [],
|
|
7077
7204
|
data: model.valueSet.getValues()
|
|
7078
7205
|
}, includeCollabMeta ? {
|
|
7079
7206
|
collabMeta: {
|
|
@@ -7096,6 +7223,21 @@ class DagaExporter {
|
|
|
7096
7223
|
if (!includeCollabMeta && connection.removed) continue;
|
|
7097
7224
|
result.connections.push(this.exportConnection(connection, includeCollabMeta));
|
|
7098
7225
|
}
|
|
7226
|
+
for (const object of model.objects.all(true)) {
|
|
7227
|
+
(_a = result.objects) === null || _a === void 0 ? void 0 : _a.push(Object.assign({
|
|
7228
|
+
id: object.id,
|
|
7229
|
+
coords: roundPoint(object.coords),
|
|
7230
|
+
width: object.width,
|
|
7231
|
+
height: object.height,
|
|
7232
|
+
priority: object.priority,
|
|
7233
|
+
svg: object.svg
|
|
7234
|
+
}, includeCollabMeta ? {
|
|
7235
|
+
collabMeta: {
|
|
7236
|
+
removed: object.removed,
|
|
7237
|
+
selfRemoved: object.selfRemoved
|
|
7238
|
+
}
|
|
7239
|
+
} : {}));
|
|
7240
|
+
}
|
|
7099
7241
|
return result;
|
|
7100
7242
|
}
|
|
7101
7243
|
exportNode(node, includeCollabMeta = false) {
|
|
@@ -7123,9 +7265,27 @@ class DagaExporter {
|
|
|
7123
7265
|
}, this.exportLabelCollabMeta(port))
|
|
7124
7266
|
} : {}));
|
|
7125
7267
|
}
|
|
7268
|
+
const decorators = [];
|
|
7269
|
+
for (const decorator of section.decorators) {
|
|
7270
|
+
decorators.push(Object.assign({
|
|
7271
|
+
id: decorator.id,
|
|
7272
|
+
coords: roundPoint(decorator.coords),
|
|
7273
|
+
width: decorator.width,
|
|
7274
|
+
height: decorator.height,
|
|
7275
|
+
priority: decorator.priority,
|
|
7276
|
+
svg: decorator.svg,
|
|
7277
|
+
anchorPoints: [decorator.anchorPointX, decorator.anchorPointY]
|
|
7278
|
+
}, includeCollabMeta ? {
|
|
7279
|
+
collabMeta: {
|
|
7280
|
+
removed: decorator.removed,
|
|
7281
|
+
selfRemoved: decorator.selfRemoved
|
|
7282
|
+
}
|
|
7283
|
+
} : {}));
|
|
7284
|
+
}
|
|
7126
7285
|
sections.push(Object.assign({
|
|
7127
7286
|
id: section.id,
|
|
7128
7287
|
ports,
|
|
7288
|
+
decorators,
|
|
7129
7289
|
label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
|
|
7130
7290
|
indexXInNode: section.indexXInNode,
|
|
7131
7291
|
indexYInNode: section.indexYInNode,
|
|
@@ -7157,12 +7317,30 @@ class DagaExporter {
|
|
|
7157
7317
|
}, this.exportLabelCollabMeta(port))
|
|
7158
7318
|
} : {}));
|
|
7159
7319
|
}
|
|
7320
|
+
const decorators = [];
|
|
7321
|
+
for (const decorator of node.decorators) {
|
|
7322
|
+
decorators.push(Object.assign({
|
|
7323
|
+
id: decorator.id,
|
|
7324
|
+
coords: roundPoint(decorator.coords),
|
|
7325
|
+
width: decorator.width,
|
|
7326
|
+
height: decorator.height,
|
|
7327
|
+
priority: decorator.priority,
|
|
7328
|
+
svg: decorator.svg,
|
|
7329
|
+
anchorPoints: [decorator.anchorPointX, decorator.anchorPointY]
|
|
7330
|
+
}, includeCollabMeta ? {
|
|
7331
|
+
collabMeta: {
|
|
7332
|
+
removed: decorator.removed,
|
|
7333
|
+
selfRemoved: decorator.selfRemoved
|
|
7334
|
+
}
|
|
7335
|
+
} : {}));
|
|
7336
|
+
}
|
|
7160
7337
|
return Object.assign({
|
|
7161
7338
|
id: node.id,
|
|
7162
7339
|
type: node.type.id,
|
|
7163
7340
|
children,
|
|
7164
7341
|
sections,
|
|
7165
7342
|
ports,
|
|
7343
|
+
decorators,
|
|
7166
7344
|
label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
|
|
7167
7345
|
coords: roundPoint(node.coords),
|
|
7168
7346
|
width: node.width,
|
|
@@ -7505,8 +7683,9 @@ class DiagramCanvas {
|
|
|
7505
7683
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
7506
7684
|
*/
|
|
7507
7685
|
constructor(parentComponent, config) {
|
|
7508
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
7509
|
-
this.
|
|
7686
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
7687
|
+
this.gridPatternId = `daga-grid-pattern-id-${++DiagramCanvas.canvasCount}`;
|
|
7688
|
+
this.ancillaryGridPatternIds = [];
|
|
7510
7689
|
this.zoomTransform = d3.zoomIdentity;
|
|
7511
7690
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
7512
7691
|
this.draggingFrom = [0, 0];
|
|
@@ -7523,23 +7702,25 @@ class DiagramCanvas {
|
|
|
7523
7702
|
this.userSelection = new DiagramUserSelection(this, (_b = (_a = config.components) === null || _a === void 0 ? void 0 : _a.propertyEditor) === null || _b === void 0 ? void 0 : _b.title);
|
|
7524
7703
|
this.userHighlight = new DiagramUserHighlight(this, ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.highlightSections) !== false);
|
|
7525
7704
|
this.contextMenu = new DiagramContextMenu(this, (_d = config.canvas) === null || _d === void 0 ? void 0 : _d.contextMenu);
|
|
7526
|
-
|
|
7527
|
-
this.
|
|
7528
|
-
this.
|
|
7529
|
-
this.
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
this.
|
|
7535
|
-
this.
|
|
7536
|
-
this.
|
|
7537
|
-
this.
|
|
7538
|
-
this.
|
|
7539
|
-
this.
|
|
7540
|
-
this.
|
|
7705
|
+
// TODO
|
|
7706
|
+
this.backgroundConfig = (_f = (_e = config.canvas) === null || _e === void 0 ? void 0 : _e.background) !== null && _f !== void 0 ? _f : BACKGROUND_DEFAULTS;
|
|
7707
|
+
this.gridConfig = applyGridDefaults((_g = config.canvas) === null || _g === void 0 ? void 0 : _g.grid);
|
|
7708
|
+
this.ancillaryGridsConfig = [];
|
|
7709
|
+
for (let i = 0; i < (((_j = (_h = config.canvas) === null || _h === void 0 ? void 0 : _h.ancillaryGrids) === null || _j === void 0 ? void 0 : _j.length) || 0); ++i) {
|
|
7710
|
+
this.ancillaryGridsConfig.push(applyGridDefaults((_l = (_k = config.canvas) === null || _k === void 0 ? void 0 : _k.ancillaryGrids) === null || _l === void 0 ? void 0 : _l[i]));
|
|
7711
|
+
this.ancillaryGridPatternIds.push(`${this.gridPatternId}-ancillary-${i}`);
|
|
7712
|
+
}
|
|
7713
|
+
this.zoomFactor = ((_m = config.canvas) === null || _m === void 0 ? void 0 : _m.zoomFactor) || 2;
|
|
7714
|
+
this.panRate = ((_o = config.canvas) === null || _o === void 0 ? void 0 : _o.panRate) || 100;
|
|
7715
|
+
this.inferConnectionType = ((_p = config.connectionSettings) === null || _p === void 0 ? void 0 : _p.inferConnectionType) || false;
|
|
7716
|
+
this.autoTightenConnections = ((_q = config.connectionSettings) === null || _q === void 0 ? void 0 : _q.autoTighten) !== false;
|
|
7717
|
+
this.tightenConnectionsAcrossPortTypes = ((_r = config.connectionSettings) === null || _r === void 0 ? void 0 : _r.tightenAcrossPortTypes) || false;
|
|
7718
|
+
this.allowConnectionLoops = ((_s = config.connectionSettings) === null || _s === void 0 ? void 0 : _s.allowLoops) || false;
|
|
7719
|
+
this.allowSharingPorts = ((_t = config.connectionSettings) === null || _t === void 0 ? void 0 : _t.sharePorts) !== false;
|
|
7720
|
+
this.allowSharingBothPorts = ((_u = config.connectionSettings) === null || _u === void 0 ? void 0 : _u.shareBothPorts) || false;
|
|
7721
|
+
this.portHighlightRadius = ((_v = config.connectionSettings) === null || _v === void 0 ? void 0 : _v.portHighlightRadius) || 100;
|
|
7541
7722
|
this.multipleSelectionOn = false;
|
|
7542
|
-
this.priorityThresholds = ((
|
|
7723
|
+
this.priorityThresholds = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.priorityThresholds) || [];
|
|
7543
7724
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
7544
7725
|
this.layoutFormat = config.layoutFormat;
|
|
7545
7726
|
this.userActions = config.userActions || {};
|
|
@@ -7566,7 +7747,7 @@ class DiagramCanvas {
|
|
|
7566
7747
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
7567
7748
|
this.model.connections.types.add(connectionType);
|
|
7568
7749
|
}
|
|
7569
|
-
this._connectionType = ((
|
|
7750
|
+
this._connectionType = ((_x = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _x === void 0 ? void 0 : _x.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
|
|
7570
7751
|
}
|
|
7571
7752
|
}
|
|
7572
7753
|
addValidator(validator) {
|
|
@@ -7598,13 +7779,13 @@ class DiagramCanvas {
|
|
|
7598
7779
|
// remove all children
|
|
7599
7780
|
appendToSelection.html('');
|
|
7600
7781
|
this.diagramRoot = appendToSelection.append('div').node();
|
|
7601
|
-
|
|
7782
|
+
this.selectRoot().attr('tabindex', 0) // make element focusable
|
|
7602
7783
|
.style('width', '100%').style('height', '100%').append('svg').style('width', '100%').style('height', '100%');
|
|
7603
|
-
|
|
7784
|
+
this.selectRoot().on(Events.Click, () => {
|
|
7604
7785
|
var _a;
|
|
7605
7786
|
// focus on the diagram when clicking so that we can focus on the diagram
|
|
7606
7787
|
// keyboard events only work if we're focusing on the diagram
|
|
7607
|
-
(_a =
|
|
7788
|
+
(_a = this.selectRoot().node()) === null || _a === void 0 ? void 0 : _a.focus();
|
|
7608
7789
|
}).on(Events.ContextMenu, event => {
|
|
7609
7790
|
if (this.dragging) {
|
|
7610
7791
|
event.preventDefault();
|
|
@@ -7768,44 +7949,57 @@ class DiagramCanvas {
|
|
|
7768
7949
|
this.zoomTransform = event.transform;
|
|
7769
7950
|
const transformAttribute = event.transform.toString();
|
|
7770
7951
|
this.selectCanvasElements().attr('transform', transformAttribute);
|
|
7771
|
-
|
|
7952
|
+
for (const gridPatternId of [this.gridPatternId, ...this.ancillaryGridPatternIds]) {
|
|
7953
|
+
this.selectCanvasView().select(`#${gridPatternId}`).attr('patternTransform', transformAttribute);
|
|
7954
|
+
}
|
|
7772
7955
|
this.contextMenu.close();
|
|
7773
7956
|
this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
|
|
7774
7957
|
}).on(ZoomEvents.End, () => {
|
|
7775
7958
|
setCursorStyle();
|
|
7776
7959
|
}));
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
}
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7960
|
+
const canvasDefs = canvasView.append('defs');
|
|
7961
|
+
const canvasBackground = [];
|
|
7962
|
+
canvasBackground.push(initializeBackground(this, canvasView, this.backgroundConfig));
|
|
7963
|
+
for (let i = 0; i < this.ancillaryGridsConfig.length; ++i) {
|
|
7964
|
+
canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.ancillaryGridPatternIds[i], this.ancillaryGridsConfig[i]));
|
|
7965
|
+
}
|
|
7966
|
+
canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.gridPatternId, this.gridConfig));
|
|
7967
|
+
for (const canvasBackgroundElement of canvasBackground) {
|
|
7968
|
+
canvasBackgroundElement.on(Events.MouseMove, event => {
|
|
7969
|
+
if (this.unfinishedConnection !== undefined) {
|
|
7970
|
+
const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7971
|
+
this.unfinishedConnection.endCoords = pointerCoords;
|
|
7972
|
+
}
|
|
7973
|
+
});
|
|
7974
|
+
canvasBackgroundElement.on(Events.MouseOver, () => {
|
|
7975
|
+
if (this.userHighlight.size() > 0) {
|
|
7976
|
+
this.userHighlight.clear();
|
|
7977
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(null));
|
|
7978
|
+
}
|
|
7979
|
+
});
|
|
7980
|
+
canvasBackgroundElement.on(Events.Click, () => {
|
|
7981
|
+
if (this.userHighlight.size() > 0) {
|
|
7982
|
+
this.userHighlight.clear();
|
|
7983
|
+
this.diagramEvent$.next(new DiagramHighlightedEvent(null));
|
|
7984
|
+
}
|
|
7985
|
+
this.contextMenu.close();
|
|
7986
|
+
if (this.userSelection.size() > 0) {
|
|
7987
|
+
const deselectedElements = this.userSelection.all();
|
|
7988
|
+
this.userSelection.clear();
|
|
7989
|
+
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
7990
|
+
}
|
|
7991
|
+
this.userSelection.openInPropertyEditor(this.model);
|
|
7992
|
+
});
|
|
7993
|
+
canvasBackgroundElement.call(d3.drag().filter(event => {
|
|
7994
|
+
return this.multipleSelectionOn || isSecondaryButton(event);
|
|
7995
|
+
}).on(DragEvents.Start, event => {
|
|
7996
|
+
this.startMultipleSelection(event);
|
|
7997
|
+
}).on(DragEvents.Drag, event => {
|
|
7998
|
+
this.continueMultipleSelection(event);
|
|
7999
|
+
}).on(DragEvents.End, event => {
|
|
8000
|
+
this.finishMultipleSelection(event);
|
|
8001
|
+
}));
|
|
8002
|
+
}
|
|
7809
8003
|
canvasView.append('g').attr('class', 'daga-canvas-elements');
|
|
7810
8004
|
}
|
|
7811
8005
|
getZoomLevel() {
|
|
@@ -7865,7 +8059,7 @@ class DiagramCanvas {
|
|
|
7865
8059
|
this.zoomBehavior.translateTo(this.selectCanvasView(), currentX, currentY);
|
|
7866
8060
|
}
|
|
7867
8061
|
} catch (e) {
|
|
7868
|
-
console.warn('Animation has been interrupted');
|
|
8062
|
+
console.warn('Animation has been interrupted.', e);
|
|
7869
8063
|
animationInterrupted = true;
|
|
7870
8064
|
}
|
|
7871
8065
|
};
|
|
@@ -7900,10 +8094,17 @@ class DiagramCanvas {
|
|
|
7900
8094
|
}
|
|
7901
8095
|
}
|
|
7902
8096
|
getClosestGridPoint(point) {
|
|
7903
|
-
|
|
7904
|
-
|
|
8097
|
+
let pointX = point[0];
|
|
8098
|
+
const spacingX = getGridSpacingX(this.gridConfig);
|
|
8099
|
+
if (spacingX !== 0) {
|
|
8100
|
+
pointX = Math.round(pointX / spacingX) * spacingX;
|
|
8101
|
+
}
|
|
8102
|
+
let pointY = point[1];
|
|
8103
|
+
const spacingY = getGridSpacingY(this.gridConfig);
|
|
8104
|
+
if (spacingY !== 0) {
|
|
8105
|
+
pointY = Math.round(pointY / spacingY) * spacingY;
|
|
7905
8106
|
}
|
|
7906
|
-
return [
|
|
8107
|
+
return [pointX, pointY];
|
|
7907
8108
|
}
|
|
7908
8109
|
getCoordinatesOnScreen() {
|
|
7909
8110
|
var _a;
|
|
@@ -8038,7 +8239,7 @@ class DiagramCanvas {
|
|
|
8038
8239
|
}).on(DragEvents.End, (event, d) => {
|
|
8039
8240
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
8040
8241
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8041
|
-
if (this.
|
|
8242
|
+
if (this.gridConfig.snap) {
|
|
8042
8243
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
8043
8244
|
pointerCoords[0] += d.type.snapToGridOffset[0];
|
|
8044
8245
|
pointerCoords[1] += d.type.snapToGridOffset[1];
|
|
@@ -8074,7 +8275,7 @@ class DiagramCanvas {
|
|
|
8074
8275
|
}).on(DragEvents.End, (event, d) => {
|
|
8075
8276
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
8076
8277
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8077
|
-
if (this.
|
|
8278
|
+
if (this.gridConfig.snap) {
|
|
8078
8279
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
8079
8280
|
pointerCoords[0] += d.type.snapToGridOffset[0];
|
|
8080
8281
|
pointerCoords[1] += d.type.snapToGridOffset[1];
|
|
@@ -8110,7 +8311,7 @@ class DiagramCanvas {
|
|
|
8110
8311
|
}).on(DragEvents.End, (event, d) => {
|
|
8111
8312
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
8112
8313
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8113
|
-
if (this.
|
|
8314
|
+
if (this.gridConfig.snap) {
|
|
8114
8315
|
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
8115
8316
|
pointerCoords[0] += d.type.snapToGridOffset[2];
|
|
8116
8317
|
pointerCoords[1] += d.type.snapToGridOffset[3];
|
|
@@ -8146,12 +8347,10 @@ class DiagramCanvas {
|
|
|
8146
8347
|
}).on(DragEvents.End, (event, d) => {
|
|
8147
8348
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
8148
8349
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8149
|
-
if (this.
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
pointerCoords[1] += d.type.snapToGridOffset[3];
|
|
8154
|
-
}
|
|
8350
|
+
if (this.gridConfig.snap) {
|
|
8351
|
+
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
8352
|
+
pointerCoords[0] += d.type.snapToGridOffset[2];
|
|
8353
|
+
pointerCoords[1] += d.type.snapToGridOffset[3];
|
|
8155
8354
|
}
|
|
8156
8355
|
d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
|
|
8157
8356
|
this.currentAction.to = d.getGeometry();
|
|
@@ -8277,7 +8476,7 @@ class DiagramCanvas {
|
|
|
8277
8476
|
}).on(DragEvents.End, (event, d) => {
|
|
8278
8477
|
if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
|
|
8279
8478
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8280
|
-
if (this.
|
|
8479
|
+
if (this.gridConfig.snap) {
|
|
8281
8480
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
8282
8481
|
}
|
|
8283
8482
|
d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
|
|
@@ -8311,7 +8510,7 @@ class DiagramCanvas {
|
|
|
8311
8510
|
}).on(DragEvents.End, (event, d) => {
|
|
8312
8511
|
if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
|
|
8313
8512
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8314
|
-
if (this.
|
|
8513
|
+
if (this.gridConfig.snap) {
|
|
8315
8514
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
8316
8515
|
}
|
|
8317
8516
|
d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
|
|
@@ -8345,7 +8544,7 @@ class DiagramCanvas {
|
|
|
8345
8544
|
}).on(DragEvents.End, (event, d) => {
|
|
8346
8545
|
if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
|
|
8347
8546
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8348
|
-
if (this.
|
|
8547
|
+
if (this.gridConfig.snap) {
|
|
8349
8548
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
8350
8549
|
}
|
|
8351
8550
|
d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
|
|
@@ -8379,7 +8578,7 @@ class DiagramCanvas {
|
|
|
8379
8578
|
}).on(DragEvents.End, (event, d) => {
|
|
8380
8579
|
if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
|
|
8381
8580
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
8382
|
-
if (this.
|
|
8581
|
+
if (this.gridConfig.snap) {
|
|
8383
8582
|
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
8384
8583
|
}
|
|
8385
8584
|
d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
|
|
@@ -8750,9 +8949,9 @@ class DiagramCanvas {
|
|
|
8750
8949
|
}
|
|
8751
8950
|
this.secondaryButton = false;
|
|
8752
8951
|
}));
|
|
8753
|
-
enterSelection.append('text');
|
|
8952
|
+
enterSelection.append('text').style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
|
|
8754
8953
|
enterSelection.append('rect');
|
|
8755
|
-
mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === HorizontalAlign.Center ? 'middle' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === VerticalAlign.Center ? d.height / 2 : d.verticalAlign === VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === VerticalAlign.Center ? 'middle' : d.verticalAlign === VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.fontSize).attr('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.
|
|
8954
|
+
mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === HorizontalAlign.Center ? 'middle' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === VerticalAlign.Center ? d.height / 2 : d.verticalAlign === VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === VerticalAlign.Center ? 'middle' : d.verticalAlign === VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('font-family', d => d.look.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.look.fontWeight || DIAGRAM_FIELD_DEFAULTS.look.fontWeight).attr('fill', d => d.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').each(d => {
|
|
8756
8955
|
this.setFieldTextAndWrap(d);
|
|
8757
8956
|
});
|
|
8758
8957
|
mergeSelection
|
|
@@ -8767,7 +8966,7 @@ class DiagramCanvas {
|
|
|
8767
8966
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8768
8967
|
}
|
|
8769
8968
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8770
|
-
mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.
|
|
8969
|
+
mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
|
|
8771
8970
|
exitSelection.remove();
|
|
8772
8971
|
enterSelection.on(Events.ContextMenu, (event, d) => {
|
|
8773
8972
|
if (this.dragging) {
|
|
@@ -8810,7 +9009,7 @@ class DiagramCanvas {
|
|
|
8810
9009
|
updateSelection = updateSelection.filter(d => ids.includes(d.id));
|
|
8811
9010
|
}
|
|
8812
9011
|
const mergeSelection = enterSelection.merge(updateSelection);
|
|
8813
|
-
mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.
|
|
9012
|
+
mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
|
|
8814
9013
|
exitSelection.remove();
|
|
8815
9014
|
enterSelection.on(Events.MouseOver, (_event, d) => {
|
|
8816
9015
|
if (!this.dragging) {
|
|
@@ -8911,6 +9110,7 @@ class DiagramCanvas {
|
|
|
8911
9110
|
const pathSelection = connectionSelection.select('path');
|
|
8912
9111
|
const pathNode = pathSelection.node();
|
|
8913
9112
|
const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
|
|
9113
|
+
labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
|
|
8914
9114
|
if (pathNode) {
|
|
8915
9115
|
const pathLength = pathNode.getTotalLength();
|
|
8916
9116
|
let startLabelShiftX = 0;
|
|
@@ -8919,7 +9119,7 @@ class DiagramCanvas {
|
|
|
8919
9119
|
let middleLabelShiftY = 0;
|
|
8920
9120
|
let endLabelShiftX = 0;
|
|
8921
9121
|
let endLabelShiftY = 0;
|
|
8922
|
-
if (labelConfiguration.
|
|
9122
|
+
if (labelConfiguration.look.fillColor === 'transparent') {
|
|
8923
9123
|
// background color is transparent / not set, so we find an alternative position for the label
|
|
8924
9124
|
const deltaX = connection.endCoords[0] - connection.startCoords[0];
|
|
8925
9125
|
const deltaY = connection.endCoords[1] - connection.startCoords[1];
|
|
@@ -8974,7 +9174,7 @@ class DiagramCanvas {
|
|
|
8974
9174
|
}
|
|
8975
9175
|
}
|
|
8976
9176
|
// bind start labels
|
|
8977
|
-
connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill',
|
|
9177
|
+
connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).text(connection.startLabel);
|
|
8978
9178
|
const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
8979
9179
|
if (startLabelBoundingRect) {
|
|
8980
9180
|
// don't create space for the label if the label is empty
|
|
@@ -8997,22 +9197,22 @@ class DiagramCanvas {
|
|
|
8997
9197
|
default:
|
|
8998
9198
|
pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
8999
9199
|
}
|
|
9000
|
-
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.
|
|
9200
|
+
connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
|
|
9001
9201
|
connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
|
|
9002
9202
|
}
|
|
9003
9203
|
// bind middle labels
|
|
9004
|
-
connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill',
|
|
9204
|
+
connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).style('font-kerning', 'none').text(connection.middleLabel);
|
|
9005
9205
|
const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
9006
9206
|
if (middleLabelBoundingRect) {
|
|
9007
9207
|
// don't create space for the label if the label is empty
|
|
9008
9208
|
const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
|
|
9009
9209
|
const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
|
|
9010
9210
|
const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
|
|
9011
|
-
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.
|
|
9211
|
+
connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
|
|
9012
9212
|
connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
|
|
9013
9213
|
}
|
|
9014
9214
|
// bind end labels
|
|
9015
|
-
connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill',
|
|
9215
|
+
connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').text(connection.endLabel);
|
|
9016
9216
|
const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
|
|
9017
9217
|
if (endLabelBoundingRect) {
|
|
9018
9218
|
// don't create space for the label if the label is empty
|
|
@@ -9035,7 +9235,7 @@ class DiagramCanvas {
|
|
|
9035
9235
|
default:
|
|
9036
9236
|
pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
|
|
9037
9237
|
}
|
|
9038
|
-
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.
|
|
9238
|
+
connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
|
|
9039
9239
|
connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
|
|
9040
9240
|
}
|
|
9041
9241
|
}
|
|
@@ -9079,9 +9279,13 @@ class DiagramCanvas {
|
|
|
9079
9279
|
const fieldDimensions = this.minimumSizeOfField(field);
|
|
9080
9280
|
let stretchX = fieldDimensions[0] + getLeftMargin(field.rootElement.type.label) + getRightMargin(field.rootElement.type.label) - field.rootElement.width;
|
|
9081
9281
|
let stretchY = fieldDimensions[1] + getTopMargin(field.rootElement.type.label) + getBottomMargin(field.rootElement.type.label) - field.rootElement.height;
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9282
|
+
const spacingX = getGridSpacingX(this.gridConfig);
|
|
9283
|
+
const spacingY = getGridSpacingY(this.gridConfig);
|
|
9284
|
+
if (this.gridConfig.snap && spacingX !== 0) {
|
|
9285
|
+
stretchX = Math.ceil(stretchX / spacingX) * spacingX;
|
|
9286
|
+
}
|
|
9287
|
+
if (this.gridConfig.snap && spacingY !== 0) {
|
|
9288
|
+
stretchY = Math.ceil(stretchY / spacingY) * spacingY;
|
|
9085
9289
|
}
|
|
9086
9290
|
// ensure node is not stretched under its minimum dimensions
|
|
9087
9291
|
if (field.rootElement.width + stretchX < field.rootElement.type.minWidth) {
|
|
@@ -9119,9 +9323,13 @@ class DiagramCanvas {
|
|
|
9119
9323
|
const type = field.rootElement.type;
|
|
9120
9324
|
let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label) + getRightMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.width;
|
|
9121
9325
|
let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label) + getBottomMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.height;
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9326
|
+
const spacingX = getGridSpacingX(this.gridConfig);
|
|
9327
|
+
const spacingY = getGridSpacingY(this.gridConfig);
|
|
9328
|
+
if (this.gridConfig.snap && spacingX !== 0) {
|
|
9329
|
+
stretchX = Math.ceil(stretchX / spacingX) * spacingX;
|
|
9330
|
+
}
|
|
9331
|
+
if (this.gridConfig.snap && spacingY !== 0) {
|
|
9332
|
+
stretchY = Math.ceil(stretchY / spacingY) * spacingY;
|
|
9125
9333
|
}
|
|
9126
9334
|
// ensure section is not stretched under its minimum dimensions
|
|
9127
9335
|
if (field.rootElement.width + stretchX < (field.rootElement.getMinWidth() || 0)) {
|
|
@@ -9171,13 +9379,13 @@ class DiagramCanvas {
|
|
|
9171
9379
|
return d3.select(this.diagramRoot);
|
|
9172
9380
|
}
|
|
9173
9381
|
selectSVGElement() {
|
|
9174
|
-
return
|
|
9382
|
+
return this.selectRoot().select('svg');
|
|
9175
9383
|
}
|
|
9176
9384
|
selectCanvasView() {
|
|
9177
9385
|
return this.selectSVGElement().select(`.daga-canvas-view`);
|
|
9178
9386
|
}
|
|
9179
9387
|
selectCanvasElements() {
|
|
9180
|
-
return this.
|
|
9388
|
+
return this.selectCanvasView().select(`.daga-canvas-elements`);
|
|
9181
9389
|
}
|
|
9182
9390
|
// User actions
|
|
9183
9391
|
startConnection(port) {
|
|
@@ -9289,7 +9497,7 @@ class DiagramCanvas {
|
|
|
9289
9497
|
openTextInput(id) {
|
|
9290
9498
|
const field = this.model.fields.get(id);
|
|
9291
9499
|
if (field) {
|
|
9292
|
-
this.createInputField(field.text, field.coords, field.width, field.height, field.fontSize, field.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, field.orientation, field.multiline, () => {
|
|
9500
|
+
this.createInputField(field.text, field.coords, field.width, field.height, field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, field.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily, field.orientation, field.multiline, () => {
|
|
9293
9501
|
// (_text)
|
|
9294
9502
|
/*
|
|
9295
9503
|
Empty for now
|
|
@@ -9326,7 +9534,7 @@ class DiagramCanvas {
|
|
|
9326
9534
|
}
|
|
9327
9535
|
}).on(Events.KeyUp, event => {
|
|
9328
9536
|
event.stopPropagation();
|
|
9329
|
-
}).on(Events.Input,
|
|
9537
|
+
}).on(Events.Input, () => {
|
|
9330
9538
|
const value = inputField.property('value');
|
|
9331
9539
|
inputField.attr('cols', numberOfColumns(value) + 1);
|
|
9332
9540
|
inputField.attr('rows', numberOfRows(value) + 1);
|
|
@@ -9415,7 +9623,7 @@ class DiagramCanvas {
|
|
|
9415
9623
|
const lines = text.split('\n');
|
|
9416
9624
|
textSelection.html('');
|
|
9417
9625
|
for (let i = 0; i < lines.length; ++i) {
|
|
9418
|
-
textSelection.append('tspan').attr('x', field.horizontalAlign === HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * field.fontSize + field.height / 2 : field.verticalAlign === VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * field.fontSize : i * field.fontSize).text(lines[i]);
|
|
9626
|
+
textSelection.append('tspan').attr('x', field.horizontalAlign === HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + field.height / 2 : field.verticalAlign === VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) : i * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)).text(lines[i]);
|
|
9419
9627
|
}
|
|
9420
9628
|
}
|
|
9421
9629
|
/**
|
|
@@ -9455,12 +9663,12 @@ class DiagramCanvas {
|
|
|
9455
9663
|
* Method to call to finish the moving of a node triggered by a user drag event.
|
|
9456
9664
|
*/
|
|
9457
9665
|
finishMovingNode(event, d) {
|
|
9458
|
-
var _a, _b, _c;
|
|
9666
|
+
var _a, _b, _c, _d;
|
|
9459
9667
|
if (this.canUserPerformAction(DiagramActions.MoveNode) && !d.removed) {
|
|
9460
9668
|
// prevent drag behavior if mouse hasn't moved
|
|
9461
9669
|
if (this.draggingFrom[0] !== event.x || this.draggingFrom[1] !== event.y) {
|
|
9462
9670
|
let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
|
|
9463
|
-
if (this.
|
|
9671
|
+
if ((_a = this.gridConfig) === null || _a === void 0 ? void 0 : _a.snap) {
|
|
9464
9672
|
newNodeCoords = this.getClosestGridPoint([newNodeCoords[0] - d.type.snapToGridOffset[0], newNodeCoords[1] - d.type.snapToGridOffset[1]]);
|
|
9465
9673
|
newNodeCoords[0] += d.type.snapToGridOffset[0];
|
|
9466
9674
|
newNodeCoords[1] += d.type.snapToGridOffset[1];
|
|
@@ -9487,8 +9695,8 @@ class DiagramCanvas {
|
|
|
9487
9695
|
if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
|
|
9488
9696
|
const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
|
|
9489
9697
|
const fromChildGeometry = this.currentAction.from;
|
|
9490
|
-
const setParentAction = new SetParentAction(this, d.id, (
|
|
9491
|
-
(
|
|
9698
|
+
const setParentAction = new SetParentAction(this, d.id, (_b = d.parent) === null || _b === void 0 ? void 0 : _b.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
|
|
9699
|
+
(_c = d.parent) === null || _c === void 0 ? void 0 : _c.removeChild(d);
|
|
9492
9700
|
if (droppedOn !== undefined) {
|
|
9493
9701
|
droppedOn.addChild(d);
|
|
9494
9702
|
}
|
|
@@ -9499,7 +9707,7 @@ class DiagramCanvas {
|
|
|
9499
9707
|
const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
|
|
9500
9708
|
this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
|
|
9501
9709
|
this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
|
|
9502
|
-
(
|
|
9710
|
+
(_d = d.parent) === null || _d === void 0 ? void 0 : _d.fitToChild(d);
|
|
9503
9711
|
this.currentAction.to = d.getGeometry(d.id);
|
|
9504
9712
|
this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
|
|
9505
9713
|
}
|
|
@@ -9910,7 +10118,7 @@ class AdjacencyLayout {
|
|
|
9910
10118
|
this.gapSize = gapSize;
|
|
9911
10119
|
}
|
|
9912
10120
|
apply(model) {
|
|
9913
|
-
var _a;
|
|
10121
|
+
var _a, _b, _c, _d;
|
|
9914
10122
|
if (model.nodes.length === 0) {
|
|
9915
10123
|
// nothing to arrange...
|
|
9916
10124
|
return model;
|
|
@@ -9924,12 +10132,13 @@ class AdjacencyLayout {
|
|
|
9924
10132
|
// place nodes according to arrangement
|
|
9925
10133
|
const maximumWidth = Math.max(...model.nodes.map(n => n.width));
|
|
9926
10134
|
const maximumHeight = Math.max(...model.nodes.map(n => n.height));
|
|
9927
|
-
const
|
|
10135
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10136
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
|
|
9928
10137
|
for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
|
|
9929
10138
|
for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
|
|
9930
10139
|
const node = nodeArrangement.get([x, y]);
|
|
9931
10140
|
if (node !== undefined) {
|
|
9932
|
-
node.move([x * (maximumWidth +
|
|
10141
|
+
node.move([x * (maximumWidth + gapSizeX), y * (maximumHeight + gapSizeY)]);
|
|
9933
10142
|
}
|
|
9934
10143
|
}
|
|
9935
10144
|
}
|
|
@@ -9956,7 +10165,7 @@ class BreadthAdjacencyLayout {
|
|
|
9956
10165
|
this.gapSize = gapSize;
|
|
9957
10166
|
}
|
|
9958
10167
|
apply(model) {
|
|
9959
|
-
var _a;
|
|
10168
|
+
var _a, _b, _c, _d;
|
|
9960
10169
|
if (model.nodes.length === 0) {
|
|
9961
10170
|
// nothing to arrange...
|
|
9962
10171
|
return model;
|
|
@@ -9992,12 +10201,13 @@ class BreadthAdjacencyLayout {
|
|
|
9992
10201
|
// place nodes according to arrangement
|
|
9993
10202
|
const maximumWidth = Math.max(...model.nodes.map(n => n.width));
|
|
9994
10203
|
const maximumHeight = Math.max(...model.nodes.map(n => n.height));
|
|
9995
|
-
const
|
|
10204
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10205
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
|
|
9996
10206
|
for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
|
|
9997
10207
|
for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
|
|
9998
10208
|
const node = nodeArrangement.get([x, y]);
|
|
9999
10209
|
if (node !== undefined) {
|
|
10000
|
-
node.move([x * (maximumWidth +
|
|
10210
|
+
node.move([x * (maximumWidth + gapSizeX), y * (maximumHeight + gapSizeY)]);
|
|
10001
10211
|
}
|
|
10002
10212
|
}
|
|
10003
10213
|
}
|
|
@@ -10014,12 +10224,13 @@ class BreadthLayout {
|
|
|
10014
10224
|
this.gapSize = gapSize;
|
|
10015
10225
|
}
|
|
10016
10226
|
apply(model) {
|
|
10017
|
-
var _a;
|
|
10227
|
+
var _a, _b, _c, _d;
|
|
10018
10228
|
if (model.nodes.length === 0) {
|
|
10019
10229
|
// nothing to arrange...
|
|
10020
10230
|
return model;
|
|
10021
10231
|
}
|
|
10022
|
-
const
|
|
10232
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10233
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
|
|
10023
10234
|
let nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
10024
10235
|
// Arrange nodes by a breadth first search
|
|
10025
10236
|
const firstNode = nodesToBeArranged[0];
|
|
@@ -10058,10 +10269,10 @@ class BreadthLayout {
|
|
|
10058
10269
|
let heightAccumulator = 0;
|
|
10059
10270
|
for (const node of nodeArrangementRow) {
|
|
10060
10271
|
node.move([widthAccumulator, heightAccumulator]);
|
|
10061
|
-
heightAccumulator +=
|
|
10272
|
+
heightAccumulator += gapSizeY + node.height;
|
|
10062
10273
|
}
|
|
10063
10274
|
const maximumWidth = Math.max(...nodeArrangementRow.map(n => n.width));
|
|
10064
|
-
widthAccumulator +=
|
|
10275
|
+
widthAccumulator += gapSizeX + maximumWidth;
|
|
10065
10276
|
}
|
|
10066
10277
|
for (const connection of model.connections) {
|
|
10067
10278
|
connection.tighten();
|
|
@@ -10079,14 +10290,16 @@ class ForceLayout {
|
|
|
10079
10290
|
this.gapSize = gapSize;
|
|
10080
10291
|
}
|
|
10081
10292
|
apply(model) {
|
|
10082
|
-
var _a;
|
|
10293
|
+
var _a, _b, _c, _d;
|
|
10083
10294
|
if (model.nodes.length === 0) {
|
|
10084
10295
|
// nothing to arrange...
|
|
10085
10296
|
return model;
|
|
10086
10297
|
}
|
|
10087
10298
|
// as a starting point, we apply a simple layout
|
|
10088
10299
|
new BreadthLayout(this.gapSize).apply(model);
|
|
10089
|
-
const
|
|
10300
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10301
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
|
|
10302
|
+
const gapSize = Math.max(gapSizeX, gapSizeY);
|
|
10090
10303
|
const coolingFactor = 0.99;
|
|
10091
10304
|
const minimumTemperature = 1;
|
|
10092
10305
|
const attractionFactor = 0.1;
|
|
@@ -10155,7 +10368,7 @@ class ForceLayout {
|
|
|
10155
10368
|
}
|
|
10156
10369
|
}
|
|
10157
10370
|
}
|
|
10158
|
-
if (model.canvas && model.canvas.
|
|
10371
|
+
if (model.canvas && model.canvas.gridConfig.snap) {
|
|
10159
10372
|
for (const node of model.nodes) {
|
|
10160
10373
|
const snappedCoords = model.canvas.getClosestGridPoint([node.coords[0] - node.type.snapToGridOffset[0], node.coords[1] - node.type.snapToGridOffset[1]]);
|
|
10161
10374
|
snappedCoords[0] += node.type.snapToGridOffset[0];
|
|
@@ -10179,18 +10392,18 @@ class HorizontalLayout {
|
|
|
10179
10392
|
this.gapSize = gapSize;
|
|
10180
10393
|
}
|
|
10181
10394
|
apply(model) {
|
|
10182
|
-
var _a;
|
|
10395
|
+
var _a, _b;
|
|
10183
10396
|
if (model.nodes.length === 0) {
|
|
10184
10397
|
// nothing to arrange...
|
|
10185
10398
|
return model;
|
|
10186
10399
|
}
|
|
10187
|
-
const
|
|
10400
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10188
10401
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
10189
10402
|
nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
|
|
10190
10403
|
let widthAccumulator = 0;
|
|
10191
10404
|
for (const node of nodesToBeArranged) {
|
|
10192
10405
|
node.move([widthAccumulator, 0]);
|
|
10193
|
-
widthAccumulator += node.width +
|
|
10406
|
+
widthAccumulator += node.width + gapSizeX;
|
|
10194
10407
|
}
|
|
10195
10408
|
return model;
|
|
10196
10409
|
}
|
|
@@ -10205,7 +10418,7 @@ class PriorityLayout {
|
|
|
10205
10418
|
this.gapSize = gapSize;
|
|
10206
10419
|
}
|
|
10207
10420
|
apply(model) {
|
|
10208
|
-
var _a;
|
|
10421
|
+
var _a, _b, _c, _d;
|
|
10209
10422
|
if (model.nodes.length === 0) {
|
|
10210
10423
|
// nothing to arrange...
|
|
10211
10424
|
return model;
|
|
@@ -10217,7 +10430,8 @@ class PriorityLayout {
|
|
|
10217
10430
|
new BreadthLayout(this.gapSize).apply(model);
|
|
10218
10431
|
return model;
|
|
10219
10432
|
}
|
|
10220
|
-
const
|
|
10433
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10434
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
|
|
10221
10435
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
10222
10436
|
const nodeArrangement = [];
|
|
10223
10437
|
const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
|
|
@@ -10294,10 +10508,10 @@ class PriorityLayout {
|
|
|
10294
10508
|
for (let j = 0; j < nodeArrangement[i].length; ++j) {
|
|
10295
10509
|
const node = nodeArrangement[i][j];
|
|
10296
10510
|
node.move([widthAccumulator, heightAccumulator]);
|
|
10297
|
-
heightAccumulator +=
|
|
10511
|
+
heightAccumulator += gapSizeY + node.height;
|
|
10298
10512
|
}
|
|
10299
10513
|
const maximumWidth = Math.max(...nodeArrangement[i].map(n => n.width));
|
|
10300
|
-
widthAccumulator +=
|
|
10514
|
+
widthAccumulator += gapSizeX + maximumWidth;
|
|
10301
10515
|
}
|
|
10302
10516
|
for (const connection of model.connections) {
|
|
10303
10517
|
connection.tighten();
|
|
@@ -10315,7 +10529,7 @@ class TreeLayout {
|
|
|
10315
10529
|
this.gapSize = gapSize;
|
|
10316
10530
|
}
|
|
10317
10531
|
apply(model) {
|
|
10318
|
-
var _a;
|
|
10532
|
+
var _a, _b, _c, _d;
|
|
10319
10533
|
if (model.nodes.length === 0) {
|
|
10320
10534
|
// nothing to arrange...
|
|
10321
10535
|
return model;
|
|
@@ -10327,7 +10541,8 @@ class TreeLayout {
|
|
|
10327
10541
|
new BreadthLayout(this.gapSize).apply(model);
|
|
10328
10542
|
return model;
|
|
10329
10543
|
}
|
|
10330
|
-
const
|
|
10544
|
+
const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10545
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
|
|
10331
10546
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
|
|
10332
10547
|
const branches = [];
|
|
10333
10548
|
while (nodesToBeArranged.length > 0) {
|
|
@@ -10349,10 +10564,10 @@ class TreeLayout {
|
|
|
10349
10564
|
for (let j = 0; j < branchArrangement[i].length; ++j) {
|
|
10350
10565
|
const branch = branchArrangement[i][j];
|
|
10351
10566
|
branch.node.move([widthAccumulator, heightAccumulator]);
|
|
10352
|
-
heightAccumulator += (
|
|
10567
|
+
heightAccumulator += (gapSizeY + maximumHeight) * branch.countBranchHeight();
|
|
10353
10568
|
}
|
|
10354
10569
|
const maximumWidth = Math.max(...branchArrangement[i].map(b => b.node.width));
|
|
10355
|
-
widthAccumulator +=
|
|
10570
|
+
widthAccumulator += gapSizeX + maximumWidth;
|
|
10356
10571
|
}
|
|
10357
10572
|
for (const connection of model.connections) {
|
|
10358
10573
|
connection.tighten();
|
|
@@ -10416,18 +10631,18 @@ class VerticalLayout {
|
|
|
10416
10631
|
this.gapSize = gapSize;
|
|
10417
10632
|
}
|
|
10418
10633
|
apply(model) {
|
|
10419
|
-
var _a;
|
|
10634
|
+
var _a, _b;
|
|
10420
10635
|
if (model.nodes.length === 0) {
|
|
10421
10636
|
// nothing to arrange...
|
|
10422
10637
|
return model;
|
|
10423
10638
|
}
|
|
10424
|
-
const
|
|
10639
|
+
const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingY((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
|
|
10425
10640
|
const nodesToBeArranged = model.nodes.filter(n => !n.parent);
|
|
10426
10641
|
nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
|
|
10427
10642
|
let heightAccumulator = 0;
|
|
10428
10643
|
for (const node of nodesToBeArranged) {
|
|
10429
10644
|
node.move([0, heightAccumulator]);
|
|
10430
|
-
heightAccumulator += node.height +
|
|
10645
|
+
heightAccumulator += node.height + gapSizeY;
|
|
10431
10646
|
}
|
|
10432
10647
|
return model;
|
|
10433
10648
|
}
|