Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » CompoundDirectedGraph orientation
CompoundDirectedGraph orientation [message #191703] Wed, 10 August 2005 23:48 Go to next message
Eclipse UserFriend
Originally posted by: bencomo.us.ibm.com

In the flow plugin, top level nodes (with no incoming connections) are
placed left to right and children of these nodes are placed below their
parents. However, how can I change that behavior to do the opposite? Top
level nodes to be place top to bottom and their children placed to their
right.

Thank you in advance,
Al.-
Re: CompoundDirectedGraph orientation [message #191788 is a reply to message #191703] Thu, 11 August 2005 16:37 Go to previous message
Eclipse UserFriend
Originally posted by: bencomo.us.ibm.com

Hi,

I found the code below in an old posting and although it looks fishy, it
works. Does anyone have a better suggestion?

Thanks,
Al.-

public void layout(IFigure container)
{
GraphAnimation.recordInitialState(container);
if (GraphAnimation.playbackState(container))
return;

CompoundDirectedGraph graph = new CompoundDirectedGraph();
Map partsToNodes = new HashMap();
diagram.contributeNodesToGraph(graph, null, partsToNodes);
diagram.contributeEdgesToGraph(graph, partsToNodes);
new CompoundDirectedGraphLayout().visit(graph);

for (Iterator iter = partsToNodes.values().iterator(); iter.hasNext();)
{
Object n = iter.next();
try
{
Node node = (Node) n;
int temp = node.x;
node.x = node.y;
node.y = temp;
}
catch (ClassCastException e)
{
Edge edge = (Edge) n;
edge.start = edge.start.getTransposed();
edge.end = edge.end.getTransposed();

if (edge.vNodes != null)
for (Iterator iter2 = edge.vNodes.iterator(); iter2.hasNext();)
{
Object no2 = iter2.next();
Node n2 = (Node) no2;
int temp = n2.x;
n2.x = n2.y;
n2.y = temp;
}
}
}
diagram.applyGraphResults(graph, partsToNodes);
}
Previous Topic:How to show a handle for edit part on top of it?
Next Topic:Changing palettes and maintaining there state
Goto Forum:
  


Current Time: Tue Dec 03 08:54:34 GMT 2024

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

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

Back to the top