When adding a node to a force directed layout, how can I get the node to appear at specific (X,Y) coordinates rather than the top-left corner of the visualization window?
Whenever I add a free-floating node (not connected to any other nodes by edges) to my visualization, it always appears in the top-left corner and just stays there until the user clicks and drags it to where they want. How can I get the node to appear in the center of the screen when added or where the user last clicked?
I found the following works: You get the corresponding visual item of the node and use the
setEndX
andsetEndY
.