/** * Layout a macro cycle (the rest of the ring set is untouched). * * @param macrocycle the macrocycle * @param ringset the ring set the macrocycle belongs to (may only be it's self) * @return layout was successfully, if false caller fall-back to regular polygons */ boolean layout(IRing macrocycle, IRingSet ringset) { final IAtomContainer anon = roundUpIfNeeded(AtomContainerManipulator.anonymise(macrocycle)); final Collection<Point2d[]> coords = TEMPLATES.getCoordinates(anon); if (coords.isEmpty()) return false; Point2d[] best = new Point2d[anon.getAtomCount()]; int bestOffset = selectCoords(coords, best, macrocycle, ringset); for (int i = 0; i < macrocycle.getAtomCount(); i++) { macrocycle.getAtom(i).setPoint2d(best[(bestOffset + i) % macrocycle.getAtomCount()]); macrocycle.getAtom(i).setFlag(ISPLACED, true); macrocycle.getAtom(i).setProperty(MACROCYCLE_ATOM_HINT, true); } macrocycle.setFlag(ISPLACED, true); return true; }
/** * Layout a macro cycle (the rest of the ring set is untouched). * * @param macrocycle the macrocycle * @param ringset the ring set the macrocycle belongs to (may only be it's self) * @return layout was successfully, if false caller fall-back to regular polygons */ boolean layout(IRing macrocycle, IRingSet ringset) { final IAtomContainer anon = roundUpIfNeeded(AtomContainerManipulator.anonymise(macrocycle)); final Collection<Point2d[]> coords = TEMPLATES.getCoordinates(anon); if (coords.isEmpty()) return false; Point2d[] best = new Point2d[anon.getAtomCount()]; int bestOffset = selectCoords(coords, best, macrocycle, ringset); for (int i = 0; i < macrocycle.getAtomCount(); i++) { macrocycle.getAtom(i).setPoint2d(best[(bestOffset + i) % macrocycle.getAtomCount()]); macrocycle.getAtom(i).setFlag(ISPLACED, true); macrocycle.getAtom(i).setProperty(MACROCYCLE_ATOM_HINT, true); } macrocycle.setFlag(ISPLACED, true); return true; }