I read the method here to create the label of node through embedded Java Api. But in my problem the label is dynamic because of correction. So, is there a way to change the label?
Without this facility the alternate solution I have thought is to create nodes of 'labels' and create edge from entity node to that 'label' node. But this may lead to some disadvantages as not able to make use of index over the label.
You can remove labels from nodes using:
node.removeLabel(DynamicLabel.label("MyLabel"));
And you can find all the nodes with the incorrect label using the global operations:
GlobalGraphOperations.at(graphDB).getAllNodesWithLabel( DynamicLabel.label("MyLabel") );
Related
I am new to prefuse and don't understand several things regarding nodes.
How can I get an event raised whenever a node clicked?
How can I group similar nodes with the same color?
How can I keep an extra meta-data on every node?
Its important to say that I build the graph in real-time and not loading it from any file.
Thanks,
Ozrad.
Three answers to your three questions:
The best way to react on node clicks is to extend prefuse.controls.ControlAdapter and add it to the Display.
prefuse.action.assignment.DataColorAction assigns color based on a data field. For more advanced scenarios you can use ColorAction with predicates or extend the class DataColorAction.
You can add columns to the node table to store metadata. A column can also store objects if you need it:
vg.getNodeTable().addColumn("meta", MyMetaData.class);
I have created two trees in gwt-ext one contains the values of nodes that can be dragged and other the nodes which can be dropped on. The problem being i am not able to set only a particular set of leaves mentioned in the array, from a tree to be dragged on other tree while the leaves which are not in the array cannot be dragged. I have enabled drag drop on the tree and then manually allow a leaf to disable drag but its not working. Tried it using the setallowdrag() method and also using setTreeAttribute("allowDrag",false) but don't know why it just doesn't work. Please help.
TreeNode n22=treePanel.getNodeById("ynode-121");
n22.setTreeAttribute("allowDrag","false");
n22.setAllowDrag(false);
I am new to eclipse RCP, well as a matter of fact to java also. Have a very basic question.
I have a JFace TreeViewer. I want to expand a particular node in that. The catch is I only have the name of the node. and no information apart from that.
I tried using treeItem, compared its string with that of the node name that I have, thus I got the node. I tried expanding it in the contentprovider of the tree. But i am not getting the desired output. When I check it in the log i get that it is expanded but it doesnt show in the viewer. I am performing this in display.asyncExec method in the contentprovider.
I hope the question is clear.
JFace viewers were created so that developers wouldn't have to mess around with SWT widgets and could use higher level API instead. When using JFace's viewer/content provider/label provider you should be in control of what nodes are in your tree (thus when you say you only know the name, I assume you are using SWT Tree directly). You can read about JFace viewers from Eclipse help.
To expand a tree node use expandToLevel(Object elementOrTreePath, int level) method of TreeViewer (the level is relative to the node that is expanded, not the root of the tree).
I am trying to make simple Setting GUI in Java (IDE Eclipse).
On the left is JTree (7 nodes), on the right is layeredPane with 7 panels (JPanel). I want to browse panels by simple clicking on nodes in JTree.
But how to do it? Especially i do not know how to link node with this appropriate Panel. I do not know how to tag it, or to assign it as an object to the node.
P.S
1. I do not know, if there is more efficient way to do it.
2. I am new in Java, but not in programming. In Delphi there is no problem for me...
Thanx a lot
Each TreeNode has index which you can use to link to your panel.
If you use MutableTreeNode (default implementation is DefaultMutableTreeNode) you can assign custom user object to each node - see JavaDoc for MutableTreeNode and DefaultMutableTreeNode.
I have a JTree which I give objects that implement the TreeNode interface, and a custom TreeModel to display them (not using DefaultMutableTreeNode). I would like to change the text colour of some nodes. I can't find anything in the docs, except javax.swing.tree.DefaultTreeCellRenderer.setTextNonSelectionColor(Color newColor), but it will change everything indiscriminately, and I only need it for some nodes (specifically, broken links, i.e. nodes whose corresponding files can't be found on the disk, should be greyed out, the rest should be default). Can it be done, and how?
You are close to your answer. What you need to do is Sub Class the DefaultTreeCellRenderer and override a few of the DefaultTreeCellRenderer's methods. Then make sure you tell the tree to use your custom cell renderer.
What you will need to do is have some state variables that indicate whether or not a link is broken, and set the color of the node based on that.
You might also look at org.netbeans.swing.outline, mentioned in this answer. Ordinary extensions of TableCellRenderer and the RenderDataProvider interface make it especially easy to customize the appearance of rows in the tree.