Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ZEST - How to recreate DotGraph Tree on event
ZEST - How to recreate DotGraph Tree on event [message #870856] Thu, 10 May 2012 01:21 Go to next message
Menard Mabunga is currently offline Menard MabungaFriend
Messages: 7
Registered: January 2012
Junior Member
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 16:29 Go to previous message
Fabian Steeg is currently offline Fabian SteegFriend
Messages: 76
Registered: July 2009
Member
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.
Previous Topic:PaletteEntry -> CreateRequest
Next Topic:Controlling line breaks in Multiline labels
Goto Forum:
  


Current Time: Tue Mar 19 01:59:34 GMT 2024

Powered by FUDForum. Page generated in 0.02064 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top