/** * Place ring with user provided angles. * * @param ring the ring to place. * @param ringCenter center coordinates of the ring. * @param bondLength given bond length. * @param startAngles a map with start angles when drawing the ring. */ 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.getFirstAtom(); 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.getConnectedAtom(currentAtom); atomsToDraw.addElement(currentAtom); } atomPlacer.populatePolygonCorners(atomsToDraw, ringCenter, startAngle, addAngle, radius); }