TreeLayout and Route.Curviness

Hi,

I’m using a TreeLayout and sometimes, there is multiple links between the same pair of nodes (see the picture below). So I tried to modify the Route.Curviness of my link but it’s not working.

Here is my code:

go:Link.Route
<go:Route Routing=“Orthogonal” Curve=“JumpGap” Curviness=“20” ToShortLength="-2" FromShortLength="-2"
FromEndSegmentDirection=“RotatedNodeOrthogonal”
ToEndSegmentDirection="RotatedNodeOrthogonal "
RelinkableFrom=“True” RelinkableTo=“True” />
</go:Link.Route>

TreeLayout assumes there are no duplicate links in the tree-structured graph that it is laying out. So as far as you are concerned, it will probably ignore the second link when routing.

I suggest that you override TreeLayout.LayoutLinks to first call the base method and then find all of the duplicate links to explicitly get them to be routed the normal way you want. Just call Link.Route.InvalidateRoute().

Thanks you. It’s working!!

I’m wondering if it’s possible to have something like the picture below without working with the From/ToPort.

Because, actually I got this:

I tried to set the Routing to Orthogonal but it didn’t work.

Here is my code to set the Curviness in the DoLayout method:

<span =“Apple-tab-span” style=“white-space:pre”> Dim route As Northwoods.GoXam.Route = New Northwoods.GoXam.Route
route.Curviness = curviness
route.Routing = LinkRouting.Normal
route.Curve = LinkCurve.None
sameFromLinks(i).Route = route

such that the Curviness = 30

It’s not necessary to replace the Link.Route with a new Route.

Are you trying to get Orthogonal links to be routed as in your first picture by modifying the Curviness property on each Route? I don’t think that will work. If you really want that, you could override Route.ComputePoints to get the results that you want.

If you could further assume that the FromSpot and ToSpot are on the same side, you could simplify that work to just be overriding the Route.AddOrthoPoints method. For example, for the upper link in the first picture, the Routing=“Orthogonal”, the FromSpot=“MiddleTop” and the ToSpot=“MiddleTop”. You could replace the definition of AddOrthoPoints to use the Curviness value to control how far from the end points (i.e. the ports/nodes) the middle two points should be.

Of course for the bottom link the spots are on the bottoms of the ports/nodes. And the middle link is going straight, so the spots could be the default (Default).

I don’t think your second approach will works because in the example I showed you, there was only 3 “branches”, but the number of branches can be unlimited.

So I think I will try to override the ComputePoints on modify by myself the point in the Points collection. But I’m wondering, what is the difference between adding a point directly to the Points collection and the AddPoint method?

OK, but overriding ComputePoints is more work than overriding AddOrthoPoints.

As is documented, you should not modify the collection that is the value of Route.Points. You have to call the methods or replace the whole collection.

Is there any example somewhere of an overrided ComputedPoints method?

There is in the Fishbone sample in version 1.3.

I do suggest calling the base method for all cases besides the specific ones that you want to handle specially. Even for those special cases, you might want to call the base method first anyway, and then modify the route points. But that depends on how different what you want is from what it does.

I want to be able to add as many branches as I want.

Correct me if I’m wrong, but in that picture, each link is composed of 4 Route.Point. So I thought set these 4 points in the ComputesPoints method. I don’t understand what can be so complicated…

And by the way, where can I get the Fishbone sample ?

OK, if you understand what you want, it isn’t hard at all.

The Fishbone sample is in the 1.3 beta kit.

Actually, you might find this very useful: parallel links

Thanks you Walter, I will look at this

Just to let you know that it was exactly what I was looking for. Thanks you Walter.

I found another problem. It’s when the angle of the TreeLayout is set to 180 (like the blue picture below).

I tried to swapped the 2 points in the ComputePoints method but it still doesn’t work.

Here is how I tried to swaped those points:

Dim pt2 As Point = New Point(m.X - offX, m.Y - offY)
Dim pt3 As Point = New Point(m.X + offX, m.Y + offY)

SetPoint(1, pt3)
InsertPoint(2, pt2)

instead of this

Dim pt2 As Point = New Point(m.X - offX, m.Y - offY)
Dim pt3 As Point = New Point(m.X + offX, m.Y + offY)

SetPoint(1, pt2)
InsertPoint(2, pt3)

I don’t understand what you think the problem is.

All the red lines are embedded in a NodeGroup on which a TreeLayout is applied. Same for the blue lines except that the blue NodeGroup TreeLayout have the property Angle set to 180 (because I want change the side of the arrow).

I think that the route points are not rotated correctly. So instead of rotating the route, I tried to only swap the 2 mid points in the route…

If you don’t override ComputePoints or any other Route method, does it work the way you want? Are you saying that the code in your override method isn’t computing the points that you want? If that’s the case, you’ll need to step through all of the cases and figure out the right values.

Yes it working when I’m not overriding the ComputePoints method. What is confusing me is the TreeLayout angle. I’m wondering what happens first: The ComputePoints or the Rotating of the TreeLayout?

If the first to happens is the ComputePoints, then I thought that I don’t have to change the ComputesPoints because each Points are supposed to rotate at the same time as the TreeLayout will do.

Otherwise, if the TreeLayout is applied before the Rotating, then I thought I need to swap the order of my route Points. For example, if initialy I have 4 points on my route,
Pt1=0,0
Pt2=10,0
Pt3=20,0
Pt4=30,0

I will have to change these point to that if I want to go in the same direction as my blue arrow
Pt1=30,0
Pt2=20,0
Pt3=10,0
Pt4=0,0

That’s what I did, but it didn’t work. So I have no idea of what to do right now…

In general the layouts first call LayoutNodes in order to position the nodes the way that the layout wants, and then call LayoutLinks in order to route the links the way that the layout wants.

Ok I found what I was doing wrong.

But now, I’m in face of a new problem :P I have associated to each link a textbox like this:

The thing is that the LinkPanel of the first branch is over the LinkPanel of the second branch. Because of this, I can not acceed of to the other TextBox. Is there any way to change the depth index of the LinkPanel.