I am using a GoLayoutLayeredDigraph layout to implement flow charts in my web application. I am populating the flow charts from XML source, and everything is working pretty well. I am trying to implement subgraphs in the transformation code that I have written. I have overridden the ConsumeAttributes subroutine for my transformation class like this:
Public Overrides Sub ConsumeAttributes(ByVal obj As Object) MyBase.ConsumeAttributes(obj) Dim n As FlowNode = GetNode(obj) Dim doc As GoDocument = CType(Me.Reader.RootObject, GoDocument) If StringAttr("subGraphID", "0") <> "0" Then Dim sg As GoSubGraph = doc.FindPart(1000000 + CInt(StringAttr("subGraphID", "0"))) If sg IsNot Nothing Then sg.Add(n) End If Else If StringAttr("hasSubGraph", "False") = "True" Then Dim sg As New GoSubGraph() sg.PartID = 1000000 + CLng(StringAttr("id", "0")) n.Add(sg) End If doc.Add(n) End If End Sub
And the XML source would look like this:
…and for one of the children to be added to the subgraph, the XML would look like:
So, if a node should have a subGraph added, the XML element has its “hasSubGraph” attribute set to ‘True’. I check for that in my transformation code. If it is ‘True’ then I add a subgraph to the node in question, giving the subgraph a PartID of 1000000 + the node’s PartID (id in the XML). Then when I encounter a node that has a subGraphID=“5136”, for example, I know to add it to the subgraph with the ID of 1005136.
These nodes appear in the flowchart but, they are all stacked on top of each other, and on top of the parent node (5136). All other nodes in the flowchart are layed-out correctly. I thought that, maybe, I should explicitly call “layoutChildren” for each subgraph that I have added but, that doesn’t seem to have an effect.
Any suggestions as to what I might try?
Thanks, as always.