public void placeSpiroRing(IRing ring, IAtomContainer sharedAtoms, Point2d sharedAtomsCenter, Vector2d ringCenterVector, double bondLength) {

        IAtom startAtom = sharedAtoms.getAtom(0);
        List<IBond> mBonds = molecule.getConnectedBondsList(sharedAtoms.getAtom(0));
        final int degree = mBonds.size();
        logger.debug("placeSpiroRing: D=", degree);

        // recalculate the ringCentreVector
        if (degree != 4) {

            int numPlaced = 0;
            for (IBond bond : mBonds) {
                IAtom nbr = bond.getOther(sharedAtoms.getAtom(0));
                if (!nbr.getFlag(CDKConstants.ISPLACED))
                    continue;
                numPlaced++;
            }

            if (numPlaced == 2) {
                // nudge the shared atom such that bond lengths will be
                // equal
                startAtom.getPoint2d().add(ringCenterVector);
                sharedAtomsCenter.add(ringCenterVector);
            }

            double theta = Math.PI-(2 * Math.PI / (degree / 2));
            rotate(ringCenterVector, theta);
        }

        double radius = getNativeRingRadius(ring, bondLength);
        Point2d ringCenter = new Point2d(sharedAtomsCenter);
        if (degree == 4) {
            ringCenterVector.normalize();
            ringCenterVector.scale(radius);
        } else {
            // spread things out a little for multiple spiro centres
            ringCenterVector.normalize();
            ringCenterVector.scale(2*radius);
        }
        ringCenter.add(ringCenterVector);
        double addAngle = 2 * Math.PI / ring.getRingSize();

        IAtom currentAtom = startAtom;
        double startAngle = GeometryUtil.getAngle(startAtom.getPoint2d().x - ringCenter.x,
                                                  startAtom.getPoint2d().y - ringCenter.y);

        /*
         * Get one bond connected to the spiro bridge atom. It doesn't matter in
         * which direction we draw.
         */
        List rBonds = ring.getConnectedBondsList(startAtom);

        IBond currentBond = (IBond) rBonds.get(0);

        Vector atomsToDraw = new Vector();
        /*
         * Store all atoms to draw in consequtive order relative to the chosen
         * bond.
         */
        for (int i = 0; i < ring.getBondCount(); i++) {
            currentBond = ring.getNextBond(currentBond, currentAtom);
            currentAtom = currentBond.getOther(currentAtom);
            if (!currentAtom.equals(startAtom))
                atomsToDraw.addElement(currentAtom);
        }
        logger.debug("currentAtom  " + currentAtom);
        logger.debug("startAtom  " + startAtom);

        atomPlacer.populatePolygonCorners(atomsToDraw, ringCenter, startAngle, addAngle, radius);

    }
public void placeSpiroRing ( IRing ring , IAtomContainer sharedAtoms , Point2d sharedAtomsCenter , Vector2d ringCenterVector , double bondLength ) { IAtom startAtom = sharedAtoms . getAtom ( 0 ) ; List < IBond > mBonds = molecule . getConnectedBondsList ( sharedAtoms . getAtom ( 0 ) ) ; final int degree = mBonds . size ( ) ; logger . debug ( "placeSpiroRing: D=" , degree ) ; if ( degree != 4 ) { int numPlaced = 0 ; for ( IBond bond : mBonds ) { IAtom nbr = bond . getOther ( sharedAtoms . getAtom ( 0 ) ) ; if ( ! nbr . getFlag ( CDKConstants . ISPLACED ) ) continue ; numPlaced ++ ; } if ( numPlaced == 2 ) { startAtom . getPoint2d ( ) . add ( ringCenterVector ) ; sharedAtomsCenter . add ( ringCenterVector ) ; } double theta = Math . PI - ( 2 * Math . PI / ( degree / 2 ) ) ; rotate ( ringCenterVector , theta ) ; } double radius = getNativeRingRadius ( ring , bondLength ) ; Point2d ringCenter = new Point2d ( sharedAtomsCenter ) ; if ( degree == 4 ) { ringCenterVector . normalize ( ) ; ringCenterVector . scale ( radius ) ; } else { ringCenterVector . normalize ( ) ; ringCenterVector . scale ( 2 * radius ) ; } ringCenter . add ( ringCenterVector ) ; double addAngle = 2 * Math . PI / ring . getRingSize ( ) ; IAtom currentAtom = startAtom ; double startAngle = GeometryUtil . getAngle ( startAtom . getPoint2d ( ) . x - ringCenter . x , startAtom . getPoint2d ( ) . y - ringCenter . y ) ; List rBonds = ring . getConnectedBondsList ( startAtom ) ; IBond currentBond = ( IBond ) rBonds . get ( 0 ) ; Vector atomsToDraw = new Vector ( ) ; for ( int i = 0 ; i < ring . getBondCount ( ) ; i ++ ) { currentBond = ring . getNextBond ( currentBond , currentAtom ) ; currentAtom = currentBond . getOther ( currentAtom ) ; if ( ! currentAtom . equals ( startAtom ) ) atomsToDraw . addElement ( currentAtom ) ; } logger . debug ( "currentAtom  " + currentAtom ) ; logger . debug ( "startAtom  " + startAtom ) ; atomPlacer . populatePolygonCorners ( atomsToDraw , ringCenter , startAngle , addAngle , radius ) ; }
Generated coordinates for a given ring, which is connected to a spiro ring.
The rings share exactly one atom.

@param   ring  The ring to be placed
@param   sharedAtoms  The atoms of this ring, also members of another ring, which are already placed
@param   sharedAtomsCenter  The geometric center of these atoms
@param   ringCenterVector  A vector pointing the the center of the new ring
@param   bondLength  The standard bondlength