while (i.hasNext()) {
Figure f = (Figure) i.next();
Interactor r = f.getInteractor();
if ((r != null) && r instanceof SelectionInteractor) {
SelectionInteractor interactor = (SelectionInteractor) r;
if (_selectionModels.contains(interactor
.getSelectionModel())) {
expandSelection((SelectionInteractor) r, f);
}
}
}
// Remove figures from the selection
i = staleFigures.iterator();
while (i.hasNext()) {
Figure f = (Figure) i.next();
Interactor r = f.getInteractor();
if ((r != null) && r instanceof SelectionInteractor) {
SelectionInteractor interactor = (SelectionInteractor) r;
if (_selectionModels.contains(interactor
.getSelectionModel())) {
contractSelection((SelectionInteractor) r, f);
}
}
}
} else {
// Toggle figures into and out of the selection
Iterator i = new CompoundIterator(freshFigures.iterator(),
staleFigures.iterator());
while (i.hasNext()) {
Figure f = (Figure) i.next();
Interactor r = f.getInteractor();
if ((r != null) && r instanceof SelectionInteractor) {
SelectionInteractor interactor = (SelectionInteractor) r;
if (_selectionModels.contains(interactor
.getSelectionModel())) {
if (interactor.getSelectionModel().containsSelection(f)) {
contractSelection(interactor, f);
} else {
expandSelection(interactor, f);
}
}