code: private static double computeWastedSpace(
          double maxSizeX, double maxSizeY, double aspect)
      {
          int maxAspectX = (int) (maxSizeY * aspect);
          int maxAspectY = (int) (maxSizeX / aspect);
          if (maxAspectX > maxSizeX)
          {
              double sizeX = maxSizeX;
              double sizeY = maxAspectY;
              double waste = maxSizeY - sizeY;
              return waste * sizeX;
          }
          double sizeX = maxAspectX;
          double sizeY = maxSizeY;
          double waste = maxSizeX - sizeX;
          return waste * sizeY;
      }
docs: Compute the wasted space that is implied by the specified layout
  
  @param maxSizeX The maximum size in x-direction
  @param maxSizeY The maximum size in y-direction
  @param aspect The aspect ratio
  @return The wasted space