CompoundDirectedGraph orientation [message #191703] |
Wed, 10 August 2005 23:48 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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);
}
|
|
|
Powered by
FUDForum. Page generated in 0.07635 seconds