GoStrokes


#1

Hi,
I am currently trying to replicate functionality for a ‘pipe’ component. The pipe component is a resizable component that has connection points at the start, middle and end and and is capable of being waypointed, adding points to the line to allow the user to shape it. Looking at the go objects it is most similar to a gostroke, the gostroke object has alot of inbuilt functionality that would help us replicate the pipe model.
So what I need to do is get an instance of a gostroke and place ports at the ends and centre of the stroke. The problems I have are as follows

  1. I cannot add the ports to the stroke as I can with for example a go simple node
  2. I cannot add the ports and group the objects so that the ports move with the stroke as we have a layer manager and as far as I understand as soon as I add the ‘pipe’ to the layer manager it will ungroup the stroke and the ports
  3. I can position ports at the ends and centre and use events in the view class to reposition the ports but this results in the code getting rather messy and fragmented, I would prefer to keep it all in a pipe class.
    I have considered using a golink but then we have other default functionality that is a problem and I still have the problem of repositiong etc. the port at the centre of the link so I think go strokes would be the best thing to use
    I can think of some rather complicated ways around this but I would prefer to keep it as elegant and simple as possible (if at all possible), do you have any ideas / thoughts on how we could make this work effectively.

many thanks,


#2

Could you use a GoLabeledLink, and set the FromLabel, MidLabel, and ToLabel to be GoPorts? If you want the user to be able to drag the pipe around by itself, you want to set Movable to true.

  1. GoLabeledLink is a GoGroup, so it can contain objects such as the standard three …Labels.
  2. I don’t know what your layer manager does, but maybe you are referring to links being disconnected when nodes are reparented from a group to a layer or vice-versa or between different groups. You can use the AddCollection method on GoLayer or GoGroup to avoid that requirement.
  3. Agreed.