public String toHtml ( Archipelago arch ) { int mat [ ] = new int [ rowNum ( ) ] ; for ( Island isl : arch . getIslands ( ) ) { for ( Coordinate c : isl ) { mat [ c . row ] = c . column ; } } StringBuilder result = new StringBuilder ( "<table>\n<tr><td></td>\n" ) ; ArrayList < String > colLabels = columnLabels ( ) ; for ( String cLabel : colLabels ) { result . append ( "<td>" ) . append ( cLabel ) . append ( "</td>" ) ; } result . append ( "</tr>\n" ) ; ArrayList < String > rLabels = rowLabels ( ) ; int row = 0 ; for ( String label : rLabels ) { result . append ( "<tr><td>" ) . append ( label ) . append ( "</td>" ) ; if ( mat [ row ] > 0 ) { result . append ( "<td colspan=\"" ) . append ( mat [ row ] ) . append ( "\"></td>" ) . append ( "<td BGCOLOR=\"lightgreen\">M</td>" ) ; } result . append ( "</tr>\n" ) ; row ++ ; } result . append ( "</table>" ) ; return result . toString ( ) ; }
arch = preferred matches