AutoLayout

Dear Friends,

Im using the GoWeb.Layout.GoLayoutForceDirected class,but the Objects are overloding.
can any one help me.
Thanks in advance.
Regards,
Sasi

If the forces are such that there isn’t enough room for some (or all) of the nodes, then some nodes might overlap. The force-directed algorithm doesn’t guarantee that there won’t be overlap, although it’s unlikely for most graphs.

Perhaps you have relatively large nodes? Maybe you need to increase the electrical charge on each node, by overriding the GoLayoutForceDirected.ElectricalCharge method to return a larger value.

Hai,

Thanks for ur prompt response.Can u give me one example.
Regards,
Sasi Kumar.

By default GoLayoutForceDirected.ElectricalCharge returns 150.0f. You could try returning larger values.

Thanks

Hai,

I increased the ElectricalCharge to 600 yesterday it was working fine, but now its overlapping for some nodes so i increased up to 1500 still the problem is there, what will be the solution?
Thanks,
Sasi

As I said originally, the force-directed algorithm does not guarantee that nodes might not overlap.

Is there any other algorithm available to draw a digram without overlapping

thanks

Layered-digraph and tree always avoid overlapping the nodes that they lay out.

I have the same problem. I am using the Tree and nodes do in fact overlap.

I would like to be able to let the user right-click on a parent node; click add child and not have that child overlap any of the existing children nodes. The problem is that it does overlap.

I am also a bit unsure of all the different types of graphs.

I am using a view with a GoDocument (a custom GoDocument which I have called FamilyTreeDoc). Should I be using GoLayout instead? If so then I would have to completely rewrite the application I have been working on for the last 6 months.
Would you be able to explain the relationships and the different GoDiagram solutions that work well together? I am still pretty fuzzy on all the GoLayout vs. GoDocument vs. GoDiagram etc. and I am also trying to understand why things like marriage links come in "two".
For instance, when I use the link style property:
GoStrokeStyle.RoundedLineWithJumpOvers
for my marriage links between two parents when the links intersect with child links from other branches it gets all screwy and splits the marriage links instead of keeping them as 1 solid link. I know that the way some of the sample code you provided does this by default but is there any way to make it so that there is only 1 single line drawn between a husband and wife?
Also, as for the overlapping nodes, I am using a custom GoNode called PersonNode that inherits from GoTextNode. I managed to get the links.AvoidNodes to work (for the most part) but I cannot get nodes to avoid one another. It seems like every time I add a new child to a family it puts it on top of one of the other children. I looked at the GoDocument.isUnoccupied method but am having some difficulty implementing it.
Also, I am having trouble centering things like the document itself as I add more and more GoObjects to it b/c I am unsure of all the different size, scale, point, DocScale, Location etc. properties. There are just soooooooo many things to try and keep track of I don't know where to start.
I am having trouble trying to understand the whole View => Document => Layers => Groups etc. relationships. I am trying to keep track of Nodes, rectangles, links, ports etc. and all I really want to do is build an intelligent family tree where no nodes overlap (in other words, they should all behave the way magnets behave when you try to force sides with the same polarity against one another -meaning, they push each other out of the way). As for the links and ports, I just want to diagram to know that parents should go above children, siblings should be at the same level as the sibling they were added from (but also avoiding any other siblings at the same level) and children should be added below parents while also avoiding other children.
How can this be done?

The various GoLayout classes are just responsible for moving nodes around in a document. Some of them also route the links connecting the nodes. It appears that you are not using GoLayout, but the very simple tree-like layout used by the FamilyTree sample.

Actually, I thought I gave you some code that adapted the FamilyTree sample to make use GoLayoutLayeredDigraph: http://www.nwoods.com/forum/forum_posts.asp?TID=2099. Aren't you using that?
GoView is just a Control (Windows Forms or Web Forms) that displays the contents of a GoDocument.
A GoDocument contains GoLayers which contain GoObjects, some of which are GoGroups, that contain other GoObjects. All GoNodes are GoGroups that also happen to contain some GoPorts, which represent the end-points for GoLinks.
This is all discussed in great detail in the User Guide.
Have you read the User Guide and the FAQ?
To center the document in the view, take a look at http://www.nwoods.com/forum/forum_posts.asp?TID=2119.

Thanks for the quick reply.

