Skip to content

Commit

Permalink
Remove empty atom containers when doing a cleanup
Browse files Browse the repository at this point in the history
solvs bug 3213
  • Loading branch information
goglepox committed Sep 6, 2012
1 parent 0f1ba0c commit 0387207
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -42,6 +42,7 @@
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IBond.Order;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.renderer.RendererModel;
import org.openscience.cdk.renderer.generators.BasicAtomGenerator;
import org.openscience.cdk.renderer.generators.AtomNumberGenerator.WillDrawAtomNumbers;
Expand Down Expand Up @@ -356,6 +357,17 @@ public void cleanup(IProgressMonitor monitor) throws BioclipseException{
if (editor != null) {
monitor.beginTask( "Cleaning up of structure", IProgressMonitor.UNKNOWN );
IChemModelRelay relay = editor.getControllerHub();
// Removes empty atomcontainers
// This is a dirty fix until we can work on a single atom container instead of a ChemModel
List<IAtomContainer> toRemove = new ArrayList<IAtomContainer>();
IMoleculeSet mSet = relay.getIChemModel().getMoleculeSet();
for(IAtomContainer ac:mSet.molecules()) {
if(ac.getAtomCount()==0)
toRemove.add(ac);
}
for(IAtomContainer ac:toRemove) {
mSet.removeAtomContainer(ac);
}
try{
relay.cleanup();
} catch (NullPointerException e) {
Expand Down

0 comments on commit 0387207

Please sign in to comment.