Skip to content

Commit

Permalink
Merge branch 'Bug3465' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
goglepox committed May 23, 2013
2 parents dc582ff + 44adefe commit 3356573
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@
import org.openscience.cdk.layout.StructureDiagramGenerator;
import org.openscience.cdk.libio.cml.ICMLCustomizer;
import org.openscience.cdk.modeling.builder3d.ModelBuilder3D;
import org.openscience.cdk.nonotify.NNAtomContainer;
import org.openscience.cdk.nonotify.NNChemFile;
import org.openscience.cdk.nonotify.NNMolecule;
import org.openscience.cdk.nonotify.NNMoleculeSet;
import org.openscience.cdk.renderer.AtomContainerRenderer;
import org.openscience.cdk.renderer.font.AWTFontManager;
import org.openscience.cdk.renderer.generators.BasicAtomGenerator;
Expand Down Expand Up @@ -213,7 +209,8 @@ public String getManagerName() {
}

public ICDKMolecule newMolecule() {
return new CDKMolecule(new NNAtomContainer());
IChemObjectBuilder scob = SilentChemObjectBuilder.getInstance();
return new CDKMolecule( scob.newInstance( IAtomContainer.class ) );
}

public ICDKMolecule newMolecule(IAtomContainer atomContainer) {
Expand All @@ -229,7 +226,8 @@ public List<ICDKMolecule> asList(IMoleculeSet set) {
}

public IMoleculeSet asSet(List<ICDKMolecule> list) {
IMoleculeSet set = new NNMoleculeSet();
IChemObjectBuilder scob = SilentChemObjectBuilder.getInstance();
IMoleculeSet set = scob.newInstance( IMoleculeSet.class );
for (ICDKMolecule mol : list)
set.addAtomContainer(mol.getAtomContainer());
return set;
Expand Down Expand Up @@ -334,15 +332,17 @@ public ICDKMolecule loadMolecule( InputStream instream,

// Read file
try {
IChemObjectBuilder scob =
SilentChemObjectBuilder.getInstance();
if (reader.accepts(ChemFile.class)) {

IChemFile chemFile =
(IChemFile) reader.read(new NNChemFile());
(IChemFile) reader.read(scob.newInstance( IChemFile.class ));
atomContainersList =
ChemFileManipulator.getAllAtomContainers(chemFile);
} else if (reader.accepts(Molecule.class)) {
atomContainersList.add(
(NNMolecule) reader.read(new NNMolecule())
);
atomContainersList.add( reader.read( scob
.newInstance( IAtomContainer.class ) ) );
} else {
throw new RuntimeException("Failed to read file.");
}
Expand Down Expand Up @@ -1589,7 +1589,9 @@ public List<ICDKMolecule> getSubstructures(ICDKMolecule molecule,
int i = 1;
for (List<RMap> substruct : substructures) {
// convert the RMap into an IAtomContainer
IAtomContainer match = new NNAtomContainer();
IChemObjectBuilder scob =
SilentChemObjectBuilder.getInstance();
IAtomContainer match = scob.newInstance( IAtomContainer.class );
for (RMap mapping : substruct) {
IBond bond = originalContainer.getBond(mapping.getId1());
for (IAtom atom : bond.atoms()) match.addAtom(atom);
Expand Down

0 comments on commit 3356573

Please sign in to comment.