Unselecting Node

I have a view with multiple layers. When I switch layers the selection rectangle stays visable on the screen. If I call getSelection().clearSelection() and then switch back to that layer the node is no longer there. (like it was deleted) What is the right way to unselect the object if I hide a layer?

What do you do when you “switch layers”?

I am setting the visable property to false on the one that I am “hiding” and true on the one to display.

On a sperate note on this, when I switch layers the nodes and links are not “attached” any more. If I drag a node the links do not move with it. I am pulling the layer to the top when I switch.

Well, it’s true that making a layer invisible does not remove all the selection handles of the objects in the now invisible layer. I guess that’s a bug.
And JGoSelection.clearSelection() does remove all of those selection handles, as it should.
But I don’t have any problems calling JGoLayer.setVisible(true) again to have the objects show up again.
Nor do I have any problems when re-ordering the layers. I tried cycling through several layers, by repeatedly calling:
JGoDocument doc = myView.getDocument();
doc.insertLayerAfter(doc.getLastLayer(), doc.getFirstLayer());
which should keep bringing the first (bottom) layer in front of the the last (top) layer.
If you are “losing” objects, it may be because you removed the layer from the document, thereby “deleting” all of those objects. If you want to change the order of the layers, you need to call JGoDocument.insertLayerAfter or insertLayerBefore without removing any layers (i.e. don’t call JGoDocument.removeLayer).

So I’m really back to how “should” I unselect the node?

To unselect all objects that are in a layer that you are making not visible:
JGoSelection sel = aView.getSelection();
JGoListPosition pos = aLayer.getFirstObjectPos();
while (pos != null) {
JGoObject obj = aLayer.getObjectAtPos(pos);
pos = aLayer.getNextObjectPosAtTop(pos);

OK, thanks.