コード例 #1
0
ファイル: DepictionGenerator.java プロジェクト: rajarshi/cdk
 /**
  * Reset the coordinates to their position before rendering.
  *
  * @param mols molecules
  * @param scales how molecules were scaled
  */
 private static void resetCoords(Iterable<IAtomContainer> mols, List<Double> scales) {
   Iterator<Double> it = scales.iterator();
   for (IAtomContainer mol : mols) {
     final double factor = it.next();
     if (!Double.isNaN(factor)) {
       GeometryUtil.scaleMolecule(mol, 1 / factor);
     } else {
       for (IAtom atom : mol.atoms()) atom.setPoint2d(null);
     }
   }
 }
コード例 #2
0
ファイル: DepictionGenerator.java プロジェクト: rajarshi/cdk
 /**
  * Prepare a collection of molecules for rendering. If coordinates are not present they are
  * generated, if coordinates exists they are scaled to be consistent (length=1.5).
  *
  * @param mols molecules
  * @return coordinates
  * @throws CDKException
  */
 private List<Double> prepareCoords(Iterable<IAtomContainer> mols) throws CDKException {
   List<Double> scaleFactors = new ArrayList<>();
   for (IAtomContainer mol : mols) {
     if (ensure2dLayout(mol)) {
       scaleFactors.add(Double.NaN);
     } else if (mol.getBondCount() > 0) {
       final double factor = GeometryUtil.getScaleFactor(mol, 1.5);
       GeometryUtil.scaleMolecule(mol, factor);
       scaleFactors.add(factor);
     } else {
       scaleFactors.add(1d); // no bonds
     }
   }
   return scaleFactors;
 }