mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-09 19:41:14 +00:00
reimplementation of adding links
This commit is contained in:
parent
9e05dfc2e7
commit
86c13644a8
@ -38,6 +38,9 @@ export class LinkCreatedComponent implements OnInit, OnDestroy {
|
||||
const xLength = Math.abs(linkCreated.sourceNode.x - linkCreated.targetNode.x);
|
||||
const yLength = Math.abs(linkCreated.sourceNode.y - linkCreated.targetNode.y);
|
||||
const zLength = Math.sqrt(Math.pow(xLength, 2) + Math.pow(yLength, 2));
|
||||
//from law of sines
|
||||
const sinY = yLength/zLength;
|
||||
|
||||
const x = (45 / zLength) * xLength;
|
||||
const y = (45 / zLength) * yLength;
|
||||
|
||||
@ -49,21 +52,21 @@ export class LinkCreatedComponent implements OnInit, OnDestroy {
|
||||
if ((linkCreated.sourceNode.x <= linkCreated.targetNode.x) && (linkCreated.sourceNode.y <= linkCreated.targetNode.y)) {
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) + Math.round(x) + 5;
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) + Math.round(y) + 5;
|
||||
xLabelTargetNode = Math.floor(linkCreated.targetNode.width/2) - Math.round(x) - 25;
|
||||
yLabelTargetNode = Math.floor(linkCreated.targetNode.height/2) - Math.round(y) - 25;
|
||||
xLabelTargetNode = Math.floor(linkCreated.targetNode.width/2) - Math.round(x) - 5 - Math.round(20 * sinY);
|
||||
yLabelTargetNode = Math.floor(linkCreated.targetNode.height/2) - Math.round(y) + 5 - Math.round(20 * sinY);
|
||||
} else if ((linkCreated.sourceNode.x > linkCreated.targetNode.x) && (linkCreated.sourceNode.y < linkCreated.targetNode.y)) {
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) - Math.round(x) - 15;
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) + Math.round(y) + 15;
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) - Math.round(x) - 5 - Math.round(20 * sinY);
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) + Math.round(y) + 5 - Math.round(20 * sinY);
|
||||
xLabelTargetNode = Math.floor(linkCreated.targetNode.width/2) + Math.round(x) + 5;
|
||||
yLabelTargetNode = Math.floor(linkCreated.targetNode.height/2) - Math.round(y) - 5;
|
||||
} else if ((linkCreated.sourceNode.x < linkCreated.targetNode.x) && (linkCreated.sourceNode.y > linkCreated.targetNode.y)) {
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) + Math.round(x) + 25;
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) - Math.round(y) - 25;
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) + Math.round(x) + 5 - Math.round(20 * sinY);
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) - Math.round(y) - 5 - Math.round(20 * sinY);
|
||||
xLabelTargetNode = Math.floor(linkCreated.targetNode.width/2) - Math.round(x) - 5;
|
||||
yLabelTargetNode = Math.floor(linkCreated.targetNode.height/2) + Math.round(y) + 5;
|
||||
} else if ((linkCreated.sourceNode.x >= linkCreated.targetNode.x) && (linkCreated.sourceNode.y >= linkCreated.targetNode.y)) {
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) - Math.round(x) - 25;
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) - Math.round(y) - 25;
|
||||
xLabelSourceNode = Math.floor(linkCreated.sourceNode.width/2) - Math.round(x) - 5 - Math.round(20 * sinY);
|
||||
yLabelSourceNode = Math.floor(linkCreated.sourceNode.height/2) - Math.round(y) + 5 - Math.round(20 * sinY);
|
||||
xLabelTargetNode = Math.floor(linkCreated.targetNode.width/2) + Math.round(x) + 5;
|
||||
yLabelTargetNode = Math.floor(linkCreated.targetNode.height/2) + Math.round(y) + 5;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user