public static String renderHTML ( Graph graph , String mapName , String imgUrl , String targets [ ] , String titles [ ] ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<map name=\"" ) . append ( mapName ) . append ( "\">" ) ; RegionGraphElement rge [ ] = graph . getRegions ( ) ; int count = rge . length ; for ( int i = 0 ; i < count ; i ++ ) { if ( targets [ i ] != null ) { Rectangle r = rge [ i ] . getBoundingRectangle ( ) ; sb . append ( "<area href=\"" ) . append ( targets [ i ] ) . append ( "\"" ) ; if ( titles [ i ] != null ) { sb . append ( " title=\"" ) . append ( titles [ i ] ) . append ( "\"" ) ; } sb . append ( " shape=\"rect\" coords=\"" ) ; sb . append ( r . x ) . append ( "," ) ; sb . append ( r . y ) . append ( "," ) ; sb . append ( r . x + r . width ) . append ( "," ) ; sb . append ( r . y + r . height ) . append ( "\" border=\"1\" />" ) ; } } sb . append ( "</map>" ) ; sb . append ( "<image src=\"" ) . append ( imgUrl ) . append ( "\"" ) ; sb . append ( " border=\"0\" width=\"" ) . append ( graph . width ) . append ( "\"" ) ; sb . append ( " height=\"" ) . append ( graph . height ) . append ( "\"" ) ; sb . append ( " usemap=\"#" ) . append ( mapName ) . append ( "\" />" ) ; return sb . toString ( ) ; }
Create both an HTML AREA map and an HTML IMG for a graph using provided href targets and titles within the AREA map .