ZEST - How to recreate DotGraph Tree on event [message #870856] |
Wed, 09 May 2012 21:21  |
Eclipse User |
|
|
|
Hi all,
Im developing a program that generates genealogy tree, my problem is that I cant recreate a tree upon events.
I have a GenealogyTree views, which displays blank tree in initial run of the program.
my GenealogyTree.class
@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
SearchGermplasm searchGermplasm = (SearchGermplasm) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SEARCH_VIEW);
graph = new DotGraph(parent, SWT.NONE);
algorithm = new TreeLayoutAlgorithm();
graph.setLayoutAlgorithm(algorithm, true);
con = searchGermplasm.getCon();
myGID = new Integer(searchGermplasm.getMyGID());
myLEVEL = searchGermplasm.getMyLEVEL();
loadTree(myGID, myLEVEL);
hookMenu(graph);
}
private void getParents(GermplasmPedigreeTreeNode currentChildNode, int level) throws QueryException
{
if(level > 0)
{
//get ID of this Germplasm for linking parent nodes to this child node
Germplasm rootChildGermplasm = currentChildNode.getGermplasm();
Integer childGermplasmID = rootChildGermplasm.getGid();
String childGermplasmName = rootChildGermplasm.getPreferredName().getNval();
for(GermplasmPedigreeTreeNode parentTreeNode : currentChildNode.getLinkedNodes())
{
parentGermplasm = parentTreeNode.getGermplasm();
System.out.println("Parent of : "+childGermplasmID+" is ---> " + parentGermplasm.getGid());
graph.add(childGermplasmID+"->"+parentGermplasm.getGid());
}
}
public void loadTree(int GID, int level) {
// TODO Auto-generated method stub
try {
tree = con.getManager().generatePedigreeTree(new Integer(GID), level);
} catch (QueryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
getParents(tree.getRoot(), level);
} catch (QueryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Now upon search events from SearchGermplasm.class, the user will define ID and LEVEL and will now the value of myGID and myLEVEL
method after clicking search button
public void setSGID(int sGID, int tLevel) throws QueryException, ConfigException
{
GenealogyTree genealogyTree = new GenealogyTree();
genealogyTree.createPartControl(btnSearch.getShell());
genealogyTree.loadTree(myGID, myLEVEL);
}
the method is working as its display all the list of parent and child records, but the problem is it doesnt display or recreate the tree.
Hope you all can help me with this.
Regards,
Menard Mabunga
|
|
|
Re: ZEST - How to recreate DotGraph Tree on event [message #874349 is a reply to message #870856] |
Sun, 20 May 2012 12:29  |
Eclipse User |
|
|
|
To provide a useful suggestion, I would probably need an isolated full working example. But in general, after you reassign the graph, you could try to set its layout (Graph#setLayout), then layout its parent (Composite#layout), and finally apply the graph layout (Graph#applyLayout). Perhaps a look into how I did something similar in the ZestGraphView can help.
|
|
|
Powered by
FUDForum. Page generated in 0.02791 seconds