Layout

I talked my client into buying the AutoLayout version of the lisence. And I was using it just fine. Then I added blocks that give the user a spot to drop a new node into the diagram and the layout went all to pot. This is what it looks like after the layout code at the end of this note:

StartTransaction();
GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph();
layout.Document = this.Document;
layout.DirectionOption = GoLayoutDirection.Down;
layout.PerformLayout();
foreach (GoObject obj in this.Document)
{
DiagramLink link = obj as DiagramLink;
if (link != null)
{
link.CalculateStroke();
}
}
this.Document.Bounds = this.Document.ComputeBounds();
FinishTransaction("Layout");
Can someone help me make this look better? The layout is not doing what I would have expected.

What was it doing before?

Are the diamonds on the links just a shape at the MidLabel?

Before it would draw straight lines. The diamonds are just a Background for a node.

Regardless of what they are. I want the lines to go straight down. When it hits a decision it should go out as far as it needs to to go straight down.
I would like it to always be symetrical. It seemed to be before I added the drop points which are just nodes.
I would like it to look like this.

I think it’ll be easier if you insert the +'s or diamonds as objects to the LabeledLink than as separate nodes. Then, the only nodes being laid out are the ones that are obviously nodes.

Looks like you may be able to manage the +'s as MidLabel and ToLabel.

Can a label have a GoImage? If so I can do that.

But why can't it layout all my nodes?

Yes, the 3 labels in GoLabeledLink are really GoObject – they can be anything derived from GoObject.

You can layout all your nodes... you are. It's just that the size difference of the big nodes and little nodes is giving you a result that isn't that great. Changing your special spots on the links from nodes to something that Layout doesn't look at is the simplest way to avoid that.

What about when I have a decision node where the decision joins up again I want to be able to place something.

Using the last picture I posted as an example:
The plus signs are the only place a user can drop a node. They are meant to show drop locations. Look at the decision after that there is a plus sign which is a node they can drop on. How would I put a midlabel there?
Do you see the issue?

You can have as many labels on a GoLabeledLink as you want. GoLabeledLink.LayoutChildren automatically positions its MidLabel, FromLabel, and ToLabel children, but if you have more, you can override LayoutChildren to place them wherever you want. The Processor example’s FlowLink does this, although that sample application never has more than one LinkLabel on a FlowLink. (Note: FlowLink and LinkLabel has a lot of other appearance and behavior that you probably don’t care for and can easily excise.)

However, I think it might be possible to keep your existing strategy of implementing those “+” objects as regular nodes. After the layout, just make sure that any “+” nodes that are directly connected to big blocks are positioned along the X axis where you want them to be.

Walter…

Ok so now I have two choices and neither seem like a solution to me.
Re: Label Solution
I realize I can have labels anywhere. One reason I used a node was to be a joining point back from a decision. Then I could drop on that node and add a node after the decision. On a decision I would need a midlabel and a ToLabel to be drop locations.
RE: Node Solution
I would prefer to stick with this solution however, I'm a little upset that I have to write my own layout code. That is what I bought Autolayout for.
I just want my diagram to flow striaght down symetrically.

Sorry about that, but there’s no way the layout algorithm can produce optimal results for everyone.

In fact, I can imagine some people would prefer a third arrangement, where all of the nodes in your example are lined up vertically, except for the one big block is off to either the left or the right. With more complicated graphs, yet more possible “optimal” possibilities exist considering yet more criteria. And it might not even be possible to produce a graph meeting your requirements when the graph is more complicated.