List of usage examples for org.jfree.chart ChartUtilities writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException
From source file:org.posterita.core.AbstractChart.java
public void writeChartAsJPEG(OutputStream outputStream, int width, int height) throws OperationException { try {//from ww w .j a v a2s . c o m ChartUtilities.writeChartAsJPEG(outputStream, getChart(), width, height, renderingInfo); } catch (IOException e) { throw new OperationException("Problem occured while write chart.", e); } }
From source file:org.pentaho.chart.plugin.jfreechart.outputs.JFreeChartOutput.java
public OutputStream persistChart(OutputStream outputStream, IOutput.OutputTypes fileType, int width, int height) throws PersistenceException { info = new ChartRenderingInfo(new StandardEntityCollection()); if (outputStream == null) { outputStream = new ByteArrayOutputStream(); }//from www . ja va 2 s. c o m try { outputStream.flush(); } catch (IOException e1) { throw new PersistenceException(e1); } if (fileType == IOutput.OutputTypes.FILE_TYPE_JPEG) { try { ChartUtilities.writeChartAsJPEG(outputStream, chart, width, height, info); } catch (IOException e) { throw new PersistenceException(e); } } else if ((fileType == IOutput.OutputTypes.FILE_TYPE_PNG) || (fileType == null)) { try { ChartUtilities.writeChartAsPNG(outputStream, chart, width, height, info); } catch (IOException e) { throw new PersistenceException(e); } } return outputStream; }
From source file:de.laures.cewolf.util.Renderer.java
/** * Handles rendering a chart as a JPEG. Currently this method is synchronized * because of concurrency issues with JFreeChart. * * @param baos//from w ww . j ava 2 s . c o m * @param chart * @param width * @param height * @param info * @throws IOException */ private static synchronized void handleJPEG(ByteArrayOutputStream baos, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { ChartUtilities.writeChartAsJPEG(baos, chart, width, height, info); }
From source file:net.sf.jsfcomp.chartcreator.renderkit.ChartRenderer.java
private void writeImageMap(FacesContext context, UIChart uichart) { ResponseWriter writer = context.getResponseWriter(); ExternalContext externalContext = context.getExternalContext(); Map sessionMap = externalContext.getSessionMap(); String clientId = uichart.getClientId(context); ChartData data = (ChartData) sessionMap.get(clientId); JFreeChart chart = ChartUtils.createChartWithType(data); ChartUtils.setGeneralChartProperties(chart, data); ChartRenderingInfo chartRenderingInfo = new ChartRenderingInfo(); try {//w ww . j a v a2s. c om ByteArrayOutputStream out = new ByteArrayOutputStream(); if (data.getOutput().equalsIgnoreCase("png")) ChartUtilities.writeChartAsPNG(out, chart, data.getWidth(), data.getHeight(), chartRenderingInfo); else if (data.getOutput().equalsIgnoreCase("jpeg")) ChartUtilities.writeChartAsJPEG(out, chart, data.getWidth(), data.getHeight(), chartRenderingInfo); renderImageMapSupport(context, uichart, chartRenderingInfo); writer.write(ChartUtilities.getImageMap(uichart.getGenerateMap(), chartRenderingInfo, new StandardToolTipTagFragmentGenerator(), new URLTagFragmentGenerator(uichart.getId()))); } catch (IOException error) { error.printStackTrace(); } }
From source file:temp1.JFrame1.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed if (RealTimeChart.getpd() == false) { jFileChooser2.showDialog(this, "?"); String fname = jFileChooser2.getName(jFileChooser2.getSelectedFile()); int result = 0; if (result == JFileChooser.APPROVE_OPTION && jFileChooser2.getSelectedFile() != null) { String filePath = jFileChooser2.getSelectedFile().getPath(); System.out.println(filePath + ".jpg"); try { FileOutputStream fos_jpg = null; filePath = filePath + ".jpg"; fos_jpg = new FileOutputStream(filePath); System.out.println(fos_jpg); ChartUtilities.writeChartAsJPEG(fos_jpg, 0.8f, jfreechart1, 2560, 1920); } catch (Exception e) { }/*from ww w . j ava 2s . c o m*/ } } }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private byte[] generateChart(JFreeChart chart, byte _format, int width, int height, ChartRenderingInfo info) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); if (_format == FORMAT_JPG) ChartUtilities.writeChartAsJPEG(out, chart, width, height, info); else//from w w w .j a v a 2 s .c o m ChartUtilities.writeChartAsPNG(out, chart, width, height, info); out.close(); return out.toByteArray(); }