private static Surface getSheetSize ( Collection < ImageBuffer > tiles , int horizontalTiles ) { final int tilesNumber = tiles . size ( ) ; final int horizontals ; final int verticals ; if ( horizontalTiles > 0 ) { horizontals = horizontalTiles ; verticals = ( int ) Math . ceil ( tilesNumber / ( double ) horizontalTiles ) ; } else { horizontals = ( int ) Math . ceil ( Math . sqrt ( tilesNumber ) ) ; verticals = horizontals ; } return new Surface ( ) { @ Override public int getWidth ( ) { return Math . max ( 1 , horizontals ) ; } @ Override public int getHeight ( ) { return Math . max ( 1 , verticals ) ; } } ; }
Get the sheet size depending of the number of horizontal tiles and total number of tiles .