Package org.openscience.cdk.layout

Examples of org.openscience.cdk.layout.AtomPlacer


      }
      moleculeSet.addAtomContainer(atomCon);
    }

    // The AtomPlacer generates coordinates for the new atom
    AtomPlacer atomPlacer = new AtomPlacer();
    atomPlacer.setMolecule(chemModel.getBuilder().newInstance(IAtomContainer.class,atomCon));
    double bondLength;
    if (atomCon.getBondCount() >= 1) {
      bondLength = GeometryTools.getBondLengthAverage(atomCon);
    } else {
      bondLength = calculateAverageBondLength(chemModel.getMoleculeSet());
    }

    // determine the atoms which define where the
    // new atom should not be placed
    List<IAtom> connectedAtoms = atomCon.getConnectedAtomsList(atom);

    if (connectedAtoms.size() == 0) {
      Point2d newAtomPoint = new Point2d(atom.getPoint2d());
      double angle = Math.toRadians(-30);
      Vector2d vec1 = new Vector2d(Math.cos(angle), Math.sin(angle));
      vec1.scale(bondLength);
      newAtomPoint.add(vec1);
      newAtom.setPoint2d(newAtomPoint);
    } else if (connectedAtoms.size() == 1) {
      IAtomContainer ac = atomCon.getBuilder().newInstance(IAtomContainer.class);
      ac.addAtom(atom);
      ac.addAtom(newAtom);
      Point2d distanceMeasure = new Point2d(0, 0); // XXX not sure about
      // this?
      IAtom connectedAtom = connectedAtoms.get(0);
      Vector2d v = atomPlacer.getNextBondVector(atom, connectedAtom,
          distanceMeasure, true);
      atomPlacer.placeLinearChain(ac, v, bondLength);
    } else {
      IAtomContainer placedAtoms = atomCon.getBuilder().newInstance(IAtomContainer.class);
      for (IAtom conAtom : connectedAtoms)
        placedAtoms.addAtom(conAtom);
      Point2d center2D = GeometryTools.get2DCenter(placedAtoms);

      IAtomContainer unplacedAtoms = atomCon.getBuilder()
          .newInstance(IAtomContainer.class);
      unplacedAtoms.addAtom(newAtom);

      atomPlacer.distributePartners(atom, placedAtoms, center2D,
          unplacedAtoms, bondLength);
    }

    atomCon.addAtom(newAtom);
    atomCon.addBond(newBond);
View Full Code Here


                        }
                    }
                    container.removeAtomAndConnectedElectronContainers(ac.getAtom(0));
                    ac.removeAtom(ac.getAtom(0));
                }
                AtomPlacer ap=new AtomPlacer();
                while(lastplaced!=null){
                    IAtomContainer placedNeighbours=ac.getBuilder().newInstance(IAtomContainer.class);
                    IAtomContainer unplacedNeighbours=ac.getBuilder().newInstance(IAtomContainer.class);
                    List<IAtom> l=container.getConnectedAtomsList(lastplaced);
                    for(int i=0;i<l.size();i++){
                        if(l.get(i).getPoint2d()!=null)
                            placedNeighbours.addAtom((IAtom)l.get(i));
                        else
                            unplacedNeighbours.addAtom((IAtom)l.get(i));
                    }
                    ap.distributePartners(lastplaced, placedNeighbours, GeometryTools.get2DCenter(placedNeighbours), unplacedNeighbours, 1.4);
                    IRingSet ringset=new SSSRFinder(container).findSSSR();
                    for(IAtomContainer ring:ringset.atomContainers()){
                        ringPlacer.placeRing((IRing)ring, GeometryTools.get2DCenter(container), chemModelRelay.getRenderer().getRenderer2DModel().getBondLength() / chemModelRelay.getRenderer().getRenderer2DModel().getScale());
                    }
                    lastplaced=container.getAtom(counter);
View Full Code Here

TOP

Related Classes of org.openscience.cdk.layout.AtomPlacer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.