public void exportIMG ( String path , String type ) throws IOException { switch ( type ) { case "JPG" : try { ChartUtilities . saveChartAsJPEG ( new File ( path + File . separator + name + ".jpg" ) , chart , width , height ) ; } catch ( IOException e ) { } break ; case "PNG" : try { ChartUtilities . saveChartAsPNG ( new File ( path + File . separator + name + ".png" ) , chart , width , height ) ; } catch ( IOException e ) { } break ; case "SVG" : String svg = generateSVG ( width , height ) ; BufferedWriter writer = null ; try { writer = new BufferedWriter ( new FileWriter ( new File ( path + File . separator + name + ".svg" ) ) ) ; writer . write ( "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" ) ; writer . write ( svg + "\n" ) ; writer . flush ( ) ; } finally { try { if ( writer != null ) { writer . close ( ) ; } } catch ( IOException ex ) { throw new RuntimeException ( ex ) ; } } break ; } }
Export the image to formats JPG PNG SVG and EPS .