Calculates points relatively to (0,0)

This commit is contained in:
ziajka
2017-12-05 10:54:37 +01:00
parent 72bdeceb20
commit d2a2c60db1
3 changed files with 10 additions and 5 deletions

View File

@ -90,7 +90,7 @@ export class LinksWidget implements Widget {
.attr('transform', function(l) { .attr('transform', function(l) {
if (l.source && l.target) { if (l.source && l.target) {
const translation = self.multiLinkCalculatorHelper.linkTranslation(l.distance, l.source, l.target); const translation = self.multiLinkCalculatorHelper.linkTranslation(l.distance, l.source, l.target);
return `translate (${translation.dx + l.source.width / 2.}, ${translation.dy + l.source.height / 2.})`; return `translate (${translation.dx}, ${translation.dy})`;
} }
return null; return null;
}); });

View File

@ -52,8 +52,8 @@ export class NodesWidget implements Widget {
selection selection
.select<SVGTextElement>('text.label') .select<SVGTextElement>('text.label')
.attr('x', (n: Node) => n.label.x) .attr('x', (n: Node) => n.label.x - n.width / 2.)
.attr('y', (n: Node) => n.label.y) .attr('y', (n: Node) => n.label.y - n.height / 2. + 20) // @todo: server computes y in auto way
.attr('style', (n: Node) => n.label.style) .attr('style', (n: Node) => n.label.style)
.text((n: Node) => n.label.text); .text((n: Node) => n.label.text);
@ -88,7 +88,12 @@ export class NodesWidget implements Widget {
return 'data:image/svg+xml;base64,none'; return 'data:image/svg+xml;base64,none';
}) })
.attr('width', (n: Node) => n.width) .attr('width', (n: Node) => n.width)
.attr('height', (n: Node) => n.height); .attr('height', (n: Node) => n.height)
.attr('x', (n: Node) => -n.width / 2.)
.attr('y', (n: Node) => -n.height / 2.);
// .attr('width', (n: Node) => n.width)
// .attr('height', (n: Node) => n.height);
// .on('mouseover', function (this, n: Node) { // .on('mouseover', function (this, n: Node) {
// select(this).attr("class", "over"); // select(this).attr("class", "over");
// }) // })

View File

@ -277,7 +277,7 @@ export class ProjectMapComponent implements OnInit {
const data = drawingLineTool.stop(); const data = drawingLineTool.stop();
this.onLineCreation(data['node'], data['port'], node, port); this.onLineCreation(data['node'], data['port'], node, port);
} else { } else {
drawingLineTool.start(node.x + node.width / 2., node.y + node.height / 2., { drawingLineTool.start(node.x, node.y, {
'node': node, 'node': node,
'port': port 'port': port
}); });