Modify node and its subscene and its label's positional attributes
(nodeGroup, d: render.RenderNodeInfo)
| 642 | } |
| 643 | /** Modify node and its subscene and its label's positional attributes */ |
| 644 | function position(nodeGroup, d: render.RenderNodeInfo) { |
| 645 | let shapeGroup = tf_graph_scene.selectChild(nodeGroup, 'g', Class.Node.SHAPE); |
| 646 | let cx = layout.computeCXPositionOfNodeShape(d); |
| 647 | switch (d.node.type) { |
| 648 | case NodeType.OP: { |
| 649 | // position shape |
| 650 | const opNode = d.node as OpNode; |
| 651 | if ( |
| 652 | _.isNumber(opNode.functionInputIndex) || |
| 653 | _.isNumber(opNode.functionOutputIndex) |
| 654 | ) { |
| 655 | // This shape represents the input into or output out of a TensorFlow |
| 656 | // function. |
| 657 | let shape = tf_graph_scene.selectChild(shapeGroup, 'polygon'); |
| 658 | tf_graph_scene.positionTriangle( |
| 659 | shape, |
| 660 | d.x, |
| 661 | d.y, |
| 662 | d.coreBox.width, |
| 663 | d.coreBox.height |
| 664 | ); |
| 665 | } else { |
| 666 | let shape = tf_graph_scene.selectChild(shapeGroup, 'ellipse'); |
| 667 | tf_graph_scene.positionEllipse( |
| 668 | shape, |
| 669 | cx, |
| 670 | d.y, |
| 671 | d.coreBox.width, |
| 672 | d.coreBox.height |
| 673 | ); |
| 674 | } |
| 675 | labelPosition(nodeGroup, cx, d.y, d.labelOffset); |
| 676 | break; |
| 677 | } |
| 678 | case NodeType.META: { |
| 679 | // position shape |
| 680 | let shapes = shapeGroup.selectAll('rect'); |
| 681 | if (d.expanded) { |
| 682 | tf_graph_scene.positionRect(shapes, d.x, d.y, d.width, d.height); |
| 683 | subscenePosition(nodeGroup, d); |
| 684 | // Put the label on top. |
| 685 | labelPosition(nodeGroup, cx, d.y, -d.height / 2 + d.labelHeight / 2); |
| 686 | } else { |
| 687 | tf_graph_scene.positionRect( |
| 688 | shapes, |
| 689 | cx, |
| 690 | d.y, |
| 691 | d.coreBox.width, |
| 692 | d.coreBox.height |
| 693 | ); |
| 694 | // Place the label in the middle. |
| 695 | labelPosition(nodeGroup, cx, d.y, 0); |
| 696 | } |
| 697 | break; |
| 698 | } |
| 699 | case NodeType.SERIES: { |
| 700 | let shape = tf_graph_scene.selectChild(shapeGroup, 'use'); |
| 701 | if (d.expanded) { |
no test coverage detected
searching dependent graphs…