I choose a node (i call this node A) then i want to make a translation( change the position on the diagram) for that node(node A) and all the nodes that is reachable from the node A without changing their correlate spatial position without using mouse. How can i do this?
If you want to move a lot of Parts by some offset, you could call DraggingTool.moveParts. But notice that the first argument is not just a simple collection of Parts but a Map of Parts to objects that have a “point” property is that holds the original location of the Part.
As far as finding the collection of Parts that you want to move, that is usually very application-specific. GoJS does provide methods for two commonly used collections: Node.findTreeParts() and Group.findSubGraphParts(). There are also some basic navigation methods provided on the Node class, such as Node.findNodesConnected() – but you will need to implement your own recursive function if you want to collect more.
<span =“Apple-tab-span” style=“white-space:pre”> Node A -----> Node B -------> Node C --------> Node D
I set up a context menu that when i right-click on the link connecting node A and node B and choose “split a flow” then imaging node A is the left branch and node B all the nodes reachable from B except through A is the right branch
In this case the
<span =“Apple-tab-span” style=“white-space:pre”> + Left branch : Node A
<span =“Apple-tab-span” style=“white-space:pre”> + Right branch: Node B---->Node C ----> Node D
i want to move the right branch with this code:
…
$$(“ContextMenuButton”,
function SplitFlow(e,obj)
<span =“Apple-tab-span” style=“white-space:pre”> {
<span =“Apple-tab-span” style=“white-space:pre”> var Link = myDiagram.selection.first();
<span =“Apple-tab-span” style=“white-space:pre”> var toNode = Link.toNode;
<span =“Apple-tab-span” style=“white-space:pre”> var MoveSet = toNode.findTreeParts();
<span =“Apple-tab-span” style=“white-space:pre”> myDiagram.toolManager.draggingTool.moveParts(MoveSet,new go.Point(200,200),true);
<span =“Apple-tab-span” style=“white-space:pre”> }
this turns out to be wrong . I think the method Node.findTreeParts() is return a Set while i need a Map for the 1st parameter in the draggingTool.movePart.
This is not yet documented, and might change before it becomes documented, but you could try calling Diagram.moveParts, because Diagram.moveParts takes a collection of Parts and builds a Map with which it calls DraggingTool.moveParts.