New node always appear in the center - visnetwork

Given the following:
const nodes = new DataView(nodeData);
// Somewhere in the code, I call this to add new node whenever I click on a node
nodes.add({id: 1, label: "newNode"});
My issue is, when the new node is added, it always appear at the center. What I want is for the new node to first appear near the node that I clicked cause I want to connect that new node to the node that I selected. But when the new node appears, I don't want it to stick on that position, cause I want it to adjust since I enable the physics, the new node should adjust it's distance from the selected node.

Related

Is there a way to show the > sign of a TTreeNode when no children have been added yet?

I show items in a TTreeView object. When an Item has children the control paints a > next to the icon (or a down pointing arrow if expanded).
I was wondering if I can tell the Item somehow to paint the > even if no children have been added (yet).
There are certain conditions in my software where it makes sense to show the user there are children, without actually adding the children yet (That is then done when the item is selected)
Using c++ Builder 2009 VCL but this Q should be valid for Delphi as well.
In VCL, TTreeNode has a HasChildren property:
Indicates whether a node has any children.
HasChildren is true if the node has subnodes, or false if the node has no subnodes. If ShowButtons of the tree view is true, and HasChildren is true, a plus (+) button will appear to the left of the node when it is collapsed, and a minus (-) button will appear when the node is expanded.
Note: If a node has no children, setting HasChildren to true will show a (+) plus button, but will not add any child nodes and the node cannot be expanded.
So, you can set a node's HasChildren to true before actual child nodes have been created for it. Then later on, once you have determined whether the node has any actual child nodes, you can reset HasChildren to false if there are no child nodes present.
Despite what the documentation suggests above, attempting to expand a node that has no child nodes but does have HasChildren set to true WILL trigger the TTreeView.OnExpanding event, at least. That is a good place to populate the actual child nodes and update HasChildren.

Node visulaization in Neo4j

How we can change Property name/Values manually in Neo4j. Which Property should be in centre to show relationships with other nodes.
An example just to elaborate the question
In graph output,How "Tom Hanks" can be replaced with some other property of Tom Hanks.
This is related to the visualizer running in the browser view, and not neo4j itself.
If you check the node labels at the top of the output view, tap on the label related to the thing you want to change (it may also show if you tap on the node in question to give it focus). Now, at the bottom of the window, you should see properties of that node. Tap on the one that you want to show up for nodes of that label in the visualizer.

TIWTreeview collapses on selecting item

I have an intraweb form with a IWTreeview which has code in the ItemClick event. If you expand a node and select a child node, the form refreshes and the node collapses. How can the node be set expanded as it was previously? The issue is nothing to do with what the code is in ItemClick. It is how to get the treeview to remember that the node was open.

(Delphi Ttreeview) how to drag/drop node to below (or above) selected node

In TtreeView1.DragDrop am using statements such as
targetnode := TreeView1.GetNodeAt(x,y);
...
TreeView1.Selected.MoveTo(targetnode , naInsert ) ;
to move a node with the mouse and insert it in front of ie above, an existing node on the same level.
Id like to change the behaviour so that if I am dragging downwards the node gets moved to below the target but if I am dragging upwards it gets moved to above the target (otherwise I can drag to a new bottom position but not a new top or vice versa).
The sort of structure I am trying is
targetnode := TreeView1.GetNodeAt(x,y);
...
if DraggedItem.Index > targetnode.Index then //we are dragging upwards, insert before
TreeViewStructure.Selected.MoveTo(targetnode , naInsert )
else //we are dragging downwards, insert after
TreeViewStructure.Selected.MoveTo(targetnode , ???) ;
but I cannot find a TNodeAttachMode constant that inserts a sibling after the target node.
The constants for TNodeAttachMode given here http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/ComCtrls_TNodeAttachMode.html are ...
naAdd: The new or relocated node becomes the last sibling of the other node.
naAddFirst: The new or relocated node becomes the first sibling of the other node.
naInsert:The new or relocated node becomes the sibling immediately before the other node.
naAddChild:The new or relocated node becomes the last child of the other node.
naAddChildFirst:The new or relocated node becomes the first child of the other node.
but none of those refer to a new last sibling.
Can I do what I want? if so how?
There is no option to insert after a node, only insert before. So you have to find the node after the drop target, and insert before it.
To add after the last node, find the last node and pass naAdd to MoveTo.
Thanks to David for his suggestions. Using them I finally wrote the following code to achieve what I need. Posted here in case it's of use to anyone else. (This is the relevant bit of code inside OnDragDrop)
if ( Assigned(targetnode)) //we are over a target node
and (DraggedNode.Level = targetnode.Level then //we are dragging within the same sub level
begin
if targetnode.Index = targetnode.Parent.Count -1 then //target is the last node so do an naAdd to drop node at the end
TreeViewStructure.Selected.MoveTo(targetnode , naAdd )
else
TreeViewStructure.Selected.MoveTo(targetnode , naInsert ) //drop before target using naInsert
end;

draw a icon on Treeview node on mouseover, when clicked display popup menu

using delphi ex-5
as of now, I can display the popupmenu on right click of a selected node
is it possible to display a icon on a treeview node (right side) on a moveover? When the icon is moused over, display a popupmenu?
thanx
EDIT: Inclusion of two screenshots to better convey my need (Yes, this was taken forom a webpage - it is what I am trying to do)
https://dl.dropboxusercontent.com/u/73677254/Delphi%20Demos/screenshot1.png
https://dl.dropboxusercontent.com/u/73677254/Delphi%20Demos/screenshot2.png
If you want the icon on the left side, you can use the TTreeNode.StateIndex property. But to put an icon on the right side, you have to owner-draw the TTreeView nodes instead.
Either way, use the TTreeView.OnMouseMove event to keep track of which node is currently under the mouse at all times, and when you detect a different node then you can reset the StateIndex of the previous node and update the StateIndex of the new node, or trigger a repaint and draw the icon only on the new node, depending on which approach you take.

Resources