JGoRoundRect with JGoPorts


#1

Is it possible to have a JGoRoundRect with JGoPorts? It seems that JGoPorts depends on JGoArea and JGoRoundRect is not subclassed off JGoArea. If it can’t be done, then what is the recommended way to get ports on rounded rectangles/ellipses/circles and also have text inside of the rectangles/ellipses/circles?
Thanks


#2

It depends on what you want.
Do you want there to be just one port for the node and links aim at the center but end at the intersection with the shape? Then use a JGoBasicNode with a LabelSpot of Center. You can either call setDrawable to specify the shape, or you can override createDrawable so you can be sure to have the shape you want for that class.
Do you want there to be ports on each of the four sides? Then use JGoTextNode. You can set the Background object (which can be any JGoObject, not just a JGoDrawable), or you can override createBackground. And you don’t have to have four ports–if you don’t need some of them, you can just set them to null, or override createPort to decide which ones to create.
Demo1 shows a JGoTextNode with a JGoRoundedRect background. It also shows several different JGoBasicNodes with various shapes and properties, although I don’t see one with a rounded rectangle.