LinkShifting - snap to grid


I’m using SnapLinkReshaping tool and LinkShifting tool in my diagram. I added some code from SnapLinkReshaping to LinkShifting so it snaps to grid when I change link position.

I have a small issue though. When The adornment is right on the corner, there is a 45deg angle, because it can’t decide what’s the grid origin probably. Is there a way to fix this?


You’ll need to further adapt the code in LinkShiftingTool.doReshape so that the Spot it uses does not include corner values. That means Spot.x and Spot.y values that are not:

  • 0,0
  • 1,0
  • 1,1
  • 0,1

Say that the existing code computes a Spot that is new go.Spot(0, 1), at the bottom left corner. You will need to decide the direction that you want the end segment to go – towards the left or downwards. If you want it to go leftwards, use new go.Spot(0, 0.9999). If you want it to go downwards, use new go.Spot(0.0001, 1).

You will also need to do analogous adjustments for the other three corners.