Bezier curves.... Node avoidance...etc

I posted a topic on links linking to themselves and having the link go around the node…but the solutions proposed dont work…even if i make a link exactly like the StateCharter example…it doesnt work…so im wondering what properties affect link creation…im stuck and it sucks bad. I need :

  • Links going around a GoSimpleNode (from - to). (now they go over the node.
  • Links with a modified curviness so that multiple links from node a to node b have a different curve to dissociate them. (actually they are over one another).
    I really dont get it…i tried everything…my GoLink class is exactly the same has the GoLabeledLink in the StateCharter sample… only difference is that my links have different brush and pen width and color…

Did you set the .InPort.ToSpot = GoObject.NoSpot? and the same for the .OutPort.FromSpot?
If you are creating the link programmatically, did you call GoLink.CalculateStroke() after the link and node are part of the GoDocument?
I just tried this, and it seems to work fine, although the shape of the curve might not be exactly what you would expect…
GoSimpleNode gsn1 = new GoSimpleNode();
gsn1.Initialize(null, null, “hello”);
gsn1.InPort.ToSpot = GoObject.NoSpot;
gsn1.InPort.IsValidSelfNode = true;
gsn1.InPort.IsValidDuplicateLinks = true;
gsn1.OutPort.FromSpot = GoObject.NoSpot;
gsn1.OutPort.IsValidSelfNode = true;
gsn1.OutPort.IsValidDuplicateLinks = true;
doc.Add(gsn1);
GoLink gl = new GoLink();
gl.FromPort = gsn1.OutPort;
gl.ToPort = gsn1.InPort;
gl.Style = GoStrokeStyle.Bezier;
gl.Curviness = -50;
doc.Add(gl);

Ok here is my code…
// Important Node code…
public class StateView : Northwoods.Go.GoSimpleNode
{
public StateView()
{
Initialize();
}
protected override GoPort CreatePort(bool input)
{
GoBoxPort port = new GoBoxPort();

port.Size = new SizeF(5, 20);
port.Brush = input? Brushes.DarkOrange : Brushes.Orange;
port.Pen = (this.Icon as GoRectangle).Pen;
port.IsValidFrom = !input;
port.IsValidTo = input;
port.IsValidSelfNode = true;
port.IsValidDuplicateLinks = true;
if(input)
port.ToSpot = GoPort.NoSpot;
else
port.FromSpot = GoPort.NoSpot;

return port;
}
protected override GoObject CreateIcon(System.Resources.ResourceManager res, string iconname)
{
GoRoundedRectangle rect = new GoGradientRoundedRectangle();
rect.Selectable = false;
rect.Resizable = false;
rect.Pen = Pens.DarkOrange;
rect.Size = new SizeF(60, 60);
rect.Brush = new LinearGradientBrush(rect.Bounds, Color.DarkOrange, Color.Orange, 0.0f);
return rect;
}


#region Initialize
private void Initialize()
{
Initialize(null, null, “”);

this.Selectable = true;
this.Resizable = false;
}
}
// Important Link code…
public override GoLink CreateRealLink()
{
return new InternalTransitionView(this);
}
public class InternalTransitionView : GoLink
{
public InternalTransitionView(TransitionView tv)
{
parent = tv;
Initialize();
}
private void Initialize()
{
this.Style = GoStrokeStyle.Bezier;
this.HighlightWhenSelected = true;
this.HighlightPen = new Pen(Color.White, 4);
this.Brush = Brushes.PaleVioletRed;
this.Pen = new Pen(Color.PaleVioletRed, 2);
this.ToArrow = true;
this.Orthogonal = true;
this.Relinkable = false;
this.AvoidsNodes = true;
this.Curviness = -50;
}
}

Linking using the UI and not programatically…doesnt give me the same result has you…

Ok now the Curviness works…but when using the Curviness i cant use the Orthogonal(true) property… so now im left with one problem… the curviness works like the StateCharter example…but the difference in my case is that in the StateCharter example the nodes have only a port and the link loops when linking a node to itself…i want to do the same thing but i have a GoSimpleNode that has 2 ports…and i want the link to go over the state in a big loop…is it possible? Or do i have to do it programatically?

Whoa–you’re using a GoBoxPort.
Hmmm. Let’s go back to the beginning. Does the following code do what you want, with just one important exception: handling multiple “looping” links from the OutPort to the InPort? (Yes, I’m simplifying by using GoSimpleNode instead of GoGeneralNode.)
GoSimpleNode gsn = new GoSimpleNode();
gsn.Initialize(null, null, “hello”);
gsn.InPort.IsValidSelfNode = true;
gsn.InPort.IsValidDuplicateLinks = true;
gsn.OutPort.IsValidSelfNode = true;
gsn.OutPort.IsValidDuplicateLinks = true;
doc.Add(gsn);
GoLink gl = new GoLink();
gl.Orthogonal = true;
gl.FromPort = gsn.OutPort;
gl.ToPort = gsn.InPort;
doc.Add(gl);
gl.CalculateStroke();
If so, then another possibility is to override GoLink.AddOrthoPoints to just call the base method and then to adjust the points according to how far from the node you want that particular link to be. You could also decide whether to have the loop go above or below the node (at smaller or larger Y coordinates).
You’ll note that this code is very ordinary–the only thing slightly unusual is setting the GoPort.IsValidSelfNode property. It’s basically the same thing I said in the earlier thread: http://www.nwoods.com/forum/forum_posts.asp?TID=403