Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » enforce node position n gridlayout(enforce node position n gridlayout)
enforce node position n gridlayout [message #1007942] Fri, 08 February 2013 06:06 Go to next message
Mokhtar Abdu is currently offline Mokhtar Abdu
Messages: 104
Registered: November 2011
Senior Member
Hello all,

Could you help me as how to enforce the position of a certain node in a certain column and row (i.e. cell) in a GridlayoutAlgoritm?

I had got valuable help [message #1007779]

Thanks,
Mok
Re: enforce node position n gridlayout [message #1008004 is a reply to message #1007942] Fri, 08 February 2013 10:00 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan Ujhelyi
Messages: 208
Registered: July 2009
Senior Member
Hi,

The algorithm does not support direct positioning. However, by ordering the nodes using a comparator it might be possible to put each element to its space. If not, than you have to implement your own changes - that should not be too hard.

Cheers,
Zoltán
Re: enforce node position n gridlayout [message #1009786 is a reply to message #1008004] Fri, 15 February 2013 12:56 Go to previous messageGo to next message
Mokhtar Abdu is currently offline Mokhtar Abdu
Messages: 104
Registered: November 2011
Senior Member
Hi,
i set a comparator to my gridlayout algo object like this:
public void customizeLayout(ArrayList<ResultsVersion> resultsVersions) {
		EvolutionGridLayoutAlgo glayoutAlg = new EvolutionGridLayoutAlgo(resultsVersions);
		glayoutAlg.setComparator(new Comparator<CandidateNode>() {
			
			@Override
			public int compare(CandidateNode o1, CandidateNode o2) {
				String id1 = o1.getCandidate().getIdentity();
				String id2 = o2.getCandidate().getIdentity();
				
			      return id1.compareTo(id2);
			}
		});
		setLayoutAlgorithm(glayoutAlg, true);
	}


but i am still missing something as it didn't work. Is this the way you set a comparator? the
CandidateNode
class extends GraphNode. Should I rather make my CandidateNode implements Comparable and the rest is automatically doable by the grid logic itsef?
thank you,
Mok
Re: enforce node position n gridlayout [message #1010185 is a reply to message #1009786] Sat, 16 February 2013 15:25 Go to previous message
Zoltan Ujhelyi is currently offline Zoltan Ujhelyi
Messages: 208
Registered: July 2009
Senior Member
Hi,

it seems I wasn't clear about my intentions with the comparator. I was asking to try to use the GraphViewer#setComparator method, as it will order the nodes before they are added to the algorithm (at least if I am not mistaken).

Of course, a layout algorithm may also offer a comparator support, but in that case it is their responsibility to handle the data. The GridLayoutAlgorithm does not do this, but relies on the external ordering created by the GraphViewer before.

I hope, it will work now.

Cheers,
Zoltán
Previous Topic:Draw2D & GEF: qualified associations
Next Topic:Create Pie chart Figure
Goto Forum:
  


Current Time: Sat Aug 30 16:40:46 EDT 2014

Powered by FUDForum. Page generated in 0.04184 seconds