AtomPlacer atomPlacer = new AtomPlacer(); atomPlacer.setMolecule(chemModel.getBuilder().newInstance(IAtomContainer.class,atomCon)); double bondLength; if (atomCon.getBondCount() >= 1) { Vector2d v = atomPlacer.getNextBondVector(atom, connectedAtom, distanceMeasure, true); atomPlacer.setMolecule(ac); atomPlacer.placeLinearChain(ac, v, bondLength); } else { IAtomContainer placedAtoms = atomCon.getBuilder().newInstance(IAtomContainer.class); unplacedAtoms.addAtom(newAtom); atomPlacer.distributePartners(atom, placedAtoms, center2D, unplacedAtoms, bondLength);
IAtomContainer longestChain = AtomPlacer.getInitialLongestChain(molecule); logger.debug("Found linear chain of length " + longestChain.getAtomCount()); logger.debug("Setting coordinated of first atom to 0,0"); atomPlacer.placeLinearChain(longestChain, firstBondVector, bondLength); else atomPlacer.placeLinearChain(longestChain, new Vector2d(Math.cos(RAD_30), Math.sin(RAD_30)), bondLength); logger.debug("Placed longest aliphatic chain");
placedAtoms = getPlacedAtoms(atom); longestUnplacedChain = atomPlacer.getLongestUnplacedChain(molecule, atom); logger.debug(AtomPlacer.listNumbers(molecule, longestUnplacedChain)); } catch (Exception exc) { logger.debug(exc); logger.debug("More than one atoms placed already"); logger.debug("trying to place neighbors of atom " + (molecule.indexOf(atom) + 1)); atomPlacer.distributePartners(atom, placedAtoms, GeometryUtil.get2DCenter(placedAtoms), unplacedAtoms, bondLength); direction = new Vector2d(longestUnplacedChain.getAtom(1).getPoint2d()); 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), GeometryUtil.get2DCenter(molecule), true); longestUnplacedChain.getAtom(f).setFlag(CDKConstants.ISPLACED, false); atomPlacer.placeLinearChain(longestUnplacedChain, direction, bondLength);
@Test public void emptyAtomsListTest() { List<IAtom> atoms = new ArrayList<IAtom>(); // switch on debugging, to see if NPE is thrown AtomPlacer placer = new AtomPlacer(); boolean npeThrown = false; try { placer.populatePolygonCorners(atoms, new Point2d(0, 0), 0, 10, 10); } catch (NullPointerException npe) { npeThrown = true; } Assert.assertFalse("Null pointer for empty atoms list", npeThrown); }
logger.debug("bond length", bondLength); AtomPlacer atomPlacer = new AtomPlacer(); atomPlacer.setMolecule(container); atomPlacer.distributePartners(atom, placed, centerPlacedAtoms, unplaced, bondLength);
@Test public void cumulated_x2() { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(atom("C", 3)); m.addAtom(atom("C", 1)); m.addAtom(atom("C", 0)); m.addAtom(atom("C", 1)); m.addAtom(atom("C", 3)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); m.getAtom(0).setPoint2d(new Point2d(0, 0)); m.getAtom(0).setFlag(CDKConstants.ISPLACED, true); AtomPlacer atomPlacer = new AtomPlacer(); atomPlacer.setMolecule(m); atomPlacer.placeLinearChain(m, new Vector2d(0, 1.5), 1.5); Point2d p1 = m.getAtom(1).getPoint2d(); Point2d p2 = m.getAtom(2).getPoint2d(); Point2d p3 = m.getAtom(3).getPoint2d(); Vector2d p2p1 = new Vector2d(p1.x - p2.x, p1.y - p2.y); Vector2d p2p3 = new Vector2d(p3.x - p2.x, p3.y - p2.y); p2p1.normalize(); p2p3.normalize(); double theta = Math.acos(p2p1.x * p2p3.x + p2p1.y * p2p3.y); assertThat(theta, closeTo(Math.PI, 0.05)); }
AtomPlacer atomPlacer = new AtomPlacer(); AtomPlacer3D ap3d = new AtomPlacer3D(); AtomTetrahedralLigandPlacer3D atlp3d = new AtomTetrahedralLigandPlacer3D(); atomPlacer.setMolecule(molecule); ac = atomPlacer.getInitialLongestChain(molecule); setAtomsToUnVisited(molecule); setAtomsToUnPlaced(molecule);
ac.removeAtom(ac.getAtom(0)); AtomPlacer ap=new AtomPlacer(); while(lastplaced!=null){ IAtomContainer placedNeighbours=ac.getBuilder().newInstance(IAtomContainer.class); unplacedNeighbours.addAtom((IAtom)l.get(i)); ap.distributePartners(lastplaced, placedNeighbours, GeometryTools.get2DCenter(placedNeighbours), unplacedNeighbours, 1.4); IRingSet ringset = Cycles.sssr(container).toRingSet(); for(IAtomContainer ring:ringset.atomContainers()){
atomPlacer.setMolecule(this.molecule); ringPlacer.setMolecule(this.molecule); macroPlacer = new MacroCycleLayout(this.molecule); for (; !AtomPlacer.allPlaced(molecule) && iter < numAtoms; iter++) { logger.debug("*** Start of handling the rest of the molecule. ***"); if (iter == numAtoms && !AtomPlacer.allPlaced(molecule)) throw new CDKException("Could not generate layout? If a set of 'fixed' atoms were provided" + " try removing these and regenerating the layout.");
populatePolygonCorners(atomsToDraw, new Point2d(atom.getPoint2d()), startAngle, addAngle, bondLength); return; } else if (placedNeighbours.getAtomCount() == 0) { populatePolygonCorners(atomsToDraw, new Point2d(atom.getPoint2d()), startAngle, addAngle, bondLength); return; if (doAngleSnap(atom, placedNeighbours)) { final Vector2d a = newVector(placedNeighbours.getAtom(0).getPoint2d(), atom.getPoint2d()); final Vector2d b = newVector(placedNeighbours.getAtom(1).getPoint2d(), atom.getPoint2d()); final double d1 = GeometryUtil.getAngle(a.x, a.y); final double d2 = GeometryUtil.getAngle(b.x, b.y); populatePolygonCorners(FluentIterable.from(unplacedNeighbours.atoms()).toList(), atom.getPoint2d(), startAngle, sweep, bondLength); markPlaced(unplacedNeighbours); return; } else { populatePolygonCorners(atomsToDraw, new Point2d(atom.getPoint2d()), startAngle, addAngle, radius);
logger.debug("placeBridgedRing->atomsToPlace: " + AtomPlacer.listNumbers(molecule, atoms)); logger.debug("placeBridgedRing->startAngle: " + Math.toDegrees(startAngle)); logger.debug("placeBridgedRing->tStep: " + Math.toDegrees(tStep)); atomPlacer.populatePolygonCorners(atoms, ringCenter, startAngle, -tStep, radius);
rings = rs.getRings(atom); centerOfRingGravity = GeometryUtil.get2DCenter(rings); atomPlacer.partitionPartners(atom, unplacedPartners, sharedAtoms); atomPlacer.markNotPlaced(unplacedPartners); try { for (int f = 0; f < unplacedPartners.getAtomCount(); f++) { atomPlacer.distributePartners(atom, sharedAtoms, centerOfRingGravity, unplacedPartners, bondLength);
atomPlacer.setMolecule(this.molecule); ringPlacer.setMolecule(this.molecule); ringPlacer.setAtomPlacer(this.atomPlacer);
boolean trans = false; if (prevBond != null && isColinear(atom, molecule.getConnectedBondsList(atom))) { logger.debug("Excpetion in detecting E/Z. This could mean that cleanup does not respect E/Z"); bondVector = getNextBondVector(nextAtom, atom, GeometryUtil.get2DCenter(molecule), trans); } else { bondVector = getNextBondVector(nextAtom, atom, GeometryUtil.get2DCenter(molecule), true);
atomsToDraw.addElement(currentAtom); atomPlacer.populatePolygonCorners(atomsToDraw, ringCenter, startAngle, addAngle, radius);
path = getLongestUnplacedChain(molecule, startAtom);
m.getAtom(0).setFlag(CDKConstants.ISPLACED, true); AtomPlacer atomPlacer = new AtomPlacer(); atomPlacer.setMolecule(m); atomPlacer.placeLinearChain(m, new Vector2d(0, 1.5), 1.5);
logger.debug("bond length", bondLength); AtomPlacer atomPlacer = new AtomPlacer(); atomPlacer.setMolecule(container); atomPlacer.distributePartners(atom, placed, centerPlacedAtoms, unplaced, bondLength);
@Test public void triangleTest() { List<IAtom> atoms = new ArrayList<IAtom>(); atoms.add(new Atom("C")); atoms.add(new Atom("C")); atoms.add(new Atom("C")); AtomPlacer placer = new AtomPlacer(); placer.populatePolygonCorners(atoms, new Point2d(0, 0), 0, 10, 10); for (IAtom atom : atoms) { Assert.assertNotNull(atom.getPoint2d()); } }
atomPlacer.setMolecule(this.molecule); ringPlacer.setMolecule(this.molecule); macroPlacer = new MacroCycleLayout(this.molecule); for (; !AtomPlacer.allPlaced(molecule) && iter < numAtoms; iter++) { logger.debug("*** Start of handling the rest of the molecule. ***"); if (iter == numAtoms && !AtomPlacer.allPlaced(molecule)) throw new CDKException("Could not generate layout? If a set of 'fixed' atoms were provided" + " try removing these and regenerating the layout.");