public static void writeGraph ( File outputFile , Component selectedComponent , Layout < AbstractType , String > layout , Graph < AbstractType , String > graph , AbstractEdgeShapeTransformer < AbstractType , String > edgeShapeTransformer , Map < String , String > options ) throws IOException { VisualizationImageServer < AbstractType , String > vis = new VisualizationImageServer < AbstractType , String > ( layout , layout . getSize ( ) ) ; vis . setBackground ( Color . WHITE ) ; vis . getRenderContext ( ) . setEdgeLabelTransformer ( new NoStringLabeller ( ) ) ; vis . getRenderContext ( ) . setEdgeShapeTransformer ( edgeShapeTransformer ) ; vis . getRenderContext ( ) . setVertexLabelTransformer ( new ToStringLabeller < AbstractType > ( ) ) ; vis . getRenderContext ( ) . setVertexShapeTransformer ( new VertexShape ( ) ) ; vis . getRenderContext ( ) . setVertexFontTransformer ( new VertexFont ( ) ) ; Color defaultBgColor = decode ( options . get ( DocConstants . OPTION_IMG_BACKGROUND_COLOR ) , DocConstants . DEFAULT_BACKGROUND_COLOR ) ; Color highlightBgcolor = decode ( options . get ( DocConstants . OPTION_IMG_HIGHLIGHT_BG_COLOR ) , DocConstants . DEFAULT_HIGHLIGHT_BG_COLOR ) ; vis . getRenderContext ( ) . setVertexFillPaintTransformer ( new VertexColor ( selectedComponent , defaultBgColor , highlightBgcolor ) ) ; Color defaultFgColor = decode ( options . get ( DocConstants . OPTION_IMG_FOREGROUND_COLOR ) , DocConstants . DEFAULT_FOREGROUND_COLOR ) ; vis . getRenderContext ( ) . setVertexLabelRenderer ( new MyVertexLabelRenderer ( selectedComponent , defaultFgColor ) ) ; vis . getRenderer ( ) . getVertexLabelRenderer ( ) . setPosition ( Position . CNTR ) ; BufferedImage image = ( BufferedImage ) vis . getImage ( new Point2D . Double ( layout . getSize ( ) . getWidth ( ) / 2 , layout . getSize ( ) . getHeight ( ) / 2 ) , new Dimension ( layout . getSize ( ) ) ) ; ImageIO . write ( image , "png" , outputFile ) ; }
Writes a graph as a PNG image .