public void setGraphSelectionModel(GraphSelectionModel model) {
if(model == null) {
throw new NullPointerException("GraphSelectionModel must not be null");
}
GraphSelectionModel oldGraphSelectionModel = graphSelectionModel;
graphSelectionModel = model;
// Replace the current selection model, transfer the
// listeners.
Object[] selObjs = oldGraphSelectionModel.getSelectedObjects();
Iterator it = oldGraphSelectionModel.getListeners();
while(it.hasNext()) {
GraphSelectionModelListener lsnr = (GraphSelectionModelListener) it.next();
graphSelectionModel.addGraphSelectionModelListener(lsnr);
// Remove the listener from the old selection model