code: 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;
      }
docs: Calculate the bounding rectangle for a molecule set.
  
  @param moleculeSet the molecule set to use
  @return the bounding rectangle of the molecule set