Calculate the bounding rectangle for a molecule set.

@param moleculeSet the molecule set to use
@return the bounding rectangle of the molecule set
491175
public static Rectangle2D calculateBounds(IAtomContainerSet moleculeSet) {
        Rectangle2D totalBounds = new Rectangle2D.Double();
        for (int i = 0; i < moleculeSet.getAtomContainerCount(); i++) {
            IAtomContainer container = moleculeSet.getAtomContainer(i);
            Rectangle2D acBounds = calculateBounds(container);
            if (totalBounds.isEmpty()) {
                totalBounds = acBounds;
            } else {
                Rectangle2D.union(totalBounds, acBounds, totalBounds);
            }
        }
        return totalBounds;
    }
1085255
public BitSet projectG2(BitSet set) {
        BitSet projection = new BitSet(secondGraphSize);
        RNode xNode = null;

        for (int x = set.nextSetBit(0); x >= 0; x = set.nextSetBit(x + 1)) {
            xNode = (RNode) graph.get(x);
            projection.set(xNode.rMap.id2);
        }
        return projection;
    }
455606
private List<Integer> getAtomNosForRingGroup(IAtomContainer molecule, List<Integer> ringGroup, IRingSet ringSet) {
        List<Integer> atc = new ArrayList<Integer>();
        for (Integer i : ringGroup) {
            for (IAtom atom : ringSet.getAtomContainer(i).atoms()) {
                if (atc.size() > 0) {
                    if (!atc.contains(molecule.indexOf(atom))) {
                        atc.add(molecule.indexOf(atom));
                    }
                } else {
                    atc.add(molecule.indexOf(atom));
                }
            }
        }
        return atc;
    }
737546
private List<Integer[]> getAtomNoPairsForRingGroup(IAtomContainer molecule, List<Integer> bondsToCheck) {
        List<Integer[]> aptc = new ArrayList<Integer[]>();
        for (Integer i : bondsToCheck) {
            Integer[] aps = new Integer[2];
            aps[0] = molecule.indexOf(molecule.getBond(i).getBegin());
            aps[1] = molecule.indexOf(molecule.getBond(i).getEnd());
            aptc.add(aps);
        }
        return aptc;
    }
288926
private static String calculateMolecularFormula(List<AbstractMolecule> molecules) throws BuilderMoleculeException, CTKException, ChemistryException {
    Map<String, Integer> atomNumberMap = new TreeMap<String, Integer>();
    for (AbstractMolecule molecule : molecules) {
      LOG.info(molecule.getMolecule().toString());
      atomNumberMap = generateAtomNumberMap(molecule, atomNumberMap);
    }
    LOG.info("GET map");
    StringBuilder sb = new StringBuilder();
    Set<String> atoms = atomNumberMap.keySet();
    for (Iterator<String> i = atoms.iterator(); i.hasNext();) {
      String atom = i.next();
      String num = atomNumberMap.get(atom).toString();
      if (num.equals("1")) {
        num = "";
      }
      sb.append(atom);
      sb.append(num.toString());
    }
    return sb.toString();
  }
591637
public static BitSet getBitSet(IAtomContainer atomContainer) {
        BitSet bitSet;
        int size = atomContainer.getBondCount();

        if (size != 0) {
            bitSet = new BitSet(size);
            for (int i = 0; i < size; i++) {
                bitSet.set(i);
            }
        } else {
            bitSet = new BitSet();
        }

        return bitSet;
    }
1329421
@Override
    public void calcInnerBounds() {
        final Insets INSETS = getInsets();
        final int SIZE = (getWidth() - INSETS.left - INSETS.right) <= (getHeight() - INSETS.top - INSETS.bottom) ? (getWidth() - INSETS.left - INSETS.right) : (getHeight() - INSETS.top - INSETS.bottom);
        if (!isFrameVisible()) {
            INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, (int)(SIZE * 1.202247191), (int)(SIZE * 1.202247191));
        } else {
            INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, SIZE, SIZE);
        }
    }
270212
public static final Atom getCenterVector(Atom[] atomSet){
		Atom centroid = getCentroid(atomSet);

		return getCenterVector(atomSet,centroid);

	}
653556
public static IReactionScheme createReactionScheme(IReactionSet reactionSet) {
        IReactionScheme reactionScheme = reactionSet.getBuilder().newInstance(IReactionScheme.class);

        // Looking for those reactants which doesn't have any precursor. They are the top.
        ArrayList<IReaction> listTopR = new ArrayList<IReaction>();
        for (IReaction reaction : reactionSet.reactions()) {
            if (extractPrecursorReaction(reaction, reactionSet).getReactionCount() == 0) listTopR.add(reaction);
        }

        for (IReaction reaction : listTopR) {
            reactionScheme.addReaction(reaction);
            IReactionScheme newReactionScheme = setScheme(reaction, reactionSet);
            if (newReactionScheme.getReactionCount() != 0 || newReactionScheme.getReactionSchemeCount() != 0)
                reactionScheme.add(newReactionScheme);
        }
        return reactionScheme;
    }
702984
public static IAtomContainerSet getAllProducts(IReaction reaction) {
        IAtomContainerSet moleculeSet = reaction.getBuilder().newInstance(IAtomContainerSet.class);
        IAtomContainerSet products = reaction.getProducts();
        for (int i = 0; i < products.getAtomContainerCount(); i++) {
            moleculeSet.addAtomContainer(products.getAtomContainer(i));
        }
        return moleculeSet;
    }
