AutoLayout on SubGraphs


#1

I’m using the JGoLayeredDigraphAutoLayout class to layout my View. Now I want to use it to layout subgraphs added to this View. The JGo Layout User Guide tells you to recursively layout the subgraphs first and work your way back up which makes sense… The problem is how do I layout a subgraph using this algorithm? The JGoLayeredDigraphAutoLayout class takes the JGoDocument and the contents of JGoAreas or JGoSubgraphs are ignored. Is there a way of getting a JGoDocument that just represents the subgraph?
Thanks in advance,
-m.


#2
You need to create a JGoNetwork.  The constructor takes a JGoObjectSimpleCollection, which is an interface implemented by several classes, including JGoArea.
JGoSubGraph sg = ...<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
JGoNetwork net = new JGoNetwork(sg);  // create a JGoNetwork representing only the children of this subgraph
if (sg.getHandle() != null) {  // but we want to ignore the handle, so we remove that from the JGoNetwork
  JGoNetworkNode nn = net.findNode(sg.getHandle());
  if (nn != null)
    net.deleteNode(nn);
}
if (sg.getLabel() != null) {  // and we want to ignore the label
  JGoNetworkNode nn = net.findNode(sg.getLabel());
  if (nn != null)
   net.deleteNode(nn);
}
// now we pass the JGoNetwork to the JGoAutoLayout (or call setDocument and setNetwork)
JGoLayeredDigraphAutoLayout l = new JGoLayeredDigraphAutoLayout(doc, net,
    20, 10, JGoLayeredDigraphAutoLayout.LD_DIRECTION_RIGHT,
    JGoLayeredDigraphAutoLayout.LD_CYCLEREMOVE_DFS,
    JGoLayeredDigraphAutoLayout.LD_LAYERING_OPTIMALLINKLENGTH,
    JGoLayeredDigraphAutoLayout.LD_INITIALIZE_DFSOUT, 4,
    JGoLayeredDigraphAutoLayout.LD_AGGRESSIVE_FALSE);
l.performLayout();

#3

Excellent - that works fine. Thanks for your help.