Is there a way to specify port "offsets"?


#1

I have a question about ports.

I can add a shape to my node template, position it, and have that be my port. This works great.
I can set a toSpot on my Link which will target a specific spot on that shape. This is also great.

What I can’t quite figure out how to do, is how to use an offset port spot inside of a shape that still does the smart thing where it ends the link line (and arrowhead, more importantly in my case) at the edge of the rendered shape.

Basically, when I set my shape to be my port, the links endpoint seems to be the center of the shape, but its length just hits the edge. This behavior is great.

What I would like, though, is to be able to specify (per link) a point or offset from center inside the port shape that retains this behavior of placing the ends / arrows of my link at the edge of the shape. If i specify a toSpot the automatic edge length behavior seems lost and the ends go right to the specified point regardless of where the edge is. I can’t use toShortLength because my shape is irregular and the link can come in from any angle.

Is this possible?


#2

There isn’t any easy way to do that in version 1.* without overriding Link.getLinkPoint to do what you want.

In version 2, it is easy to do if the offset is a fixed distance (not a fractional distance) from the center of the port. However I was just checking it, and it turns out that the change was not documented and had a bug in it anyways. So if you are able to upgrade to version 2 after the next beta release (which should be next week sometime), then it will be easy for you to specify.


#3

We are deploying production code so it makes me uncomfortable to upgrade to a beta. I’ll keep an eye out for the official release though.

For now, I can try to implement getLinkPoint myself, do you have any pointers or sample code that could help me?

Perhaps we should upgrade to a source license!

mc.


#4

I don’t know – I would search the samples and the forum for overrides of getLinkPoint.