Port Location

Hi All,

Simple question but…

I have a subclass of JGoIconicNode and I want to add a port to it and I
want the port to be at the bottom center of the node. How do I do this?



So you want two separate ports on a JGoIconicNode? Basically you just need to create a port, give it the bounding rectangle that you want relative to the node’s Icon, and add it to the node.
If you expect the size of the icon to change, then you’ll want to override layoutChildren to call the super method and then position the port where you want it, again relative to the Icon. (If you do this, then you won’t need to do the positioning code in the initialization, since layoutChildren is called automatically.)
As a separate issue, if you add a field to a JGoObject-derived class, you’ll want to override copyObject. Or if the class inherits from JGoArea, and it’s a reference to a child JGoObject, override copyChildren instead.
There are lots of examples of this. MultiPortNode, by the way, adds a varying number of ports to a JGoIconicNode.