code: public static Rectangle2D calculateBounds(IReactionSet reactionSet) {
          Rectangle2D totalBounds = new Rectangle2D.Double();
          for (IReaction reaction : reactionSet.reactions()) {
              Rectangle2D reactionBounds = calculateBounds(reaction);
              if (totalBounds.isEmpty()) {
                  totalBounds = reactionBounds;
              } else {
                  Rectangle2D.union(totalBounds, reactionBounds, totalBounds);
              }
          }
          return totalBounds;
      }
docs: Calculate the bounding rectangle for a reaction set.
  
  @param reactionSet the reaction set to use
  @return the bounding rectangle of the reaction set