code: public MapBounds expand(final int margin, final Rectangle paintArea) {
          final double size;
          if (this.bbox.getHeight() == 0 ||
                  this.bbox.getWidth() / this.bbox.getHeight() > paintArea.getWidth() / paintArea.getHeight()) {
              // it's the width of the feature that is a limiting factor
              size = paintArea.getWidth();
          } else {
              // it's the height of the feature that is a limiting factor
              size = paintArea.getHeight();
          }
          final double factor = size / (size - 2.0 * margin);
  
          final double destWidth = this.bbox.getWidth() * factor;
          final double destHeight = this.bbox.getHeight() * factor;
  
          final double centerX = this.bbox.centre().x;
          final double centerY = this.bbox.centre().y;
  
          final double minGeoX = centerX - destWidth / 2.0;
          final double maxGeoX = centerX + destWidth / 2.0;
          final double minGeoY = centerY - destHeight / 2.0;
          final double maxGeoY = centerY + destHeight / 2.0;
  
          return new BBoxMapBounds(getProjection(),
                                   minGeoX, minGeoY, maxGeoX, maxGeoY);
      }
docs: Expand the bounds by the given margin (in pixel).
  
  @param margin Value in pixel.
  @param paintArea the paint area of the map.