void rotateGridCCW ( Grid g ) { work . clear ( ) ; for ( int i = 0 ; i < g . rows * g . columns ; i ++ ) { work . add ( null ) ; } for ( int row = 0 ; row < g . rows ; row ++ ) { for ( int col = 0 ; col < g . columns ; col ++ ) { work . set ( col * g . rows + row , g . get ( g . rows - row - 1 , col ) ) ; } } g . ellipses . clear ( ) ; g . ellipses . addAll ( work ) ; int tmp = g . columns ; g . columns = g . rows ; g . rows = tmp ; }
performs a counter - clockwise rotation