protected void orderNodeGrid ( SquareGrid grid , int row , int col ) { SquareNode node = grid . get ( row , col ) ; if ( grid . rows == 1 && grid . columns == 1 ) { for ( int i = 0 ; i < 4 ; i ++ ) { ordered [ i ] = node . square . get ( i ) ; } } else if ( grid . columns == 1 ) { if ( row == grid . rows - 1 ) { orderNode ( node , grid . get ( row - 1 , col ) , false ) ; rotateTwiceOrdered ( ) ; } else { orderNode ( node , grid . get ( row + 1 , col ) , false ) ; } } else { if ( col == grid . columns - 1 ) { orderNode ( node , grid . get ( row , col - 1 ) , true ) ; rotateTwiceOrdered ( ) ; } else { orderNode ( node , grid . get ( row , col + 1 ) , true ) ; } } }
Given the grid coordinate order the corners for the node at that location . Takes in handles situations where there are no neighbors .