I guess I do understand the View => Document => GoObject (links, ports, nodes etc.) relationships.
It's all the other stuff that has got me confused. It helps that you just mentioned that "all GoNodes are GoGroups that also happen to contain some GoPorts". I thought that GoGroups was something else entirely.
I am using some form of the moded Family Tree code that you gave me awhile back. The problem is that when you gave it to me I had modified the original family tree code so much that I was afraid to change anything b/c I had so much of it working.
As for the centering of the document. I have two problems.
1. We purchased a license for 2.5.2 and I was wondering if we get free upgrades to newer versions during a certain period of time. If so, then I would like to know how to obtain a new license for version 2.6.2 since I cannot use the document center code in the example you provided since GoDocument.Bounds is not a property in 2.5.2.
2. If you could explain how I could obtain the various coordinates of my document and which specific size and position properties are affected by which objects that would be most helpful.
For #2 above I guess my real question is, how can I dynamically recenter the document which each new Node (or Nodes) that get added by the user? For example: If I start off with 1 node in the center of the document and then I right-click on the node and select "Add Parents" from the context menu. The two parent nodes are added with the appropriate marriage links and the child link. I would think that with each new Node that I add to the document that the size of the document increases by a certain amount.
I am not sure if I am asking this question correctly but assuming that the GoObjects are all in my GoDocument (which based on what I've been doing for the last 6 months they have to be) how can I calculate the total width and height that these GoObjects (i.e. the entire tree) make up in the document and get the document's current size and it's TopLeft coordinates and based on all of that information figure out how to recenter everything?
In the instructions you provide to center the GoDocument you don't exactly give any detail as to what everything is.
I will look into trying to figure it out myself as I know you are very busy but if you could give me an idea of how one might be able to dynamically recenter the document (and really what I mean by that is make sure that the contents of the document appear in the center of the view) I would greatly appreciate it.

GoDocument.Bounds is just a combination of GoDocument.TopLeft and GoDocument.Size. Just do:

RectangleF r = ...
doc.TopLeft = r.Location;
doc.Size = r.Size;
Just try executing that code (that calls ComputeDocumentBounds) after each time you have added and positioned (or removed) some nodes.

How will that affect the code you gave me about snapping to grid?
GoSelection sel = new GoSelection(null);
sel.AddRange(this.view.Document);
SizeF size = new SizeF(0, 1);
this.view.MoveSelection(sel, size, true);

I want to be able to snap to grid after recentering the document. In the code you provided me above, it seems like when I execute the MoveSelection method it shifts the whole document to the top left corner of the view. If I put in different values (i.e. 450, 250) it moves (what seems to be) the top left corner of the document to middle of my view.
When the user creates a new tree the document starts with a default node in the center. I center it by setting it's X/Y coordinates to 450,250. Since I know that those coordinates are what appear to be the center of the viewable area in my grid I pretty much use 450,250 as my "default" mid-point.
What I think might be happening is that when there is just 1 node it doesn't matter whether I set the center of the document to 450,250 and also use 450,250 as the value for size in the MoveSelection method because both will result in showing the single node in the center of the document.
However, as I add more nodes, links etc. the document does not seem to actually center itself at 450,250 rather it seems to be setting it's TopLeft property to 450,250 and as I add more nodes whether above existing ones, below, to the right or to the left, the tree is never again "centered" in the grid but instead seems to gradually grow towards the bottom right corner of the screen with it's top left point being 450,250.
Any thoughts?

There is also no GoView.DocExtentCenter property in version 2.5.2.

If you could tell me whether or not my company qualifies for a free upgrade I could just use 2.6.2 and get the new license.

The behavior you see is when the document is smaller than the view, the view, like Notepad and Word and other applications, naturally positions everything at the top or at the top-left. You can change that behavior in 2.6 by setting GoView.SheetStyle to GoViewSheetStyle.Sheet (or any value other than None), even if there’s no GoView.Sheet.

In earlier versions there had to be a Sheet for that scrolling behavior -- in other words, you had to have set GoView.BackgroundHasSheet to true. In 2.6 the view doesn't have to have a sheet in the background.
Walter,
I have run into a problem when trying to have my Family Tree center itself, snap to grid and maintain it's original layout when it first loads.
The centering seems to work pretty well, however when I try to have it "auto snap to grid" when it first loads I run into a problem b/c instead of simply snapping the GoDocument as a whole to a specific X/Y coordinate, it seems as if the code you gave me shifts each node individually and depending on which nodes might be in certain locations and whether or not I have my AvoidNodes property set to true for my links, certain node shifts cause my Family Tree structure become skewed.
What I don't understand is, why when I last saved my Family Tree was everything snapped to grid and centered perfectly but each time I try and reload my saved tree it needs to be re-snapped to grid and re-centered.

Yes, the snap-to-grid feature is supposed to work on each node, separately.

It sounds like you aren't saving and restoring the correct positions. Make sure you set the position of the newly reconstructed node last, since if you do it before the node is completely initialized, the position might change automatically. For example, changing a text label will change its size, which might affect the size of the whole node, and thus might change the Position or Location of the whole node.

Again, thanks for the prompt reply.

After each addition or deletion of a node I perform the following actions:
  1. Save all of the X/Y coordinates of all of the nodes that remain in the tree in my database.
  2. Then I call a method called CleanUp() that calls a modified reload method from the GenDB class.
  3. Within the CleanUp() method I call GoDocument.Clear(), GoDocument.InitNodes(), GoView.UpdateScrollbars() and finally GoView.RescaleWithCenter().
At this point, any new nodes that get added to the Document are first stored in an in-memory typed-dataset and then the GenDB Load() method uses the data in the dataset to populate the HashTable and create all of the Person and PersonNode objects.
It seems like I can almost get everything working but just not altogether. When I get the snap-to-grid working the layout gets screwed up. When I get the centering working the snap-to-grid isn't implemented. When I get the layout working either the snap-to-grid or the document centering code has been commented out.
If what you are saying is correct (i.e. about perhaps I am not saving and restoring the correct positions) then why does the tree look fine when I opt not to implement the snap-to-grid code? All the links are routed correctly, parent nodes line up correctly on the same X coordinates etc.
But when I try any combination of ...
GoView.MoveSelection(sel, size, true);
instead of every Node all shifting to their respective new X/Y coordinates specified in the size variable -they don't!
Thoughts?