List of usage examples for org.jfree.chart.servlet ServletUtilities createTempDir
protected static void createTempDir()
From source file:com.portalbook.charting.PortletUtilities.java
/** * Saves the chart as a PNG format file in the temporary directory and * populates the ChartRenderingInfo object which can be used to generate * an HTML image map./* ww w.j av a2 s. c o m*/ * * @param chart the chart to be saved (<code>null</code> not permitted). * @param width the width of the chart. * @param height the height of the chart. * @param info the ChartRenderingInfo object to be populated (<code>null</code> permitted). * @param session the PortletSession of the client. * * @return the filename of the chart saved in the temporary directory. * * @throws IOException if there is a problem saving the file. */ public static String saveChartAsPNG(JFreeChart chart, int width, int height, ChartRenderingInfo info, PortletSession session) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } ServletUtilities.createTempDir(); File tempFile = File.createTempFile(PortletUtilities.getTempFilePrefix(), ".png", new File(System.getProperty("java.io.tmpdir"))); ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info); PortletUtilities.registerChartForDeletion(tempFile, session); return tempFile.getName(); }