code: public Rectangle calculateScreenBounds(Rectangle2D modelBounds) {
          double scale = rendererModel.getParameter(Scale.class).getValue();
          double zoom = rendererModel.getParameter(ZoomFactor.class).getValue();
          double margin = rendererModel.getParameter(Margin.class).getValue();
          Point2d modelScreenCenter = this.toScreenCoordinates(modelBounds.getCenterX(), modelBounds.getCenterY());
          double width = (scale * zoom * modelBounds.getWidth()) + (2 * margin);
          double height = (scale * zoom * modelBounds.getHeight()) + (2 * margin);
          return new Rectangle((int) (modelScreenCenter.x - width / 2), (int) (modelScreenCenter.y - height / 2),
                  (int) width, (int) height);
      }
docs: Converts a bounding rectangle in 'model space' into the equivalent
  bounds in 'screen space'. Used to determine how much space the model
  will take up on screen given a particular scale, zoom, and margin.
  
  @param modelBounds the bounds of the model
  @return the bounds of the diagram as drawn on screen