@metadev/daga 4.2.7 → 4.2.9
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 +12 -0
- package/index.cjs.js +629 -216
- package/index.esm.js +629 -216
- package/package.json +1 -1
- package/src/lib/diagram/canvas/diagram-user-selection.d.ts +4 -3
- package/src/lib/diagram/config/diagram-components-config.d.ts +5 -0
- package/src/lib/diagram/config/diagram-config.d.ts +6 -0
- package/src/lib/diagram/config/diagram-look-config.d.ts +1 -0
- package/src/lib/diagram/model/diagram-connection.d.ts +36 -3
- package/src/lib/diagram/model/diagram-node.d.ts +14 -1
- package/src/lib/diagram/model/diagram-port.d.ts +12 -1
- package/src/lib/diagram/model/diagram-section.d.ts +12 -1
package/index.esm.js
CHANGED
|
@@ -381,7 +381,20 @@ const linePath = (shape, points, startDirection, endDirection, minimumDistanceBe
|
|
|
381
381
|
result += `M ${points[0][0]} ${points[0][1]}`;
|
|
382
382
|
for (let i = 1; i < points.length; ++i) {
|
|
383
383
|
if (i + 1 >= points.length) {
|
|
384
|
-
|
|
384
|
+
switch (endDirection) {
|
|
385
|
+
case Side.Bottom:
|
|
386
|
+
nextDirection = Side.Top;
|
|
387
|
+
break;
|
|
388
|
+
case Side.Top:
|
|
389
|
+
nextDirection = Side.Bottom;
|
|
390
|
+
break;
|
|
391
|
+
case Side.Right:
|
|
392
|
+
nextDirection = Side.Left;
|
|
393
|
+
break;
|
|
394
|
+
case Side.Left:
|
|
395
|
+
nextDirection = Side.Right;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
385
398
|
} else {
|
|
386
399
|
if (Math.abs(points[i][0] - points[i - 1][0]) < Math.abs(points[i][1] - points[i - 1][1])) {
|
|
387
400
|
if (points[i][1] > points[i - 1][1]) {
|
|
@@ -417,16 +430,16 @@ const linePath = (shape, points, startDirection, endDirection, minimumDistanceBe
|
|
|
417
430
|
}
|
|
418
431
|
if (nextDirection !== undefined) {
|
|
419
432
|
switch (nextDirection) {
|
|
420
|
-
case Side.
|
|
433
|
+
case Side.Top:
|
|
421
434
|
controlPoint2 = `${points[i][0]} ${points[i][1] + controlPointDistance}`;
|
|
422
435
|
break;
|
|
423
|
-
case Side.
|
|
436
|
+
case Side.Bottom:
|
|
424
437
|
controlPoint2 = `${points[i][0]} ${points[i][1] - controlPointDistance}`;
|
|
425
438
|
break;
|
|
426
|
-
case Side.
|
|
439
|
+
case Side.Left:
|
|
427
440
|
controlPoint2 = `${points[i][0] + controlPointDistance} ${points[i][1]}`;
|
|
428
441
|
break;
|
|
429
|
-
case Side.
|
|
442
|
+
case Side.Right:
|
|
430
443
|
controlPoint2 = `${points[i][0] - controlPointDistance} ${points[i][1]}`;
|
|
431
444
|
break;
|
|
432
445
|
}
|
|
@@ -439,16 +452,16 @@ const linePath = (shape, points, startDirection, endDirection, minimumDistanceBe
|
|
|
439
452
|
let controlPoint = '';
|
|
440
453
|
const controlPointDistance = (Math.abs(points[i][0] - points[i - 1][0]) + Math.abs(points[i][1] - points[i - 1][1])) / 2;
|
|
441
454
|
switch (nextDirection) {
|
|
442
|
-
case Side.
|
|
455
|
+
case Side.Top:
|
|
443
456
|
controlPoint = `${points[i][0]} ${points[i][1] + controlPointDistance}`;
|
|
444
457
|
break;
|
|
445
|
-
case Side.
|
|
458
|
+
case Side.Bottom:
|
|
446
459
|
controlPoint = `${points[i][0]} ${points[i][1] - controlPointDistance}`;
|
|
447
460
|
break;
|
|
448
|
-
case Side.
|
|
461
|
+
case Side.Left:
|
|
449
462
|
controlPoint = `${points[i][0] + controlPointDistance} ${points[i][1]}`;
|
|
450
463
|
break;
|
|
451
|
-
case Side.
|
|
464
|
+
case Side.Right:
|
|
452
465
|
controlPoint = `${points[i][0] - controlPointDistance} ${points[i][1]}`;
|
|
453
466
|
break;
|
|
454
467
|
}
|
|
@@ -461,152 +474,443 @@ const linePath = (shape, points, startDirection, endDirection, minimumDistanceBe
|
|
|
461
474
|
}
|
|
462
475
|
break;
|
|
463
476
|
case LineShape.Square:
|
|
477
|
+
currentDirection = startDirection;
|
|
464
478
|
result += `M ${points[0][0]} ${points[0][1]}`;
|
|
465
|
-
if (startDirection) {
|
|
466
|
-
switch (startDirection) {
|
|
467
|
-
case Side.Bottom:
|
|
468
|
-
points.splice(1, 0, [points[0][0], points[0][1] + minimumDistanceBeforeTurn]);
|
|
469
|
-
break;
|
|
470
|
-
case Side.Top:
|
|
471
|
-
points.splice(1, 0, [points[0][0], points[0][1] - minimumDistanceBeforeTurn]);
|
|
472
|
-
break;
|
|
473
|
-
case Side.Right:
|
|
474
|
-
points.splice(1, 0, [points[0][0] + minimumDistanceBeforeTurn, points[0][1]]);
|
|
475
|
-
break;
|
|
476
|
-
case Side.Left:
|
|
477
|
-
points.splice(1, 0, [points[0][0] - minimumDistanceBeforeTurn, points[0][1]]);
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (endDirection) {
|
|
482
|
-
switch (endDirection) {
|
|
483
|
-
case Side.Bottom:
|
|
484
|
-
points.splice(points.length - 1, 0, [points[points.length - 1][0], points[points.length - 1][1] + minimumDistanceBeforeTurn]);
|
|
485
|
-
break;
|
|
486
|
-
case Side.Top:
|
|
487
|
-
points.splice(points.length - 1, 0, [points[points.length - 1][0], points[points.length - 1][1] - minimumDistanceBeforeTurn]);
|
|
488
|
-
break;
|
|
489
|
-
case Side.Right:
|
|
490
|
-
points.splice(points.length - 1, 0, [points[points.length - 1][0] + minimumDistanceBeforeTurn, points[points.length - 1][1]]);
|
|
491
|
-
break;
|
|
492
|
-
case Side.Left:
|
|
493
|
-
points.splice(points.length - 1, 0, [points[points.length - 1][0] - minimumDistanceBeforeTurn, points[points.length - 1][1]]);
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
479
|
for (let i = 1; i < points.length; ++i) {
|
|
498
|
-
if (
|
|
499
|
-
switch (
|
|
480
|
+
if (i + 1 >= points.length) {
|
|
481
|
+
switch (endDirection) {
|
|
500
482
|
case Side.Bottom:
|
|
501
|
-
|
|
502
|
-
// next point is behind, we turn around
|
|
503
|
-
result += ` H ${points[i][0]}`;
|
|
504
|
-
result += ` V ${points[i][1]}`;
|
|
505
|
-
currentDirection = Side.Top;
|
|
506
|
-
} else if (points[i][1] < points[i - 1][1] && points[i][0] === points[i - 1][0]) {
|
|
507
|
-
// next point is behind on the same line, we turn around
|
|
508
|
-
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
509
|
-
result += ` V ${points[i][1]}`;
|
|
510
|
-
result += ` H ${points[i][0]}`;
|
|
511
|
-
currentDirection = Side.Left;
|
|
512
|
-
} else if (points[i][1] === points[i - 1][1] && points[i][0] !== points[i - 1][0]) {
|
|
513
|
-
// next point is perpendicular to us
|
|
514
|
-
result += ` H ${points[i][0]}`;
|
|
515
|
-
currentDirection = points[i][0] > points[i - 1][0] ? Side.Right : Side.Left;
|
|
516
|
-
} else if (points[i][1] > points[i - 1][1] && points[i][0] !== points[i - 1][0]) {
|
|
517
|
-
// next point is after us, we turn and continue
|
|
518
|
-
result += ` H ${points[i][0]}`;
|
|
519
|
-
result += ` V ${points[i][1]}`;
|
|
520
|
-
} else if (points[i][1] > points[i - 1][1] && points[i][0] === points[i - 1][0]) {
|
|
521
|
-
// next point is in the same direction, we continue straight
|
|
522
|
-
result += ` V ${points[i][1]}`;
|
|
523
|
-
}
|
|
483
|
+
nextDirection = Side.Top;
|
|
524
484
|
break;
|
|
525
485
|
case Side.Top:
|
|
526
|
-
|
|
527
|
-
// next point is behind, we turn around
|
|
528
|
-
result += ` H ${points[i][0]}`;
|
|
529
|
-
result += ` V ${points[i][1]}`;
|
|
530
|
-
currentDirection = Side.Bottom;
|
|
531
|
-
} else if (points[i][1] > points[i - 1][1] && points[i][0] === points[i - 1][0]) {
|
|
532
|
-
// next point is behind on the same line, we turn around
|
|
533
|
-
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
534
|
-
result += ` V ${points[i][1]}`;
|
|
535
|
-
result += ` H ${points[i][0]}`;
|
|
536
|
-
currentDirection = Side.Right;
|
|
537
|
-
} else if (points[i][1] === points[i - 1][1] && points[i][0] !== points[i - 1][0]) {
|
|
538
|
-
// next point is perpendicular to us
|
|
539
|
-
result += ` H ${points[i][0]}`;
|
|
540
|
-
currentDirection = points[i][0] > points[i - 1][0] ? Side.Right : Side.Left;
|
|
541
|
-
} else if (points[i][1] < points[i - 1][1] && points[i][0] !== points[i - 1][0]) {
|
|
542
|
-
// next point is after us, we turn and continue
|
|
543
|
-
result += ` H ${points[i][0]}`;
|
|
544
|
-
result += ` V ${points[i][1]}`;
|
|
545
|
-
} else if (points[i][1] < points[i - 1][1] && points[i][0] === points[i - 1][0]) {
|
|
546
|
-
// next point is in the same direction, we continue straight
|
|
547
|
-
result += ` V ${points[i][1]}`;
|
|
548
|
-
}
|
|
486
|
+
nextDirection = Side.Bottom;
|
|
549
487
|
break;
|
|
550
488
|
case Side.Right:
|
|
551
|
-
|
|
552
|
-
// next point is behind, we turn around
|
|
553
|
-
result += ` V ${points[i][1]}`;
|
|
554
|
-
result += ` H ${points[i][0]}`;
|
|
555
|
-
currentDirection = Side.Left;
|
|
556
|
-
} else if (points[i][0] < points[i - 1][0] && points[i][1] === points[i - 1][1]) {
|
|
557
|
-
// next point is behind on the same line, we turn around
|
|
558
|
-
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
559
|
-
result += ` H ${points[i][0]}`;
|
|
560
|
-
result += ` V ${points[i][1]}`;
|
|
561
|
-
currentDirection = Side.Top;
|
|
562
|
-
} else if (points[i][0] === points[i - 1][0] && points[i][1] !== points[i - 1][1]) {
|
|
563
|
-
// next point is perpendicular to us
|
|
564
|
-
result += ` V ${points[i][1]}`;
|
|
565
|
-
currentDirection = points[i][1] > points[i - 1][1] ? Side.Bottom : Side.Top;
|
|
566
|
-
} else if (points[i][0] > points[i - 1][0] && points[i][1] !== points[i - 1][1]) {
|
|
567
|
-
// next point is after us, we turn and continue
|
|
568
|
-
result += ` V ${points[i][1]}`;
|
|
569
|
-
result += ` H ${points[i][0]}`;
|
|
570
|
-
} else if (points[i][0] > points[i - 1][0] && points[i][1] === points[i - 1][1]) {
|
|
571
|
-
// next point is in the same direction, we continue straight
|
|
572
|
-
result += ` H ${points[i][0]}`;
|
|
573
|
-
}
|
|
489
|
+
nextDirection = Side.Left;
|
|
574
490
|
break;
|
|
575
491
|
case Side.Left:
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
492
|
+
nextDirection = Side.Right;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
switch (currentDirection) {
|
|
497
|
+
case Side.Bottom:
|
|
498
|
+
switch (nextDirection) {
|
|
499
|
+
case Side.Bottom:
|
|
500
|
+
if (points[i][1] > points[i - 1][1]) {
|
|
501
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
502
|
+
result += ` V ${(points[i][1] + points[i - 1][1]) / 2}`;
|
|
503
|
+
result += ` H ${points[i][0]}`;
|
|
504
|
+
result += ` V ${points[i][1]}`;
|
|
505
|
+
} else {
|
|
506
|
+
result += ` V ${points[i][1]}`;
|
|
507
|
+
}
|
|
508
|
+
currentDirection = nextDirection;
|
|
509
|
+
} else {
|
|
510
|
+
if (points[i][0] > points[i - 1][0]) {
|
|
511
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
512
|
+
result += ` H ${Math.max(points[i - 1][0], points[i][0]) + minimumDistanceBeforeTurn}`;
|
|
513
|
+
result += ` V ${points[i][1] - minimumDistanceBeforeTurn}`;
|
|
514
|
+
result += ` H ${points[i][0]}`;
|
|
515
|
+
result += ` V ${points[i][1]}`;
|
|
516
|
+
} else {
|
|
517
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
518
|
+
result += ` H ${Math.min(points[i - 1][0], points[i][0]) - minimumDistanceBeforeTurn}`;
|
|
519
|
+
result += ` V ${points[i][1] - minimumDistanceBeforeTurn}`;
|
|
520
|
+
result += ` H ${points[i][0]}`;
|
|
521
|
+
result += ` V ${points[i][1]}`;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
case Side.Top:
|
|
526
|
+
result += ` V ${Math.max(points[i - 1][1], points[i][1]) + minimumDistanceBeforeTurn}`;
|
|
584
527
|
result += ` H ${points[i][0]}`;
|
|
585
528
|
result += ` V ${points[i][1]}`;
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
529
|
+
break;
|
|
530
|
+
case Side.Left:
|
|
531
|
+
if (points[i][1] > points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
532
|
+
if (points[i][0] < points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
533
|
+
result += ` V ${points[i][1]}`;
|
|
534
|
+
result += ` H ${points[i][0]}`;
|
|
535
|
+
} else {
|
|
536
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
537
|
+
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
538
|
+
result += ` V ${points[i][1]}`;
|
|
539
|
+
result += ` H ${points[i][0]}`;
|
|
540
|
+
}
|
|
541
|
+
} else {
|
|
542
|
+
if (points[i][0] < points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
543
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
544
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
545
|
+
result += ` V ${points[i][1]}`;
|
|
546
|
+
result += ` H ${points[i][0]}`;
|
|
547
|
+
} else {
|
|
548
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
549
|
+
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
550
|
+
result += ` V ${points[i][1]}`;
|
|
551
|
+
result += ` H ${points[i][0]}`;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
break;
|
|
555
|
+
case Side.Right:
|
|
556
|
+
if (points[i][1] > points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
557
|
+
if (points[i][0] > points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
558
|
+
result += ` V ${points[i][1]}`;
|
|
559
|
+
result += ` H ${points[i][0]}`;
|
|
560
|
+
} else {
|
|
561
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
562
|
+
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
563
|
+
result += ` V ${points[i][1]}`;
|
|
564
|
+
result += ` H ${points[i][0]}`;
|
|
565
|
+
}
|
|
566
|
+
} else {
|
|
567
|
+
if (points[i][0] > points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
568
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
569
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
570
|
+
result += ` V ${points[i][1]}`;
|
|
571
|
+
result += ` H ${points[i][0]}`;
|
|
572
|
+
} else {
|
|
573
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
574
|
+
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
575
|
+
result += ` V ${points[i][1]}`;
|
|
576
|
+
result += ` H ${points[i][0]}`;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
break;
|
|
580
|
+
default:
|
|
581
|
+
if (points[i][1] < points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
582
|
+
result += ` V ${points[i - 1][1] + minimumDistanceBeforeTurn}`;
|
|
583
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
584
|
+
result += ` H ${points[i][0]}`;
|
|
585
|
+
}
|
|
586
|
+
result += ` V ${points[i][1]}`;
|
|
587
|
+
currentDirection = Side.Top;
|
|
588
|
+
} else {
|
|
589
|
+
result += ` V ${points[i][1]}`;
|
|
590
|
+
currentDirection = Side.Bottom;
|
|
591
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
592
|
+
result += ` H ${points[i][0]}`;
|
|
593
|
+
currentDirection = points[i][0] > points[i - 1][0] ? Side.Right : Side.Left;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
break;
|
|
599
|
+
case Side.Top:
|
|
600
|
+
switch (nextDirection) {
|
|
601
|
+
case Side.Top:
|
|
602
|
+
if (points[i][1] < points[i - 1][1]) {
|
|
603
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
604
|
+
result += ` V ${(points[i][1] + points[i - 1][1]) / 2}`;
|
|
605
|
+
result += ` H ${points[i][0]}`;
|
|
606
|
+
result += ` V ${points[i][1]}`;
|
|
607
|
+
} else {
|
|
608
|
+
result += ` V ${points[i][1]}`;
|
|
609
|
+
}
|
|
610
|
+
currentDirection = nextDirection;
|
|
611
|
+
} else {
|
|
612
|
+
if (points[i][0] < points[i - 1][0]) {
|
|
613
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
614
|
+
result += ` H ${Math.min(points[i - 1][0], points[i][0]) - minimumDistanceBeforeTurn}`;
|
|
615
|
+
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
616
|
+
result += ` H ${points[i][0]}`;
|
|
617
|
+
result += ` V ${points[i][1]}`;
|
|
618
|
+
} else {
|
|
619
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
620
|
+
result += ` H ${Math.max(points[i - 1][0], points[i][0]) + minimumDistanceBeforeTurn}`;
|
|
621
|
+
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
622
|
+
result += ` H ${points[i][0]}`;
|
|
623
|
+
result += ` V ${points[i][1]}`;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
break;
|
|
627
|
+
case Side.Bottom:
|
|
628
|
+
result += ` V ${Math.min(points[i - 1][1], points[i][1]) - minimumDistanceBeforeTurn}`;
|
|
629
|
+
result += ` H ${points[i][0]}`;
|
|
589
630
|
result += ` V ${points[i][1]}`;
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
631
|
+
break;
|
|
632
|
+
case Side.Right:
|
|
633
|
+
if (points[i][1] < points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
634
|
+
if (points[i][0] > points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
635
|
+
result += ` V ${points[i][1]}`;
|
|
636
|
+
result += ` H ${points[i][0]}`;
|
|
637
|
+
} else {
|
|
638
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
639
|
+
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
640
|
+
result += ` V ${points[i][1]}`;
|
|
641
|
+
result += ` H ${points[i][0]}`;
|
|
642
|
+
}
|
|
643
|
+
} else {
|
|
644
|
+
if (points[i][0] > points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
645
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
646
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
647
|
+
result += ` V ${points[i][1]}`;
|
|
648
|
+
result += ` H ${points[i][0]}`;
|
|
649
|
+
} else {
|
|
650
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
651
|
+
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
652
|
+
result += ` V ${points[i][1]}`;
|
|
653
|
+
result += ` H ${points[i][0]}`;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
break;
|
|
657
|
+
case Side.Left:
|
|
658
|
+
if (points[i][1] < points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
659
|
+
if (points[i][0] < points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
660
|
+
result += ` V ${points[i][1]}`;
|
|
661
|
+
result += ` H ${points[i][0]}`;
|
|
662
|
+
} else {
|
|
663
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
664
|
+
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
665
|
+
result += ` V ${points[i][1]}`;
|
|
666
|
+
result += ` H ${points[i][0]}`;
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
if (points[i][0] < points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
670
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
671
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
672
|
+
result += ` V ${points[i][1]}`;
|
|
673
|
+
result += ` H ${points[i][0]}`;
|
|
674
|
+
} else {
|
|
675
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
676
|
+
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
677
|
+
result += ` V ${points[i][1]}`;
|
|
678
|
+
result += ` H ${points[i][0]}`;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
break;
|
|
682
|
+
default:
|
|
683
|
+
if (points[i][1] > points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
684
|
+
result += ` V ${points[i - 1][1] - minimumDistanceBeforeTurn}`;
|
|
685
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
686
|
+
result += ` H ${points[i][0]}`;
|
|
687
|
+
}
|
|
688
|
+
result += ` V ${points[i][1]}`;
|
|
689
|
+
currentDirection = Side.Bottom;
|
|
690
|
+
} else {
|
|
691
|
+
result += ` V ${points[i][1]}`;
|
|
692
|
+
currentDirection = Side.Top;
|
|
693
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
694
|
+
result += ` H ${points[i][0]}`;
|
|
695
|
+
currentDirection = points[i][0] > points[i - 1][0] ? Side.Right : Side.Left;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
case Side.Left:
|
|
702
|
+
switch (nextDirection) {
|
|
703
|
+
case Side.Left:
|
|
704
|
+
if (points[i][0] < points[i - 1][0]) {
|
|
705
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
706
|
+
result += ` H ${(points[i][0] + points[i - 1][0]) / 2}`;
|
|
707
|
+
result += ` V ${points[i][1]}`;
|
|
708
|
+
result += ` H ${points[i][0]}`;
|
|
709
|
+
} else {
|
|
710
|
+
result += ` H ${points[i][0]}`;
|
|
711
|
+
}
|
|
712
|
+
currentDirection = nextDirection;
|
|
713
|
+
} else {
|
|
714
|
+
if (points[i][1] < points[i - 1][1]) {
|
|
715
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
716
|
+
result += ` V ${Math.min(points[i - 1][1], points[i][1]) - minimumDistanceBeforeTurn}`;
|
|
717
|
+
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
718
|
+
result += ` V ${points[i][1]}`;
|
|
719
|
+
result += ` H ${points[i][0]}`;
|
|
720
|
+
} else {
|
|
721
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
722
|
+
result += ` V ${Math.max(points[i - 1][1], points[i][1]) + minimumDistanceBeforeTurn}`;
|
|
723
|
+
result += ` H ${points[i][0] + minimumDistanceBeforeTurn}`;
|
|
724
|
+
result += ` V ${points[i][1]}`;
|
|
725
|
+
result += ` H ${points[i][0]}`;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
729
|
+
case Side.Right:
|
|
730
|
+
result += ` H ${Math.min(points[i - 1][0], points[i][0]) - minimumDistanceBeforeTurn}`;
|
|
593
731
|
result += ` V ${points[i][1]}`;
|
|
594
732
|
result += ` H ${points[i][0]}`;
|
|
595
|
-
|
|
596
|
-
|
|
733
|
+
break;
|
|
734
|
+
case Side.Bottom:
|
|
735
|
+
if (points[i][0] < points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
736
|
+
if (points[i][1] > points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
737
|
+
result += ` H ${points[i][0]}`;
|
|
738
|
+
result += ` V ${points[i][1]}`;
|
|
739
|
+
} else {
|
|
740
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
741
|
+
result += ` V ${points[i][1] - minimumDistanceBeforeTurn}`;
|
|
742
|
+
result += ` H ${points[i][0]}`;
|
|
743
|
+
result += ` V ${points[i][1]}`;
|
|
744
|
+
}
|
|
745
|
+
} else {
|
|
746
|
+
if (points[i][1] > points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
747
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
748
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
749
|
+
result += ` H ${points[i][0]}`;
|
|
750
|
+
result += ` V ${points[i][1]}`;
|
|
751
|
+
} else {
|
|
752
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
753
|
+
result += ` V ${points[i][1] - minimumDistanceBeforeTurn}`;
|
|
754
|
+
result += ` H ${points[i][0]}`;
|
|
755
|
+
result += ` V ${points[i][1]}`;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
break;
|
|
759
|
+
case Side.Top:
|
|
760
|
+
if (points[i][0] < points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
761
|
+
if (points[i][1] < points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
762
|
+
result += ` H ${points[i][0]}`;
|
|
763
|
+
result += ` V ${points[i][1]}`;
|
|
764
|
+
} else {
|
|
765
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
766
|
+
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
767
|
+
result += ` H ${points[i][0]}`;
|
|
768
|
+
result += ` V ${points[i][1]}`;
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
if (points[i][1] < points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
772
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
773
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
774
|
+
result += ` H ${points[i][0]}`;
|
|
775
|
+
result += ` V ${points[i][1]}`;
|
|
776
|
+
} else {
|
|
777
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
778
|
+
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
779
|
+
result += ` H ${points[i][0]}`;
|
|
780
|
+
result += ` V ${points[i][1]}`;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
break;
|
|
784
|
+
default:
|
|
785
|
+
if (points[i][0] > points[i - 1][0] - minimumDistanceBeforeTurn) {
|
|
786
|
+
result += ` H ${points[i - 1][0] - minimumDistanceBeforeTurn}`;
|
|
787
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
788
|
+
result += ` V ${points[i][1]}`;
|
|
789
|
+
}
|
|
790
|
+
result += ` H ${points[i][0]}`;
|
|
791
|
+
currentDirection = Side.Right;
|
|
792
|
+
} else {
|
|
793
|
+
result += ` H ${points[i][0]}`;
|
|
794
|
+
currentDirection = Side.Left;
|
|
795
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
796
|
+
result += ` V ${points[i][1]}`;
|
|
797
|
+
currentDirection = points[i][1] > points[i - 1][1] ? Side.Bottom : Side.Top;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
break;
|
|
803
|
+
case Side.Right:
|
|
804
|
+
switch (nextDirection) {
|
|
805
|
+
case Side.Right:
|
|
806
|
+
if (points[i][0] > points[i - 1][0]) {
|
|
807
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
808
|
+
result += ` H ${(points[i][0] + points[i - 1][0]) / 2}`;
|
|
809
|
+
result += ` V ${points[i][1]}`;
|
|
810
|
+
result += ` H ${points[i][0]}`;
|
|
811
|
+
} else {
|
|
812
|
+
result += ` H ${points[i][0]}`;
|
|
813
|
+
}
|
|
814
|
+
currentDirection = nextDirection;
|
|
815
|
+
} else {
|
|
816
|
+
if (points[i][1] > points[i - 1][1]) {
|
|
817
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
818
|
+
result += ` V ${Math.max(points[i - 1][1], points[i][1]) + minimumDistanceBeforeTurn}`;
|
|
819
|
+
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
820
|
+
result += ` V ${points[i][1]}`;
|
|
821
|
+
result += ` H ${points[i][0]}`;
|
|
822
|
+
} else {
|
|
823
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
824
|
+
result += ` V ${Math.min(points[i - 1][1], points[i][1]) - minimumDistanceBeforeTurn}`;
|
|
825
|
+
result += ` H ${points[i][0] - minimumDistanceBeforeTurn}`;
|
|
826
|
+
result += ` V ${points[i][1]}`;
|
|
827
|
+
result += ` H ${points[i][0]}`;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
break;
|
|
831
|
+
case Side.Left:
|
|
832
|
+
result += ` H ${Math.max(points[i - 1][0], points[i][0]) + minimumDistanceBeforeTurn}`;
|
|
833
|
+
result += ` V ${points[i][1]}`;
|
|
597
834
|
result += ` H ${points[i][0]}`;
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
835
|
+
break;
|
|
836
|
+
case Side.Top:
|
|
837
|
+
if (points[i][0] > points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
838
|
+
if (points[i][1] < points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
839
|
+
result += ` H ${points[i][0]}`;
|
|
840
|
+
result += ` V ${points[i][1]}`;
|
|
841
|
+
} else {
|
|
842
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
843
|
+
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
844
|
+
result += ` H ${points[i][0]}`;
|
|
845
|
+
result += ` V ${points[i][1]}`;
|
|
846
|
+
}
|
|
847
|
+
} else {
|
|
848
|
+
if (points[i][1] < points[i - 1][1] - minimumDistanceBeforeTurn) {
|
|
849
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
850
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
851
|
+
result += ` H ${points[i][0]}`;
|
|
852
|
+
result += ` V ${points[i][1]}`;
|
|
853
|
+
} else {
|
|
854
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
855
|
+
result += ` V ${points[i][1] + minimumDistanceBeforeTurn}`;
|
|
856
|
+
result += ` H ${points[i][0]}`;
|
|
857
|
+
result += ` V ${points[i][1]}`;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
break;
|
|
861
|
+
case Side.Bottom:
|
|
862
|
+
if (points[i][0] > points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
863
|
+
if (points[i][1] > points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
864
|
+
result += ` H ${points[i][0]}`;
|
|
865
|
+
result += ` V ${points[i][1]}`;
|
|
866
|
+
} else {
|
|
867
|
+
result += ` H ${(points[i - 1][0] + points[i][0]) / 2}`;
|
|
868
|
+
result += ` V ${points[i][1] - minimumDistanceBeforeTurn}`;
|
|
869
|
+
result += ` H ${points[i][0]}`;
|
|
870
|
+
result += ` V ${points[i][1]}`;
|
|
871
|
+
}
|
|
872
|
+
} else {
|
|
873
|
+
if (points[i][1] > points[i - 1][1] + minimumDistanceBeforeTurn) {
|
|
874
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
875
|
+
result += ` V ${(points[i - 1][1] + points[i][1]) / 2}`;
|
|
876
|
+
result += ` H ${points[i][0]}`;
|
|
877
|
+
result += ` V ${points[i][1]}`;
|
|
878
|
+
} else {
|
|
879
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
880
|
+
result += ` V ${points[i][1] - minimumDistanceBeforeTurn}`;
|
|
881
|
+
result += ` H ${points[i][0]}`;
|
|
882
|
+
result += ` V ${points[i][1]}`;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
break;
|
|
886
|
+
default:
|
|
887
|
+
if (points[i][0] < points[i - 1][0] + minimumDistanceBeforeTurn) {
|
|
888
|
+
result += ` H ${points[i - 1][0] + minimumDistanceBeforeTurn}`;
|
|
889
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
890
|
+
result += ` V ${points[i][1]}`;
|
|
891
|
+
}
|
|
892
|
+
result += ` H ${points[i][0]}`;
|
|
893
|
+
currentDirection = Side.Left;
|
|
894
|
+
} else {
|
|
895
|
+
result += ` H ${points[i][0]}`;
|
|
896
|
+
currentDirection = Side.Right;
|
|
897
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
898
|
+
result += ` V ${points[i][1]}`;
|
|
899
|
+
currentDirection = points[i][1] > points[i - 1][1] ? Side.Bottom : Side.Top;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
break;
|
|
903
|
+
}
|
|
904
|
+
break;
|
|
905
|
+
default:
|
|
906
|
+
if (points[i][0] !== points[i - 1][0]) {
|
|
907
|
+
result += ` H ${points[i][0]}`;
|
|
908
|
+
currentDirection = points[i][0] > points[i - 1][0] ? Side.Right : Side.Left;
|
|
909
|
+
}
|
|
910
|
+
if (points[i][1] !== points[i - 1][1]) {
|
|
911
|
+
result += ` V ${points[i][1]}`;
|
|
912
|
+
currentDirection = points[i][1] > points[i - 1][1] ? Side.Bottom : Side.Top;
|
|
913
|
+
}
|
|
610
914
|
}
|
|
611
915
|
}
|
|
612
916
|
break;
|
|
@@ -904,13 +1208,14 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
904
1208
|
const extractLooksFromConfig = lookConfig => {
|
|
905
1209
|
const {
|
|
906
1210
|
selected,
|
|
907
|
-
highlighted
|
|
1211
|
+
highlighted,
|
|
1212
|
+
selectedAndHighlighted
|
|
908
1213
|
} = lookConfig,
|
|
909
|
-
rest = __rest(lookConfig, ["selected", "highlighted"]);
|
|
1214
|
+
rest = __rest(lookConfig, ["selected", "highlighted", "selectedAndHighlighted"]);
|
|
910
1215
|
const defaultLook = rest;
|
|
911
1216
|
const selectedLook = Object.assign(Object.assign({}, defaultLook), selected);
|
|
912
1217
|
const highlightedLook = Object.assign(Object.assign({}, defaultLook), highlighted);
|
|
913
|
-
const selectedAndHighlightedLook = Object.assign(Object.assign(Object.assign({}, defaultLook), highlighted), selected);
|
|
1218
|
+
const selectedAndHighlightedLook = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultLook), highlighted), selected), selectedAndHighlighted);
|
|
914
1219
|
return {
|
|
915
1220
|
defaultLook,
|
|
916
1221
|
selectedLook,
|
|
@@ -1922,23 +2227,38 @@ class DiagramConnection extends DiagramElement {
|
|
|
1922
2227
|
}
|
|
1923
2228
|
}
|
|
1924
2229
|
}
|
|
2230
|
+
/**
|
|
2231
|
+
* An alias for the `lookConfig` attribute.
|
|
2232
|
+
* @private
|
|
2233
|
+
*/
|
|
2234
|
+
set look(look) {
|
|
2235
|
+
this.lookConfig = look;
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Look configuration used to derive the current look of this connection.
|
|
2239
|
+
* @private
|
|
2240
|
+
*/
|
|
2241
|
+
get lookConfig() {
|
|
2242
|
+
return this._lookConfig;
|
|
2243
|
+
}
|
|
1925
2244
|
/**
|
|
1926
2245
|
* Sets the look configuration of the connection to override the one determined by the type.
|
|
1927
2246
|
* `undefined` resets it to the one determined by the type.
|
|
1928
2247
|
* @private
|
|
1929
2248
|
*/
|
|
1930
|
-
set
|
|
1931
|
-
|
|
1932
|
-
|
|
2249
|
+
set lookConfig(lookConfig) {
|
|
2250
|
+
this._lookConfig = lookConfig;
|
|
2251
|
+
if (lookConfig) {
|
|
2252
|
+
const looks = extractLooksFromConfig(lookConfig);
|
|
1933
2253
|
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
1934
2254
|
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
1935
2255
|
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
1936
2256
|
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
1937
2257
|
} else {
|
|
1938
|
-
this._defaultLook =
|
|
1939
|
-
this._selectedLook =
|
|
1940
|
-
this._highlightedLook =
|
|
1941
|
-
this._selectedAndHighlightedLook =
|
|
2258
|
+
this._defaultLook = lookConfig;
|
|
2259
|
+
this._selectedLook = lookConfig;
|
|
2260
|
+
this._highlightedLook = lookConfig;
|
|
2261
|
+
this._selectedAndHighlightedLook = lookConfig;
|
|
1942
2262
|
}
|
|
1943
2263
|
}
|
|
1944
2264
|
/**
|
|
@@ -1960,23 +2280,38 @@ class DiagramConnection extends DiagramElement {
|
|
|
1960
2280
|
}
|
|
1961
2281
|
}
|
|
1962
2282
|
}
|
|
2283
|
+
/**
|
|
2284
|
+
* An alias for the `lookConfig` attribute.
|
|
2285
|
+
* @private
|
|
2286
|
+
*/
|
|
2287
|
+
set startMarkerLook(startMarkerLook) {
|
|
2288
|
+
this.startMarkerLookConfig = startMarkerLook;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Look configuration used to derive the current look of the start marker of this connection.
|
|
2292
|
+
* @private
|
|
2293
|
+
*/
|
|
2294
|
+
get startMarkerLookConfig() {
|
|
2295
|
+
return this._startMarkerLookConfig;
|
|
2296
|
+
}
|
|
1963
2297
|
/**
|
|
1964
2298
|
* Sets the look configuration of the start marker to override the one determined by the type.
|
|
1965
2299
|
* `null` stands for no marker and `undefined` resets it to the one determined by the type.
|
|
1966
2300
|
* @private
|
|
1967
2301
|
*/
|
|
1968
|
-
set
|
|
1969
|
-
|
|
1970
|
-
|
|
2302
|
+
set startMarkerLookConfig(startMarkerLookConfig) {
|
|
2303
|
+
this._startMarkerLookConfig = startMarkerLookConfig;
|
|
2304
|
+
if (startMarkerLookConfig) {
|
|
2305
|
+
const looks = extractLooksFromConfig(startMarkerLookConfig);
|
|
1971
2306
|
this._defaultStartMarkerLook = Object.assign(Object.assign({}, this._defaultStartMarkerLook), looks.defaultLook);
|
|
1972
2307
|
this._selectedStartMarkerLook = Object.assign(Object.assign({}, this._selectedStartMarkerLook), looks.selectedLook);
|
|
1973
2308
|
this._highlightedStartMarkerLook = Object.assign(Object.assign({}, this._highlightedStartMarkerLook), looks.highlightedLook);
|
|
1974
2309
|
this._selectedAndHighlightedStartMarkerLook = Object.assign(Object.assign({}, this._selectedAndHighlightedStartMarkerLook), looks.selectedAndHighlightedLook);
|
|
1975
2310
|
} else {
|
|
1976
|
-
this._defaultStartMarkerLook =
|
|
1977
|
-
this._selectedStartMarkerLook =
|
|
1978
|
-
this._highlightedStartMarkerLook =
|
|
1979
|
-
this._selectedAndHighlightedStartMarkerLook =
|
|
2311
|
+
this._defaultStartMarkerLook = startMarkerLookConfig;
|
|
2312
|
+
this._selectedStartMarkerLook = startMarkerLookConfig;
|
|
2313
|
+
this._highlightedStartMarkerLook = startMarkerLookConfig;
|
|
2314
|
+
this._selectedAndHighlightedStartMarkerLook = startMarkerLookConfig;
|
|
1980
2315
|
}
|
|
1981
2316
|
}
|
|
1982
2317
|
/**
|
|
@@ -1998,23 +2333,38 @@ class DiagramConnection extends DiagramElement {
|
|
|
1998
2333
|
}
|
|
1999
2334
|
}
|
|
2000
2335
|
}
|
|
2336
|
+
/**
|
|
2337
|
+
* An alias for the `lookConfig` attribute.
|
|
2338
|
+
* @private
|
|
2339
|
+
*/
|
|
2340
|
+
set endMarkerLook(endMarkerLook) {
|
|
2341
|
+
this.endMarkerLookConfig = endMarkerLook;
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Look configuration used to derive the current look of the end marker of this connection.
|
|
2345
|
+
* @private
|
|
2346
|
+
*/
|
|
2347
|
+
get endMarkerLookConfig() {
|
|
2348
|
+
return this._endMarkerLookConfig;
|
|
2349
|
+
}
|
|
2001
2350
|
/**
|
|
2002
2351
|
* Sets the look configuration of the end marker to override the one determined by the type.
|
|
2003
2352
|
* `null` stands for no marker and `undefined` resets it to the one determined by the type.
|
|
2004
2353
|
* @private
|
|
2005
2354
|
*/
|
|
2006
|
-
set
|
|
2007
|
-
|
|
2008
|
-
|
|
2355
|
+
set endMarkerLookConfig(endMarkerLookConfig) {
|
|
2356
|
+
this._endMarkerLookConfig = endMarkerLookConfig;
|
|
2357
|
+
if (endMarkerLookConfig) {
|
|
2358
|
+
const looks = extractLooksFromConfig(endMarkerLookConfig);
|
|
2009
2359
|
this._defaultEndMarkerLook = Object.assign(Object.assign({}, this._defaultEndMarkerLook), looks.defaultLook);
|
|
2010
2360
|
this._selectedEndMarkerLook = Object.assign(Object.assign({}, this._selectedEndMarkerLook), looks.selectedLook);
|
|
2011
2361
|
this._highlightedEndMarkerLook = Object.assign(Object.assign({}, this._highlightedEndMarkerLook), looks.highlightedLook);
|
|
2012
2362
|
this._selectedAndHighlightedEndMarkerLook = Object.assign(Object.assign({}, this._selectedAndHighlightedEndMarkerLook), looks.selectedAndHighlightedLook);
|
|
2013
2363
|
} else {
|
|
2014
|
-
this._defaultEndMarkerLook =
|
|
2015
|
-
this._selectedEndMarkerLook =
|
|
2016
|
-
this._highlightedEndMarkerLook =
|
|
2017
|
-
this._selectedAndHighlightedEndMarkerLook =
|
|
2364
|
+
this._defaultEndMarkerLook = endMarkerLookConfig;
|
|
2365
|
+
this._selectedEndMarkerLook = endMarkerLookConfig;
|
|
2366
|
+
this._highlightedEndMarkerLook = endMarkerLookConfig;
|
|
2367
|
+
this._selectedAndHighlightedEndMarkerLook = endMarkerLookConfig;
|
|
2018
2368
|
}
|
|
2019
2369
|
}
|
|
2020
2370
|
constructor(model, type, start, end, id) {
|
|
@@ -2689,23 +3039,38 @@ class DiagramSection extends DiagramElement {
|
|
|
2689
3039
|
}
|
|
2690
3040
|
}
|
|
2691
3041
|
}
|
|
3042
|
+
/**
|
|
3043
|
+
* An alias for the `lookConfig` attribute.
|
|
3044
|
+
* @private
|
|
3045
|
+
*/
|
|
3046
|
+
set look(look) {
|
|
3047
|
+
this.lookConfig = look;
|
|
3048
|
+
}
|
|
3049
|
+
/**
|
|
3050
|
+
* Look configuration used to derive the current look of this section.
|
|
3051
|
+
* @private
|
|
3052
|
+
*/
|
|
3053
|
+
get lookConfig() {
|
|
3054
|
+
return this._lookConfig;
|
|
3055
|
+
}
|
|
2692
3056
|
/**
|
|
2693
3057
|
* Sets the look configuration of the look to override the one determined by the type.
|
|
2694
3058
|
* `undefined` resets it to the one determined by the type.
|
|
2695
3059
|
* @private
|
|
2696
3060
|
*/
|
|
2697
|
-
set
|
|
2698
|
-
|
|
2699
|
-
|
|
3061
|
+
set lookConfig(lookConfig) {
|
|
3062
|
+
this._lookConfig = lookConfig;
|
|
3063
|
+
if (lookConfig) {
|
|
3064
|
+
const looks = extractLooksFromConfig(lookConfig);
|
|
2700
3065
|
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
2701
3066
|
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
2702
3067
|
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
2703
3068
|
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
2704
3069
|
} else {
|
|
2705
|
-
this._defaultLook =
|
|
2706
|
-
this._selectedLook =
|
|
2707
|
-
this._highlightedLook =
|
|
2708
|
-
this._selectedAndHighlightedLook =
|
|
3070
|
+
this._defaultLook = lookConfig;
|
|
3071
|
+
this._selectedLook = lookConfig;
|
|
3072
|
+
this._highlightedLook = lookConfig;
|
|
3073
|
+
this._selectedAndHighlightedLook = lookConfig;
|
|
2709
3074
|
}
|
|
2710
3075
|
}
|
|
2711
3076
|
constructor(model, node, indexXInNode, indexYInNode, coords, width, height, id) {
|
|
@@ -3088,6 +3453,7 @@ const DIAGRAM_NODE_TYPE_DEFAULTS = {
|
|
|
3088
3453
|
minHeight: 1,
|
|
3089
3454
|
resizableX: false,
|
|
3090
3455
|
resizableY: false,
|
|
3456
|
+
snapToGridOffset: [0, 0, 0, 0],
|
|
3091
3457
|
padding: 0,
|
|
3092
3458
|
label: null,
|
|
3093
3459
|
ports: [],
|
|
@@ -3116,6 +3482,7 @@ class DiagramNodeType {
|
|
|
3116
3482
|
this.minHeight = values.minHeight;
|
|
3117
3483
|
this.resizableX = values.resizableX;
|
|
3118
3484
|
this.resizableY = values.resizableY;
|
|
3485
|
+
this.snapToGridOffset = values.snapToGridOffset;
|
|
3119
3486
|
this.bottomPadding = getBottomPadding(values);
|
|
3120
3487
|
this.leftPadding = getLeftPadding(values);
|
|
3121
3488
|
this.rightPadding = getRightPadding(values);
|
|
@@ -3201,23 +3568,38 @@ class DiagramNode extends DiagramElement {
|
|
|
3201
3568
|
}
|
|
3202
3569
|
}
|
|
3203
3570
|
}
|
|
3571
|
+
/**
|
|
3572
|
+
* An alias for the `lookConfig` attribute.
|
|
3573
|
+
* @private
|
|
3574
|
+
*/
|
|
3575
|
+
set look(look) {
|
|
3576
|
+
this.lookConfig = look;
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* Look configuration used to derive the current look of this node.
|
|
3580
|
+
* @private
|
|
3581
|
+
*/
|
|
3582
|
+
get lookConfig() {
|
|
3583
|
+
return this._lookConfig;
|
|
3584
|
+
}
|
|
3204
3585
|
/**
|
|
3205
3586
|
* Sets the look configuration of the look to override the one determined by the type.
|
|
3206
3587
|
* `undefined` resets it to the one determined by the type.
|
|
3207
3588
|
* @private
|
|
3208
3589
|
*/
|
|
3209
|
-
set
|
|
3210
|
-
|
|
3211
|
-
|
|
3590
|
+
set lookConfig(lookConfig) {
|
|
3591
|
+
this._lookConfig = lookConfig;
|
|
3592
|
+
if (lookConfig) {
|
|
3593
|
+
const looks = extractLooksFromConfig(lookConfig);
|
|
3212
3594
|
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
3213
3595
|
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
3214
3596
|
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
3215
3597
|
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
3216
3598
|
} else {
|
|
3217
|
-
this._defaultLook =
|
|
3218
|
-
this._selectedLook =
|
|
3219
|
-
this._highlightedLook =
|
|
3220
|
-
this._selectedAndHighlightedLook =
|
|
3599
|
+
this._defaultLook = lookConfig;
|
|
3600
|
+
this._selectedLook = lookConfig;
|
|
3601
|
+
this._highlightedLook = lookConfig;
|
|
3602
|
+
this._selectedAndHighlightedLook = lookConfig;
|
|
3221
3603
|
}
|
|
3222
3604
|
}
|
|
3223
3605
|
constructor(model, type, coords = [0, 0], id) {
|
|
@@ -4229,23 +4611,38 @@ class DiagramPort extends DiagramElement {
|
|
|
4229
4611
|
}
|
|
4230
4612
|
}
|
|
4231
4613
|
}
|
|
4614
|
+
/**
|
|
4615
|
+
* An alias for the `lookConfig` attribute.
|
|
4616
|
+
* @private
|
|
4617
|
+
*/
|
|
4618
|
+
set look(look) {
|
|
4619
|
+
this.lookConfig = look;
|
|
4620
|
+
}
|
|
4621
|
+
/**
|
|
4622
|
+
* Look configuration used to derive the current look of this port.
|
|
4623
|
+
* @private
|
|
4624
|
+
*/
|
|
4625
|
+
get lookConfig() {
|
|
4626
|
+
return this._lookConfig;
|
|
4627
|
+
}
|
|
4232
4628
|
/**
|
|
4233
4629
|
* Sets the look configuration of the look to override the one determined by the type.
|
|
4234
4630
|
* `undefined` resets it to the one determined by the type.
|
|
4235
4631
|
* @private
|
|
4236
4632
|
*/
|
|
4237
|
-
set
|
|
4238
|
-
|
|
4239
|
-
|
|
4633
|
+
set lookConfig(lookConfig) {
|
|
4634
|
+
this._lookConfig = lookConfig;
|
|
4635
|
+
if (lookConfig) {
|
|
4636
|
+
const looks = extractLooksFromConfig(lookConfig);
|
|
4240
4637
|
this._defaultLook = Object.assign(Object.assign({}, this._defaultLook), looks.defaultLook);
|
|
4241
4638
|
this._selectedLook = Object.assign(Object.assign({}, this._selectedLook), looks.selectedLook);
|
|
4242
4639
|
this._highlightedLook = Object.assign(Object.assign({}, this._highlightedLook), looks.highlightedLook);
|
|
4243
4640
|
this._selectedAndHighlightedLook = Object.assign(Object.assign({}, this._selectedAndHighlightedLook), looks.selectedAndHighlightedLook);
|
|
4244
4641
|
} else {
|
|
4245
|
-
this._defaultLook =
|
|
4246
|
-
this._selectedLook =
|
|
4247
|
-
this._highlightedLook =
|
|
4248
|
-
this._selectedAndHighlightedLook =
|
|
4642
|
+
this._defaultLook = lookConfig;
|
|
4643
|
+
this._selectedLook = lookConfig;
|
|
4644
|
+
this._highlightedLook = lookConfig;
|
|
4645
|
+
this._selectedAndHighlightedLook = lookConfig;
|
|
4249
4646
|
}
|
|
4250
4647
|
}
|
|
4251
4648
|
/**
|
|
@@ -6687,12 +7084,12 @@ class DagaExporter {
|
|
|
6687
7084
|
}
|
|
6688
7085
|
|
|
6689
7086
|
/**
|
|
6690
|
-
* Text to display as the title of the property editor when editing the properties of a diagram's value set.
|
|
7087
|
+
* Text to display by default as the title of the property editor when editing the properties of a diagram's value set.
|
|
6691
7088
|
* @private
|
|
6692
7089
|
* @see PropertyEditorComponent
|
|
6693
7090
|
* @see ValueSet
|
|
6694
7091
|
*/
|
|
6695
|
-
const
|
|
7092
|
+
const DIAGRAM_PROPERTIES_DEFAULT_TEXT = 'Diagram properties';
|
|
6696
7093
|
/**
|
|
6697
7094
|
* Stores the functionality regarding the user highlight of a diagram canvas.
|
|
6698
7095
|
* @public
|
|
@@ -6704,12 +7101,14 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
6704
7101
|
* @public
|
|
6705
7102
|
* @param canvas A canvas.
|
|
6706
7103
|
*/
|
|
6707
|
-
constructor(canvas) {
|
|
7104
|
+
constructor(canvas, diagramPropertiesText) {
|
|
6708
7105
|
super();
|
|
6709
7106
|
this.canvas = canvas;
|
|
6710
7107
|
this.canvas.propertyEditorChanges$.pipe(debounceTime(2000)).subscribe(() => {
|
|
6711
7108
|
this.makeUpdateValuesAction();
|
|
6712
7109
|
});
|
|
7110
|
+
console.log(diagramPropertiesText);
|
|
7111
|
+
this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
|
|
6713
7112
|
}
|
|
6714
7113
|
add(element) {
|
|
6715
7114
|
if (this.contains(element.id)) {
|
|
@@ -6904,7 +7303,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
6904
7303
|
propertyEditor.valueSet = undefined;
|
|
6905
7304
|
propertyEditor.valueSet = selectedValueSet;
|
|
6906
7305
|
} else {
|
|
6907
|
-
propertyEditor.title =
|
|
7306
|
+
propertyEditor.title = this.diagramPropertiesText;
|
|
6908
7307
|
// force the update of the valueSet
|
|
6909
7308
|
propertyEditor.valueSet = undefined;
|
|
6910
7309
|
propertyEditor.valueSet = selectedValueSet;
|
|
@@ -6994,7 +7393,7 @@ class DiagramCanvas {
|
|
|
6994
7393
|
* @param config The configuration object used to set the parameters of this canvas.
|
|
6995
7394
|
*/
|
|
6996
7395
|
constructor(parentComponent, config) {
|
|
6997
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
7396
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
6998
7397
|
this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
|
|
6999
7398
|
this.zoomTransform = d3.zoomIdentity;
|
|
7000
7399
|
// used to distinguish drags from clicks when dragging elements and during multiple selection
|
|
@@ -7009,25 +7408,25 @@ class DiagramCanvas {
|
|
|
7009
7408
|
this.propertyEditorChanges$ = new Subject();
|
|
7010
7409
|
this.parentComponent = parentComponent;
|
|
7011
7410
|
this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
|
|
7012
|
-
this.userSelection = new DiagramUserSelection(this);
|
|
7013
|
-
this.userHighlight = new DiagramUserHighlight(this, ((
|
|
7014
|
-
this.contextMenu = new DiagramContextMenu(this, (
|
|
7015
|
-
this.backgroundColor = ((
|
|
7016
|
-
this.gridStyle = (
|
|
7017
|
-
this.gridSize = ((
|
|
7018
|
-
this.gridThickness = Math.abs(((
|
|
7019
|
-
this.gridColor = ((
|
|
7020
|
-
this.snapToGrid = ((
|
|
7021
|
-
this.zoomFactor = ((
|
|
7022
|
-
this.panRate = ((
|
|
7023
|
-
this.inferConnectionType = ((
|
|
7024
|
-
this.autoTightenConnections = ((
|
|
7025
|
-
this.allowConnectionLoops = ((
|
|
7026
|
-
this.allowSharingPorts = ((
|
|
7027
|
-
this.allowSharingBothPorts = ((
|
|
7028
|
-
this.portHighlightRadius = ((
|
|
7411
|
+
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);
|
|
7412
|
+
this.userHighlight = new DiagramUserHighlight(this, ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.highlightSections) !== false);
|
|
7413
|
+
this.contextMenu = new DiagramContextMenu(this, (_d = config.canvas) === null || _d === void 0 ? void 0 : _d.contextMenu);
|
|
7414
|
+
this.backgroundColor = ((_e = config.canvas) === null || _e === void 0 ? void 0 : _e.backgroundColor) || '#FFFFFF';
|
|
7415
|
+
this.gridStyle = (_h = (_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.grid) === null || _g === void 0 ? void 0 : _g.style) !== null && _h !== void 0 ? _h : GRID_DEFAULTS.style;
|
|
7416
|
+
this.gridSize = ((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === null || _k === void 0 ? void 0 : _k.enabled) === false || ((_l = config.canvas) === null || _l === void 0 ? void 0 : _l.grid) === undefined ? 0 : Math.abs(((_o = (_m = config.canvas) === null || _m === void 0 ? void 0 : _m.grid) === null || _o === void 0 ? void 0 : _o.spacing) || GRID_DEFAULTS.spacing);
|
|
7417
|
+
this.gridThickness = Math.abs(((_q = (_p = config.canvas) === null || _p === void 0 ? void 0 : _p.grid) === null || _q === void 0 ? void 0 : _q.thickness) || GRID_DEFAULTS.thickness);
|
|
7418
|
+
this.gridColor = ((_s = (_r = config.canvas) === null || _r === void 0 ? void 0 : _r.grid) === null || _s === void 0 ? void 0 : _s.color) || GRID_DEFAULTS.color;
|
|
7419
|
+
this.snapToGrid = ((_u = (_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === null || _u === void 0 ? void 0 : _u.enabled) === false || ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.grid) === undefined ? false : ((_x = (_w = config.canvas) === null || _w === void 0 ? void 0 : _w.grid) === null || _x === void 0 ? void 0 : _x.snap) || GRID_DEFAULTS.snap;
|
|
7420
|
+
this.zoomFactor = ((_y = config.canvas) === null || _y === void 0 ? void 0 : _y.zoomFactor) || 2;
|
|
7421
|
+
this.panRate = ((_z = config.canvas) === null || _z === void 0 ? void 0 : _z.panRate) || 100;
|
|
7422
|
+
this.inferConnectionType = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.inferConnectionType) || false;
|
|
7423
|
+
this.autoTightenConnections = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.autoTighten) !== false;
|
|
7424
|
+
this.allowConnectionLoops = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.allowLoops) || false;
|
|
7425
|
+
this.allowSharingPorts = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.sharePorts) !== false;
|
|
7426
|
+
this.allowSharingBothPorts = ((_4 = config.connectionSettings) === null || _4 === void 0 ? void 0 : _4.shareBothPorts) || false;
|
|
7427
|
+
this.portHighlightRadius = ((_5 = config.connectionSettings) === null || _5 === void 0 ? void 0 : _5.portHighlightRadius) || 100;
|
|
7029
7428
|
this.multipleSelectionOn = false;
|
|
7030
|
-
this.priorityThresholds = ((
|
|
7429
|
+
this.priorityThresholds = ((_6 = config.canvas) === null || _6 === void 0 ? void 0 : _6.priorityThresholds) || [];
|
|
7031
7430
|
this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
|
|
7032
7431
|
this.layoutFormat = config.layoutFormat;
|
|
7033
7432
|
this.userActions = config.userActions || {};
|
|
@@ -7054,7 +7453,7 @@ class DiagramCanvas {
|
|
|
7054
7453
|
const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
|
|
7055
7454
|
this.model.connections.types.add(connectionType);
|
|
7056
7455
|
}
|
|
7057
|
-
this._connectionType = ((
|
|
7456
|
+
this._connectionType = ((_7 = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _7 === void 0 ? void 0 : _7.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
|
|
7058
7457
|
}
|
|
7059
7458
|
}
|
|
7060
7459
|
addValidator(validator) {
|
|
@@ -7281,8 +7680,8 @@ class DiagramCanvas {
|
|
|
7281
7680
|
const deselectedElements = this.userSelection.all();
|
|
7282
7681
|
this.userSelection.clear();
|
|
7283
7682
|
this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
|
|
7284
|
-
this.userSelection.openInPropertyEditor(this.model);
|
|
7285
7683
|
}
|
|
7684
|
+
this.userSelection.openInPropertyEditor(this.model);
|
|
7286
7685
|
}).call(d3.drag().filter(event => {
|
|
7287
7686
|
return this.multipleSelectionOn || isSecondaryButton(event);
|
|
7288
7687
|
}).on(DragEvents.Start, event => {
|
|
@@ -7489,7 +7888,9 @@ class DiagramCanvas {
|
|
|
7489
7888
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.type.resizableX && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
7490
7889
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7491
7890
|
if (this.snapToGrid) {
|
|
7492
|
-
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
7891
|
+
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
7892
|
+
pointerCoords[0] += d.type.snapToGridOffset[0];
|
|
7893
|
+
pointerCoords[1] += d.type.snapToGridOffset[1];
|
|
7493
7894
|
}
|
|
7494
7895
|
d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
|
|
7495
7896
|
this.currentAction.to = d.getGeometry();
|
|
@@ -7523,7 +7924,9 @@ class DiagramCanvas {
|
|
|
7523
7924
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.type.resizableY && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
7524
7925
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7525
7926
|
if (this.snapToGrid) {
|
|
7526
|
-
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
7927
|
+
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
|
|
7928
|
+
pointerCoords[0] += d.type.snapToGridOffset[0];
|
|
7929
|
+
pointerCoords[1] += d.type.snapToGridOffset[1];
|
|
7527
7930
|
}
|
|
7528
7931
|
d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
|
|
7529
7932
|
this.currentAction.to = d.getGeometry();
|
|
@@ -7557,7 +7960,9 @@ class DiagramCanvas {
|
|
|
7557
7960
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.type.resizableX && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
7558
7961
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7559
7962
|
if (this.snapToGrid) {
|
|
7560
|
-
pointerCoords = this.getClosestGridPoint(pointerCoords);
|
|
7963
|
+
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
7964
|
+
pointerCoords[0] += d.type.snapToGridOffset[2];
|
|
7965
|
+
pointerCoords[1] += d.type.snapToGridOffset[3];
|
|
7561
7966
|
}
|
|
7562
7967
|
d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
|
|
7563
7968
|
this.currentAction.to = d.getGeometry();
|
|
@@ -7591,7 +7996,11 @@ class DiagramCanvas {
|
|
|
7591
7996
|
if (this.canUserPerformAction(DiagramActions.StretchNode) && d.type.resizableY && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
|
|
7592
7997
|
let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
|
|
7593
7998
|
if (this.snapToGrid) {
|
|
7594
|
-
|
|
7999
|
+
if (this.snapToGrid) {
|
|
8000
|
+
pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
|
|
8001
|
+
pointerCoords[0] += d.type.snapToGridOffset[2];
|
|
8002
|
+
pointerCoords[1] += d.type.snapToGridOffset[3];
|
|
8003
|
+
}
|
|
7595
8004
|
}
|
|
7596
8005
|
d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
|
|
7597
8006
|
this.currentAction.to = d.getGeometry();
|
|
@@ -8841,7 +9250,9 @@ class DiagramCanvas {
|
|
|
8841
9250
|
if (this.draggingFrom[0] !== event.x || this.draggingFrom[1] !== event.y) {
|
|
8842
9251
|
let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
|
|
8843
9252
|
if (this.snapToGrid) {
|
|
8844
|
-
newNodeCoords = this.getClosestGridPoint(newNodeCoords);
|
|
9253
|
+
newNodeCoords = this.getClosestGridPoint([newNodeCoords[0] - d.type.snapToGridOffset[0], newNodeCoords[1] - d.type.snapToGridOffset[1]]);
|
|
9254
|
+
newNodeCoords[0] += d.type.snapToGridOffset[0];
|
|
9255
|
+
newNodeCoords[1] += d.type.snapToGridOffset[1];
|
|
8845
9256
|
}
|
|
8846
9257
|
if (this.currentAction instanceof MoveAction) {
|
|
8847
9258
|
const movingFrom = this.currentAction.delta;
|
|
@@ -9535,7 +9946,9 @@ class ForceLayout {
|
|
|
9535
9946
|
}
|
|
9536
9947
|
if (model.canvas && model.canvas.snapToGrid) {
|
|
9537
9948
|
for (const node of model.nodes) {
|
|
9538
|
-
const snappedCoords = model.canvas.getClosestGridPoint(node.coords);
|
|
9949
|
+
const snappedCoords = model.canvas.getClosestGridPoint([node.coords[0] - node.type.snapToGridOffset[0], node.coords[1] - node.type.snapToGridOffset[1]]);
|
|
9950
|
+
snappedCoords[0] += node.type.snapToGridOffset[0];
|
|
9951
|
+
snappedCoords[1] += node.type.snapToGridOffset[1];
|
|
9539
9952
|
node.move(snappedCoords);
|
|
9540
9953
|
}
|
|
9541
9954
|
}
|