Snap problem

I have a canvas and few objects with links between them,
when snap them to topleft or topright all objects are snapped to the respective option, but these links also getting snapped and hence it is appearing as link is gone between the objects…how do go ahead with …

thanks
john

JGoView.moveSelection does not move any links to “snap” them to the nearest grid point, but instead moves them by the same offset as the first non-link that it moves in order to “snap” in place.
That way all links stay in exactly the same positions relative to the nodes. Of course, it is entirely possible that the relative positions of the nodes will change, as different nodes get moved to different grid points. That would cause the connected links to be recalculated (JGoLink.calculateStroke() to be called).

Thanks, Understood the problem…
but can u give me a solution how to go abt it…

Thanks
john

If you could tell me what the problem is…

The problem is …I will try like this…
I have four objects and they are aligned to topleft of the grid,all of objects having links between them, If i snap to the right side of the grid, It appears as the link between the objects is broken, and later if i select an object and move it will appear perfectly.
so when i align it to respective position, how can i see that it doesn’t appear as the link is broken.
This is what the problem is…
sorry if i am not able to explain it properly…
waiting for ur help…
thanks
john

Oh, so are you calling JGoView.snapAllObjects? I can see how that wouldn’t do the right thing for links. That might be a bug. Try the following definition instead:
public void snapAllObjects(int spotNumber) {
JGoDocument doc = getDocument();
// for each toplevel object in the document
JGoListPosition pos = doc.getFirstObjectPos();
while (pos != null) {
JGoObject obj = doc.getObjectAtPos(pos);
pos = doc.getNextObjectPosAtTop(pos);
// align the object
if (obj instanceof JGoLink) continue;
snapObject(obj, spotNumber);
}
}
If you don’t want to define a subclass of JGoView to define this override, you can just execute the code for your document.