code: @Override
      public Rectangle calculateDiagramBounds(IChemModel model) {
          IAtomContainerSet moleculeSet = model.getMoleculeSet();
          IReactionSet reactionSet = model.getReactionSet();
          if ((moleculeSet == null && reactionSet == null)) {
              return new Rectangle();
          }
  
          Rectangle2D moleculeBounds = null;
          Rectangle2D reactionBounds = null;
          if (moleculeSet != null) {
              moleculeBounds = BoundsCalculator.calculateBounds(moleculeSet);
          }
          if (reactionSet != null) {
              reactionBounds = BoundsCalculator.calculateBounds(reactionSet);
          }
  
          if (moleculeBounds == null) {
              return this.calculateScreenBounds(reactionBounds);
          } else if (reactionBounds == null) {
              return this.calculateScreenBounds(moleculeBounds);
          } else {
              Rectangle2D allbounds = new Rectangle2D.Double();
              Rectangle2D.union(moleculeBounds, reactionBounds, allbounds);
              return this.calculateScreenBounds(allbounds);
          }
      }
docs: Given a chem model, calculates the bounding rectangle in screen space.
  
  @param model the model to draw.
  @return a rectangle in screen space.