selectionChanged();
}
// OK
public void addFragment(IAtomContainer toPaste, IAtomContainer moleculeToAddTo, IAtomContainer toRemove) {
IAtomContainerSet newMoleculeSet = chemModel.getMoleculeSet();
if (newMoleculeSet == null) {
newMoleculeSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
}
IAtomContainerSet oldMoleculeSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
if (moleculeToAddTo == null) {
newMoleculeSet.addAtomContainer(toPaste);
moleculeToAddTo = toPaste;
} else {
IAtomContainer mol = chemModel.getBuilder().newInstance(IAtomContainer.class);
for (IAtom atom: moleculeToAddTo.atoms())
mol.addAtom(atom);
for (IBond bond: moleculeToAddTo.bonds())
mol.addBond(bond);
oldMoleculeSet.addAtomContainer(mol);
moleculeToAddTo.add(toPaste);
}
if (toRemove != null) {
oldMoleculeSet.addAtomContainer(toRemove);
moleculeToAddTo.add(toRemove);
updateAtoms(toRemove, toRemove.atoms());
newMoleculeSet.removeAtomContainer(toRemove);
}
for (IAtomContainer ac: newMoleculeSet.atomContainers())