public void placeRing ( IRing ring , Point2d ringCenter , double bondLength , Map < Integer , Double > startAngles ) { double radius = this . getNativeRingRadius ( ring , bondLength ) ; double addAngle = 2 * Math . PI / ring . getRingSize ( ) ; IAtom startAtom = ring . getAtom ( 0 ) ; Point2d p = new Point2d ( ringCenter . x + radius , ringCenter . y ) ; startAtom . setPoint2d ( p ) ; double startAngle = Math . PI * 0.5 ; /* * Different ring sizes get different start angles to have visually * correct placement */ int ringSize = ring . getRingSize ( ) ; if ( startAngles . get ( ringSize ) != null ) startAngle = startAngles . get ( ringSize ) ; List < IBond > bonds = ring . getConnectedBondsList ( startAtom ) ; /* * Store all atoms to draw in consecutive order relative to the chosen * bond. */ Vector < IAtom > atomsToDraw = new Vector < IAtom > ( ) ; IAtom currentAtom = startAtom ; IBond currentBond = ( IBond ) bonds . get ( 0 ) ; for ( int i = 0 ; i < ring . getBondCount ( ) ; i ++ ) { currentBond = ring . getNextBond ( currentBond , currentAtom ) ; currentAtom = currentBond . getOther ( currentAtom ) ; atomsToDraw . addElement ( currentAtom ) ; } atomPlacer . populatePolygonCorners ( atomsToDraw , ringCenter , startAngle , addAngle , radius ) ; }
Place ring with user provided angles .