Node class and ports


I’m still evaluating GoDiagram. To check if the component fits to our
needs i try to implement a little network editor as it will be needed
in our product.

My first step is to implement the base node class. I think the best
will be to inherited from GoNode class because our nodes need to have

  • nodes can either displayed by combination of shapes or images/icons
  • nodes need to have a label to display ID and name
  • each node has 4 ports
  • there are some rules which node types can be connected by links.

Is it the best way to inherit from GoNode? And what’s the best way to
create the ports. I searched the examples for ‘new GoPort’ but did not
find a hint. Do i have to add the ports to list implemented by GoGroup?

Because our networks may become really large (up to 8000 nodes in about 300 subnets) we are interested in a smart solution.

Thanks in advance for any helpful suggestion :-)

You can certainly define your own node type from scratch by inheriting from GoNode, but you might find it easier to make use of the predefined node types. I would guess that GoTextNode would be suitable for your purpose, depending on where you want to place the label and where you want to position the ports.
You could have the GoTextNode.Background object be a GoGroup consisting of whatever GoImages and GoShapes you want. For efficiency, you can override CreateBackground, to avoid having the default background be created needlessly.
You can implement limitations on the links that users can draw by either overriding GoToolLinkingNew.IsValidLink or GoPort.IsValidLink, depending on where you want to put the code. If you subclass GoPort you’ll want to override GoTextNode.CreatePort for efficiency.
8000 nodes isn’t at all large, although it may be too large if you are using automatic layout frequently.