Hi,
I have a new customer request to make a node that “looks like a Visio object”. While vague, I think what they are asking for is an object with a basic rectangular shape with multiple ports around the outside of the rectangle: one port at each corner and one port midway along each side, for a total of eight ports. The interior of the object, the body, could be anything, images, text or a combination of both.
In thinking about how to implement this I keep coming back to the GoBoxNode. It has the rectangular shape that I need, it implements the “body” concept, and it knows how to resize itself based on the size of the body. The fact that the rectangle (box) sits behind and is slightly larger than the body works well too. Unfortunately, the GoBoxNode only has the one port (the box!). I need eight ports.
So, what I need is a GoBoxNode-like object with eight ports. To implement this object I was thinking of using two GoNodes.
The first GoNode, the parent, would contain the 8 ports and the GoRectangle background. The eight ports would be spotted around the rectangle. The second GoNode, the body, would contain the remaining content of the object (images, text, etc…).
For my implementation, the one thing I don’t know how to do is to manage/maintain the size of the rectangle around the body, the way BoxNode does it. The body can be modified at any time based on user actions (note, resize for the sake of resize would not be allowed, only adding/removing content). Each change to the body would require a resizing of the rectangle, but I’m not sure what methods to override to do this. Also, should all of the functionality of both GoNodes be wrapped into a single class or would the parent GoNode need to be it’s own class and the body GoNode need to be it’s own class? The reason I ask this question is because I’m not sure which methods I need to override in order to resize the rectangle border around the body.
Could I implement all of this functionality using a single GoNode…, or some other set of GoObjects? Have you already implemented this functionality somewhere?
Your thoughts or comments would be greatly appreciated.
Thank you very much.
R. Houston