docs: private void calculateOptimalWidthAndHeight() {
          if (state == State.DEFAULT || getWidth() == 0) {
              return;
          }
  
          float maxWidth = getWidth(), maxHeight = getHeight();
          float w = pageWidth, h = pageHeight;
          float ratio = w / h;
          w = maxWidth;
          h = (float) Math.floor(maxWidth / ratio);
          if (h > maxHeight) {
              h = maxHeight;
              w = (float) Math.floor(maxHeight * ratio);
          }
  
          optimalPageWidth = w;
          optimalPageHeight = h;
  
          calculateMasksBounds();
          calculateMinimapBounds();
      }