/** * Saves a chart to a file in JPEG format. * * @param file the file (<code>null</code> not permitted). * @param quality the JPEG quality setting. * @param chart the chart (<code>null</code> not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsJPEG(file, quality, chart, width, height, null); }
/** * Saves a chart to a file in JPEG format. * * @param file the file (<code>null</code> not permitted). * @param chart the chart (<code>null</code> not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsJPEG(file, chart, width, height, null); }
public void saveToJPG(File jpgFileName, int width, int height) { try { ChartUtilities.saveChartAsJPEG(jpgFileName, graph, width, height); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
public static String draw(List<XYScatter> list,int picId,String title,String xLabel,String yLabel){ XYDataset xyDataset= ScatterPlotChart.createXYDataSet(list,""); String path=LineChart.class.getClassLoader().getResource("").getPath(); String filePath=path+"/images/"+picId+"/"+fileName; File scatterChartFile = new File(filePath); if(!scatterChartFile.getParentFile().exists()){ scatterChartFile.getParentFile().mkdirs(); } try { JFreeChart jFreeChart = createChart(xyDataset,list,title,xLabel,yLabel); ChartUtilities.saveChartAsJPEG(scatterChartFile ,jFreeChart, width ,height); } catch (IOException ex) { log.error("散点图生成异常:{}", ExceptionUtils.getFullStackTrace(ex)); return ""; } return scatterChartFile.getAbsolutePath(); }
private void saveChart(JFreeChart chart, String fileName, int width, int height) { try { // Converts chart in JPEG file named [name].jpg File file = new File(_params.outputPath()); if (!file.exists()) { file.mkdirs(); } ChartUtilities.saveChartAsJPEG( new File(_params.outputPath() + FILE_SEP + fileName), chart, width, height); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
/** * @description 画出折线图 * @return 图片地址 */ private String drawLineChar(String title, String xLabel, String yLabel, DefaultCategoryDataset dataSet, int picId) throws IOException { JFreeChart lineChartObject= ChartFactory.createLineChart( title, xLabel, // 横轴 yLabel, // 纵轴 dataSet, // 获得数据集 PlotOrientation.VERTICAL,// 图标方向垂直 true, // 显示图例 false, // 不用生成工具 false // 不用生成URL地址 ); String path=this.getClass().getClassLoader().getResource("").getPath(); String filePath=path+"/images/"+picId+"/"+getFileName(); File lineChart = new File(filePath); if(!lineChart.getParentFile().exists()){ lineChart.getParentFile().mkdirs(); } //初始化表格样式 initDefaultPlot(lineChartObject,dataSet); ChartUtilities.saveChartAsJPEG(lineChart ,lineChartObject, getWidth() ,getHeight()); return lineChart.getAbsolutePath(); }
ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info); if (session != null) { ServletUtilities.registerChartForDeletion(tempFile, session);
/** * Saves the given chart to a JPEG image file. * * @param aFile * File to be saved to. * @param aChart * Chart to be saved. * @param aWidth * Desired width of the image. * @param aHeight * Desired height of the image. * @throws IOException * If I/O error occurs. */ public static void saveAsJpeg(File aFile, JFreeChart aChart, int aWidth, int aHeight) throws IOException { // Force white background because JPEG does not support transparency aChart.setBackgroundPaint(Color.WHITE); ChartUtilities.saveChartAsJPEG(aFile, aChart, aWidth, aHeight); aChart.setBackgroundPaint(null); }
public void generateDriverChart(String fileName) { try { JFreeChart chart = null; String chartType = _testSuite.getParam(Constants.CHART_TYPE); if (chartType.equalsIgnoreCase("barchart")) { chart = generateDriverBarChart(); } else if (chartType.equalsIgnoreCase("scatterchart")) { chart = generateDriverScatterChart(); } else if (chartType.equalsIgnoreCase("linechart")) { chart = generateDriverLineChart(); } else { assert false; } chart.setAntiAlias(true); ChartUtilities.saveChartAsJPEG(new File(fileName), chart, _chartWidth, _chartHeight); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
case JPEG: try { ChartUtilities.saveChartAsJPEG(new File(params.path), chart, params.width, params.height); } catch (IOException e) {
case JPEG: try { ChartUtilities.saveChartAsJPEG(new File(params.path), chart, params.width, params.height); } catch (IOException e) {
ChartUtilities.saveChartAsJPEG( new File(baseName + Integer.toString(nOfFiles) + extension), chart, _chartWidth, _chartHeight);
ChartUtilities.saveChartAsJPEG( new File(baseName + Integer.toString(nOfFiles) + extension), chart, _chartWidth, _chartHeight);
plot, true); chart.setAntiAlias(true); ChartUtilities.saveChartAsJPEG( new File(baseName + Integer.toString(nOfFiles) + extension), chart, _chartWidth, _chartHeight);