code: public static Rectangle2D calculateBounds(IReaction reaction) {
          // get the participants in the reaction
          IAtomContainerSet reactants = reaction.getReactants();
          IAtomContainerSet products = reaction.getProducts();
          if (reactants == null || products == null) return null;
  
          // determine the bounds of everything in the reaction
          Rectangle2D reactantsBounds = calculateBounds(reactants);
          return reactantsBounds.createUnion(calculateBounds(products));
      }
docs: Calculate the bounding rectangle for a reaction.
  
  @param reaction the reaction to use
  @return the bounding rectangle of the reaction