Add label to a link in a specific position?

Hey you all,

I went through all the documentation looking for something that would give me a clue about how to add a label at a specific position on a GoLabeledLink but I couldn’t find anything.

I know about the MidLabel and the others but what I need is a label positioned exactly in the place that the user clicked on the link. I have the position but don’t now how to add the label there (if that is possible).

If some of you have experience with this, please help!

The position of each label that is a child of a GoLabeledLink is determined by the LayoutChildren method. GoLabeledLink.LayoutChildren’s implementation positions each of the standard three labels that it knows about. The MidLabel is positioned by the LayoutMidLabel method.

So if you will have at most one such label (remember, a “label” can be a GoObject of any type, not just a GoText object), I suggest you override the LayoutMidLabel method.

However, the difficulty is in knowing where to position the label when the link’s stroke points are recalculated, for example, when one of the nodes that the link is connected to is moved.

One way to solve that problem is to associate positioning information with the label. This also handles the case where you have more than one label on a single GoLabeledLink.

This is demonstrated by the FlowLink and LinkLabel classes in the Processor sample.

I suggest you adapt these two classes for your own purposes.