@Nonnull
  @CheckReturnValue
  public SizeLong getBestMatchingSize (@Nonnegative final long nMaxWidth, @Nonnegative final long nMaxHeight)
  {
    ValueEnforcer.isGT0 (nMaxWidth, "MaxWidth");
    ValueEnforcer.isGT0 (nMaxHeight, "MaxHeight");

    final double dRelWidth = MathHelper.getDividedDouble (m_nWidth, nMaxWidth);
    final double dRelHeight = MathHelper.getDividedDouble (m_nHeight, nMaxHeight);
    if (dRelWidth > dRelHeight)
    {
      if (m_nWidth > nMaxWidth)
        return new SizeLong (nMaxWidth, (long) (m_nHeight / dRelWidth));
    }
    else
    {
      if (m_nHeight > nMaxHeight)
        return new SizeLong ((long) (m_nWidth / dRelHeight), nMaxHeight);
    }
    return this;
  }
@ Nonnull @ CheckReturnValue public SizeLong getBestMatchingSize ( @ Nonnegative final long nMaxWidth , @ Nonnegative final long nMaxHeight ) { ValueEnforcer . isGT0 ( nMaxWidth , "MaxWidth" ) ; ValueEnforcer . isGT0 ( nMaxHeight , "MaxHeight" ) ; final double dRelWidth = MathHelper . getDividedDouble ( m_nWidth , nMaxWidth ) ; final double dRelHeight = MathHelper . getDividedDouble ( m_nHeight , nMaxHeight ) ; if ( dRelWidth > dRelHeight ) { if ( m_nWidth > nMaxWidth ) return new SizeLong ( nMaxWidth , ( long ) ( m_nHeight / dRelWidth ) ) ; } else { if ( m_nHeight > nMaxHeight ) return new SizeLong ( ( long ) ( m_nWidth / dRelHeight ) , nMaxHeight ) ; } return this ; }
Return the scaled width and height relative to a maximum size.

@param nMaxWidth
Maximum width. Must be &gt; 0.
@param nMaxHeight
Maximum height. Must be &gt; 0.
@return An array with 2 elements, where the first element is the width, and
the second is the height.