Icon, Box, General Node hybrid

I’m looking for a cross between a box node and a general node. I would like the source (left) port to be centered behind the Icon like the box node or Icon Node and multiple

Right ports off to the side to connect to other nodes.

<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The links intersecting the closest edge of the Icons box looks better then grouped to a single left port.

Also

Is it possible for a right port to point back to the edge of the icon on its node?

Thanks,

Mike

Sure you could easily define a GoGeneralNode so that the right-side ports act in the normal way but that you had a single left-side port. There are several aspects to consider for this port.
For its appearance, you may want to not to have any particular appearance. Set its GoPort.Style to GoPortStyle.None.
For how links connect to the port, set its GoPort.PortObject to be the GoGeneralNode.Icon, and its FromSpot and ToSpot to be GoObject.NoSpot. That will cause the GoPort.GetFromLinkPoint and GetToLinkPoint methods to return the closest intersection points with the GoPort.PortObject (i.e. with the Icon).
For how the user may draw a new link from the port, you may need to override GoGeneralNode.LayoutChildren to first call the base method and then reposition, and perhaps resize, the port to where you want it to be responsive. The bounds of the port (assuming it is not occluded by other GoObjects) will be available for drawing a new link and thus will be associated with the “pointer”/“hand” cursor.
You’ll note that in the GoIconicNode class, its port is actually centered in the Icon, and you may want to do the same. But then again, maybe you’d prefer it to be in the middle of the left side of the Icon. And maybe you’d rather it be sized to cover the whole left half of the Icon. I can’t decide that for you and for your application – you need to design it the way it is best for you. But you should put that code into your override of GoGroup.LayoutChildren.

Thanks for the Reply,

I have followed your suggestions and the behavior is close, currently the left is hidden and off to the left side of the icon, I have set <?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

port.PortObject = node.Icon

But I’m unclear on how to get the links to move around the icon and snap to the closest side like they do in the BoxNode?

Also

I’m unclear on how to grab a right port and draw a link to the left port of the same node (appearing as a 270 degree pointer from the right port back to the icon edge)

Thanks Again

Mike

(here’s wher’re i’m at)
Dim node As Go.GoGeneralNode = New Go.GoGeneralNode
node.Icon = New Go.GoImage
node.Image.ImageList = ImageList2
node.Image.Index = 1
node.Image.Width = 75
node.Image.Height = 75
node.Image.Resizable = False
node.Image.Reshapable = False
node.Reshapable = False
node.Editable = False
node.Resizable = False
Dim port As Go.GoGeneralNodePort = New Go.GoGeneralNodePort()
port.Style = Go.GoPortStyle.None
port.PortObject = node.Icon
port.FromSpot = Go.GoObject.NoSpot
port.ToSpot = Go.GoObject.NoSpot
node.AddLeftPort(port)
Dim lport1 As Go.GoGeneralNodePort = New Go.GoGeneralNodePort()
lport1 = New Go.GoGeneralNodePort()
lport1.Style = Go.GoPortStyle.Triangle
lport1.Label = New Go.GoGeneralNodePortLabel()
lport1.Label.Text = “1”
lport1.Label.FontSize = 6.5
node.AddRightPort(lport1)
Dim lport2 As Go.GoGeneralNodePort = New Go.GoGeneralNodePort()
lport2 = New Go.GoGeneralNodePort()
lport2.Style = Go.GoPortStyle.Triangle
lport2.Label = New Go.GoGeneralNodePortLabel()
lport2.Label.Text = “2”
lport2.Label.FontSize = 6.5
node.AddRightPort(lport2)
GoView1.Document.Add(node)

Well, you could try using a GoBoxPort instead of a GoGeneralNodePort. That kind of port is smart about trying to have the link come in to the closest side, perpendicular to that side.
You can create links programmatically, of course, to connect any two ports. If you want users to be able to draw such a link, you’ll need to set GoPort.IsValidSelfNode to true on both ports.
However, the default routing for such a link might just be a 180-degree loop rather than a 270-degree one. You’ll have to try it. It might be possible to disallow that by overriding a method or two of GoPort (or GoBoxPort if you use that). I think there are some examples of this in the samples–for example the CustomSubGraphPort class in CustomSubGraph.vb of the SubGraphApp sample application overrides some methods to have internal links connect to/from the inside of the port’s edges, while external links connect normally.

Thanks for the prompt reply Walter,
You said “you could try using a GoBoxPort instead of a GoGeneralNodePort. That kind of port is smart about trying to have the link come in to the closest side, perpendicular to that side.”
Are you saying to change to a BoxNode, or cast GeneralPort to a BoxPort or pass as Object? If I change to a Boxnode I loose the Icon and multiple right ports?
Mike

I meant to replace that particular port with a GoBoxPort, with the same Bounds as the Icon I guess. You didn’t need the GoGeneralNodePortLabel that goes along with that GoGeneralNodePort, did you?
It’s true that if you were to replace your node with a GoBoxNode you would lose the Icon and multiple right ports. You could add them back again if you wanted to. But I didn’t think that extra work was necessary. (Although I can’t be sure since I haven’t tried it, and since I’m not sure exactly what you want to do.)
It might take a while to learn, but GoDiagram was designed for programmers. You can mix and match all kinds of objects and set various properties or override methods to get the behavior you want.

I meant to replace that particular port with a GoBoxPort, with the same Bounds as the Icon I guess. You didn’t need the GoGeneralNodePortLabel that goes along with that GoGeneralNodePort, did you?
No, I dont need the label on the Left port (now the icon)
It’s true that if you were to replace your node with a GoBoxNode you would lose the Icon and multiple right ports. You could add them back again if you wanted to. But I didn’t think that extra work was necessary. (Although I can’t be sure since I haven’t tried it, and since I’m not sure exactly what you want to do.)
I would like a icon node with either 1,6,8 right ports and one left port that is the icon itself. If two of these were on a surface, right port #6 could connect to the icon of a second node. As the two nodes were moved, the link would move to the closest side. Additionally if it would be possible for the links to stay away from the right side of the icon that would prevent links from initially intersecting the right ports.
It might take a while to learn, but GoDiagram was designed for programmers. You can mix and match all kinds of objects and set various properties or override methods to get the behavior you want.
Sounds good, I dont mind learning :) Is their a good example you can point me at to start.
Thanks Again,
Mike

There are lots of good examples in the sample applications. Look for classes that inherit from GoPort and override some or all of the four Get[From/To]Link[Dir/Point] methods. That’s what GoBoxPort does, and that’s what CustomSubGraphPort does.
The SidewaysPort class in ObjectBrowser might also be instructive, since sometimes it only allows links from/to the left and from/to the right, but other times only from/to the bottom, depending on whether or not the port is the last port in the node’s list of ports.