718773
@Override
    public void setup(IAtomContainerSet moleculeSet, Rectangle screen) {
        this.setScale(moleculeSet);
        Rectangle2D bounds = BoundsCalculator.calculateBounds(moleculeSet);
        if (bounds != null) this.modelCenter = new Point2d(bounds.getCenterX(), bounds.getCenterY());
        this.drawCenter = new Point2d(screen.getCenterX(), screen.getCenterY());
        this.setup();
    }
1220648
private Rectangle2D getBounds(ServletRequest pReq, BufferedImage pImage,
                                  double pAng) {
        // Get dimensions of original image
        int width = pImage.getWidth(); // loads the image
        int height = pImage.getHeight();

        // Test if we want to crop image (default)
        // if true
        //  - find the largest bounding box INSIDE the rotated image,
        //    that matches the original proportions (nearest 90deg)
        //    (scale up to fit dimensions?)
        // else
        //  - find the smallest bounding box OUTSIDE the rotated image.
        //    - that matches the original proportions (nearest 90deg) ?
        //      (scale down to fit dimensions?)
        AffineTransform at =
                AffineTransform.getRotateInstance(pAng, width / 2.0, height / 2.0);

        Rectangle2D orig = new Rectangle(width, height);
        Shape rotated = at.createTransformedShape(orig);

        if (ServletUtil.getBooleanParameter(pReq, PARAM_CROP, false)) {
            // TODO: Inside box
            return rotated.getBounds2D();
        }
        else {
            return rotated.getBounds2D();
        }
    }
196896
public BitSet projectG2(BitSet set) {
        BitSet projection = new BitSet(getSecondGraphSize());
        CDKRNode xNode = null;

        for (int x = set.nextSetBit(0); x >= 0; x = set.nextSetBit(x + 1)) {
            xNode = getGraph().get(x);
            projection.set(xNode.getRMap().getId2());
        }
        return projection;
    }
1346988
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {
        if (!GeometryUtil.has3DCoordinates(atomContainer))
            return getDummyDescriptorValue(new CDKException("Molecule must have 3D coordinates"));

        double angle = 10.0;
        double maxLOB = 0;
        double minArea = 1e6;
        double mmLOB = 0;

        double lob, bol, area;
        double[] xyzRanges;

        double[][] coords = new double[atomContainer.getAtomCount()][3];
        for (int i = 0; i < atomContainer.getAtomCount(); i++) {
            coords[i][0] = atomContainer.getAtom(i).getPoint3d().x;
            coords[i][1] = atomContainer.getAtom(i).getPoint3d().y;
            coords[i][2] = atomContainer.getAtom(i).getPoint3d().z;
        }

        // get the com
        Point3d com = GeometryUtil.get3DCentreOfMass(atomContainer);
        if (com == null) 
            return getDummyDescriptorValue(new CDKException("Error in center of mass calculation, has exact mass been set on all atoms?"));

        // translate everything to COM
        for (int i = 0; i < coords.length; i++) {
            coords[i][0] -= com.x;
            coords[i][1] -= com.y;
            coords[i][2] -= com.z;
        }

        int nangle = (int) (90 / angle);
        for (int i = 0; i < nangle; i++) {
            rotateZ(coords, Math.PI / 180.0 * angle);
            try {
                xyzRanges = extents(atomContainer, coords, true);
            } catch (CDKException e) {
                return getDummyDescriptorValue(e);
            }
            lob = xyzRanges[0] / xyzRanges[1];
            bol = 1.0 / lob;
            if (lob < bol) {
                double tmp = lob;
                lob = bol;
                bol = tmp;
            }
            area = xyzRanges[0] * xyzRanges[1];
            if (lob > maxLOB) maxLOB = lob;
            if (area < minArea) {
                minArea = area;
                mmLOB = lob;
            }
        }

        DoubleArrayResult result = new DoubleArrayResult(2);
        result.add(maxLOB);
        result.add(mmLOB);

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result,
                getDescriptorNames());
    }
1245836
public IAtomContainer getPlacedHeavyAtoms(IAtomContainer molecule, IAtom atom) {

        List<IBond> bonds = molecule.getConnectedBondsList(atom);
        IAtomContainer connectedAtoms = molecule.getBuilder().newInstance(IAtomContainer.class);
        IAtom connectedAtom = null;
        for (IBond bond : bonds) {
            connectedAtom = bond.getOther(atom);
            if (isPlacedHeavyAtom(connectedAtom)) {
                connectedAtoms.addAtom(connectedAtom);
            }
        }
        return connectedAtoms;
    }
50301
public static double calculateAverageBondLength(IAtomContainerSet moleculeSet) {
        double averageBondModelLength = 0.0;
        for (IAtomContainer atomContainer : moleculeSet.atomContainers()) {
            averageBondModelLength += GeometryUtil.getBondLengthAverage(atomContainer);
        }
        return averageBondModelLength / moleculeSet.getAtomContainerCount();
    }
1000737
public int getSrcSetMaxWidth() {

        int result = 0;
        if ((m_srcSet != null) && (m_srcSet.size() > 0)) {

            result = m_srcSet.lastKey().intValue();
        }
        return result;
    }