Fishbone questions

I’m a newbie to GoDiagram. I’ve been playing with the Fishbone sample and I have 3 questions about it:

  1. I changed the arrowheads at the end of links to circles. But the circles do not end up centered on the target line, they’re just outside the line, tangent to it. Is there a way to center the circles on the target line precisely? I tried playing with Lenght and ShaftLegth to no avail.

this.ToArrowStyle = GoStrokeArrowheadStyle.Circle;
this.ToArrowShaftLength = 5;
this.ToArrowLength = 0;

  1. I have a row of fishnodes connected vertically to a horizontal main target link (like a picket fence). When I select a fishnode, I’d like its corresponding link (the “picket”) to become selected, too. How would I do this?

  2. How would I programatically loop through all the fishnodes in the order they’re attached to the target link, that is from left to right? The links have been shifted around, so that their left-to-right ordering doesn’t correspond to their “age” or an index number.

Thanks

Circle on link:
In the FishRealLink class, add:
[code]
public override void CalculateArrowhead(PointF anchor, PointF endPoint, bool atEnd, PointF[] poly) {
base.CalculateArrowhead(anchor, endPoint, atEnd, poly);
SizeF width = new SizeF(this.ToArrowShaftLength/2, 0);
poly[0] = this.ToArrowEndPoint - width;
poly[2] = this.ToArrowEndPoint + width;
}
[/code]
(if you look at the API reference for DrawArrowHead, you'll see:
When the arrowhead style is GoStrokeArrowheadStyle.Circle, the
polygon's [0] and [2] points are used to position the circle.
Now... this also changes the arrowheads where links connect to nodes.
which looks a little funny to me. Increasing the margin in the nodes would help, I think.
I'll answer the other 2 in a bit....

You’ll note the angle on the attaching links is more “fishbone-ish” than the sample that ships in 3.0.2. We’ve made some enhancements to the FishBone sample for a future release.

2) I have a row of fishnodes connected vertically to a horizontal main target link (like a picket fence). When I select a fishnode, I’d like its corresponding link (the “picket”) to become selected, too. How would I do this?

Add an ObjectGotSelection event handler to your GoView control...
[code]
private void goView1_ObjectGotSelection(object sender, GoSelectionEventArgs e) {
FishNode node = e.GoObject as FishNode;
if (node != null) {
foreach (FishLink link in node.DestinationLinks) {
goView1.Selection.Add(link);
}
}
}
[/code]
note there's only ever going to be 0 or 1 DestinationLink(s) here, but the foreach was easier to code.

3) How would I programatically loop through all the fishnodes in the order they’re attached to the target link, that is from left to right? The links have been shifted around, so that their left-to-right ordering doesn’t correspond to their “age” or an index number.

This is a little trickier than normal diagram traversal (which is covered in the User Guide... but you should go read that as a starting point).
In FishBone, you have links connecting to other links. A FishLinkPort is created and set as the MidLabel of the FishLink. (FishLink is a GoLabeledLink, which is a GoGroup with a "RealLink" and other objects like labels.)
The FishLink has a "ToPort" property. That's the FishLinkPort on the link that the FishLink is connected to. From the FishLinkPort, you can get the PortObject, which is the FishRealLink. From the FishRealLink, you can get the Parent, which is the FishLink.
The ToPort has SourceLinks property, which is the links connecting in to the link associated with that ToPort.
(clear as mud?.... set a break point in the ObjectGotSelection event, and look at the structures with the debugger. that should help.)
Now, I've described the parts here, not how to iterate. You can iterate through the GoDocument to get all the top level objects (some of which will be FishNodes). The FishNode with 1 SouceLink will be the "Effect" node... the end point. Starting at the end point and doing a recursive track back to the start points may be the best way to "traverse" the diagram while getting a sense of the age/index.
Ponder that a bit, it depends a lot on what you're application needs are. If you need more help, just shout.

better arrowhead code:

[code]
public override void CalculateArrowhead(PointF anchor, PointF endPoint, bool atEnd, PointF[] poly) {
base.CalculateArrowhead(anchor, endPoint, atEnd, poly);
if (this.ToArrowStyle == GoStrokeArrowheadStyle.Circle && this.ToNode == null) {
SizeF width = new SizeF(this.ToArrowShaftLength / 2, 0);
poly[0] = this.ToArrowEndPoint - width;
poly[2] = this.ToArrowEndPoint + width;
}
}
[/code]
this only affects Circle heads that connect to links....

Jake, kind thanks for the exhaustive reply. I’ve already implemented #1 & #2 and they work like a charm. As far as #3, I think I’ll keep it simple: I’ll list the top-level objects, filter out the fishnodes, and sort their IDs into an array based on the x coordinate. Will let you know if I encounter problems. Thanks again. Smile

Can the circle arrowhead (as above) be drawn as an “empty” white dot with a black outline, as opposed to an entirely black dot?

Set the link’s Brush to null (for no fill) or to Brushes.White (for a solid white fill).

Works great, thanks.