private static String guessHumanReadableRatioString ( double ratio , NumberFormat numberFormat ) { for ( long width = 1 ; width <= 50 ; width ++ ) { double height = width / ratio ; if ( isLong ( height ) ) { return numberFormat . format ( width ) + ":" + numberFormat . format ( height ) ; } } for ( long width = 1 ; width <= 200 ; width ++ ) { double height = width / 2d / ratio ; if ( isHalfLong ( height ) ) { return numberFormat . format ( width / 2d ) + ":" + numberFormat . format ( height ) ; } } return null ; }
Try to guess a nice human readable ratio string from the given decimal ratio