question: 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 ; }
target:  Calculate the optimal width and height of a page considering the area width and height