Bug 379152 - CompoundDirectedGraph does not layout properly, nodes overlap.
Summary: CompoundDirectedGraph does not layout properly, nodes overlap.
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-10 11:44 EDT by Kamil Fejfar CLA
Modified: 2012-05-11 04:58 EDT (History)
0 users

See Also:


Attachments
Correct and wrong layout (54.64 KB, image/png)
2012-05-10 11:46 EDT, Kamil Fejfar CLA
no flags Details
Flow graph example (2.08 KB, application/octet-stream)
2012-05-10 11:50 EDT, Kamil Fejfar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kamil Fejfar CLA 2012-05-10 11:44:45 EDT
Build Identifier: M20100211-1343

When I layout a graph using CompoundDirectedGraphLayout, some nodes overlap. This happens when nodes (org.eclipse.draw2d.graph.Node) have no parent. If I create these nodes (org.eclipse.draw2d.graph.Node) with common parent (org.eclipse.draw2d.graph.Subgraph), it seems to work fine.

The problem can be reproduced using GEF flow example with following change in
StructuredActivityPart class:

public void contributeNodesToGraph(CompoundDirectedGraph graph, Subgraph s, Map map) {
	GraphAnimation.recordInitialState(getContentPane());
//	Subgraph me = new Subgraph(this, s);
//	me.rowOrder = getActivity().getSortIndex();
//	me.outgoingOffset = 5;
//	me.incomingOffset = 5;
//	IFigure fig = getFigure();
//	if (fig instanceof SubgraphFigure) {
//		me.width = fig.getPreferredSize(me.width, me.height).width;
//		int tagHeight = ((SubgraphFigure)fig).getHeader().getPreferredSize().height;
//		me.insets.top = tagHeight;
//		me.insets.left = 0;
//		me.insets.bottom = tagHeight;
//	}
//	me.innerPadding = INNER_PADDING;
//	me.setPadding(PADDING);
//	map.put(this, me);
//	graph.nodes.add(me);
	for (int i = 0; i < getChildren().size(); i++) {
		ActivityPart activity = (ActivityPart)getChildren().get(i);
		activity.contributeNodesToGraph(graph, null/*me*/, map);
	}
}

Notes:
1) The attached graph is the smallest graph where it happens to me.
2) The order the nodes are added to graph using graph.nodes.add() is important. Some orders do not cause this problem. The problem can be reproduced when nodes are sorted alphabetically (a1, b1, b2, ...).
3) I think the problem is in org.eclipse.draw2d.graph.HorizontalPlacement.balanceClusters() method. If this 
method is not called, then the nodes do not overlap (no matter the nodes have common parent or not).



Reproducible: Always

Steps to Reproduce:
1. Run the example plugin with change mentioned above.
2. Open attached flow file.
3. Nodes overlap.
Comment 1 Kamil Fejfar CLA 2012-05-10 11:46:48 EDT
Created attachment 215412 [details]
Correct and wrong layout
Comment 2 Kamil Fejfar CLA 2012-05-10 11:50:18 EDT
Created attachment 215413 [details]
Flow graph example