Logo Search packages:      
Sourcecode: cdk version File versions  Download package

void org::openscience::cdk::layout::StructureDiagramGenerator::handleAliphatics (  ) throws CDKException [inline, private]

Does a layout of all aliphatic parts connected to the parts of the molecule that have already been laid out. Starts at the first bond with unplaced neighbours and stops when a ring is encountered.

Exceptions:
org.openscience.cdk.exception.CDKExceptionif an error occurs

Definition at line 584 of file StructureDiagramGenerator.java.

References org::openscience::cdk::tools::LoggingTool::debug(), org::openscience::cdk::layout::AtomPlacer::distributePartners(), org::openscience::cdk::geometry::GeometryTools::get2DCenter(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IAtomContainer::getAtomCount(), org::openscience::cdk::interfaces::IAtomContainer::getAtomNumber(), org::openscience::cdk::layout::AtomPlacer::getLongestUnplacedChain(), getNextAtomWithAliphaticUnplacedNeigbors(), org::openscience::cdk::layout::AtomPlacer::getNextBondVector(), getPlacedAtoms(), org::openscience::cdk::interfaces::IAtom::getPoint2d(), getUnplacedAtoms(), org::openscience::cdk::CDKConstants::ISPLACED, org::openscience::cdk::layout::AtomPlacer::listNumbers(), org::openscience::cdk::layout::AtomPlacer::placeLinearChain(), and org::openscience::cdk::interfaces::IChemObject::setFlag().

Referenced by generateCoordinates().

      {
            logger.debug("Start of handleAliphatics");

            int safetyCounter = 0;
            IAtomContainer unplacedAtoms = null;
            IAtomContainer placedAtoms = null;
            IAtomContainer longestUnplacedChain = null;
            IAtom atom = null;

            Vector2d direction = null;
            Vector2d startVector = null;
            boolean done;
            do
            {
                  safetyCounter++;
                  done = false;
                  atom = getNextAtomWithAliphaticUnplacedNeigbors();
                  if (atom != null)
                  {
                        unplacedAtoms = getUnplacedAtoms(atom);
                        placedAtoms = getPlacedAtoms(atom);

                        longestUnplacedChain = atomPlacer.getLongestUnplacedChain(molecule, atom);

                        logger.debug("---start of longest unplaced chain---");
                        try
                        {
                              logger.debug("Start at atom no. " + (molecule.getAtomNumber(atom) + 1));
                              logger.debug(atomPlacer.listNumbers(molecule, longestUnplacedChain));
                        } catch (Exception exc) {
                              logger.debug(exc);
                        }
                        logger.debug("---end of longest unplaced chain---");

                        if (longestUnplacedChain.getAtomCount() > 1)
                        {

                              if (placedAtoms.getAtomCount() > 1)
                              {
                                    logger.debug("More than one atoms placed already");
                                    logger.debug("trying to place neighbors of atom " + (molecule.getAtomNumber(atom) + 1));
                                    atomPlacer.distributePartners(atom, placedAtoms, GeometryTools.get2DCenter(placedAtoms), unplacedAtoms, bondLength);
                                    direction = new Vector2d(longestUnplacedChain.getAtom(1).getPoint2d());
                                    startVector = new Vector2d(atom.getPoint2d());
                                    direction.sub(startVector);
                                    logger.debug("Done placing neighbors of atom " + (molecule.getAtomNumber(atom) + 1));
                              } else
                              {
                                    logger.debug("Less than or equal one atoms placed already");
                                    logger.debug("Trying to get next bond vector.");
                                    direction = atomPlacer.getNextBondVector(atom, placedAtoms.getAtom(0), GeometryTools.get2DCenter(molecule),true);

                              }

                              for (int f = 1; f < longestUnplacedChain.getAtomCount(); f++)
                              {
                                    longestUnplacedChain.getAtom(f).setFlag(CDKConstants.ISPLACED, false);
                              }
                              atomPlacer.placeLinearChain(longestUnplacedChain, direction, bondLength);

                        } else
                        {
                              done = true;
                        }
                  } else
                  {
                        done = true;
                  }
            } while (!done && safetyCounter <= molecule.getAtomCount());

            logger.debug("End of handleAliphatics");
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index