ChartUtilities.writeChartAsPNG(outputStream, chart, width, height);
/** * Writes a chart to an output stream in PNG format. * * @param out the output stream (<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 writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... writeChartAsPNG(out, chart, width, height, null); }
/** * Writes a chart to an output stream in PNG format. * * @param out the output stream (<code>null</code> not permitted). * @param chart the chart (<code>null</code> not permitted). * @param width the image width. * @param height the image height. * @param encodeAlpha encode alpha? * @param compression the compression level (0-9). * * @throws IOException if there are any I/O errors. */ public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, boolean encodeAlpha, int compression) throws IOException { // defer argument checking... ChartUtilities.writeChartAsPNG(out, chart, width, height, null, encodeAlpha, compression); }
public static void saveAsPNG(JFreeChart chart, String filename, int width, int height) { try { ChartUtilities.writeChartAsPNG(new FileOutputStream(filename + ".png"), chart, width, height); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override protected byte[] getImageData(Attributes aAttributes) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(bos, chart, width, height); return bos.toByteArray(); } catch (IOException e) { return new byte[0]; } }
@Override protected byte[] getImageData(Attributes aAttributes) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(bos, chart, width, height); return bos.toByteArray(); } catch (IOException e) { return new byte[0]; } }
private void savePNG(JFreeChart chart) { File f = new File(config.getString("/ofx/dir[@type='image-web']")+"/"+chartName+".png"); try { OutputStream os = new FileOutputStream(f); ChartUtilities.writeChartAsPNG(os,chart,width,height); os.close(); } catch (FileNotFoundException e) {logger.error("",e);} catch (IOException e) {logger.error("",e);} }
public static byte[] getChartAsPngByteArray( JFreeChart jFreeChart, int width, int height ) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG( out, jFreeChart, width, height ); out.flush(); return out.toByteArray(); } catch ( IOException ex ) { throw new UncheckedIOException( ex ); } } }
/** * Plots the chart and sends it in the form of ByteArrayOutputStream to * outside. * * @return Returns the byteArrayOutputStream. */ public synchronized ByteArrayOutputStream writePlot ( ) { if ( !changed ) return byteArrayOutputStream; byteArrayOutputStream.reset( ); try { ChartUtilities.writeChartAsPNG( byteArrayOutputStream , chart , width , height , false , 8 ); } catch ( IOException e ) { logger.warn( e.getMessage( ) , e ); } return byteArrayOutputStream; }
/** * Saves a chart to a file in PNG format. This method allows you to pass * in a {@link ChartRenderingInfo} object, to collect information about the * chart dimensions/entities. You will need this info if you want to * create an HTML image map. * * @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. * @param info the chart rendering info (<code>null</code> permitted). * * @throws IOException if there are any I/O errors. */ public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (file == null) { throw new IllegalArgumentException("Null 'file' argument."); } OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { ChartUtilities.writeChartAsPNG(out, chart, width, height, info); } finally { out.close(); } }
writeChartAsPNG(out, chart, width, height, info, encodeAlpha, compression);
@Override protected byte[] getImageData(final Attributes attributes) { try { final JFreeChart chart = (JFreeChart) getDefaultModelObject(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (imageType == JFreeChartImageType.JPEG) { ChartUtilities.writeChartAsJPEG(baos, chart, width, height); } else { ChartUtilities.writeChartAsPNG(baos, chart, width, height); } final byte[] ba = baos.toByteArray(); return ba; } catch (final IOException ex) { log.error(ex.getMessage(), ex); return null; } }
/** * Executes the result. Writes the given chart as a PNG to the servlet output stream. * * @param invocation an encapsulation of the action execution state. * @throws Exception if an error occurs when creating or writing the chart to the servlet output stream. */ public void execute(ActionInvocation invocation) throws Exception { JFreeChart chart = null; if (chartSet) { chart = this.chart; } else { chart = (JFreeChart) invocation.getStack().findValue("chart"); } if (chart == null) { throw new NullPointerException("No chart found"); } HttpServletResponse response = ServletActionContext.getResponse(); OutputStream os = response.getOutputStream(); ChartUtilities.writeChartAsPNG(os, chart, width, height); os.flush(); } }
@SuppressWarnings("unchecked") private void chart(HttpServletRequest request , HttpServletResponse response) { String uuid = new String(request.getParameter("uuid")); try { OutputStream out = response.getOutputStream(); HttpSession session = request.getSession(); Map<String,Chart> mCharts = (Map<String,Chart>)session.getAttribute("charts"); Chart chart = mCharts.get(uuid); // JaxbUtil.debug(chart, new MwiNsPrefixMapper()); OfxChartRenderer ofxRenderer = new OfxChartRenderer(); JFreeChart jfreeChart = ofxRenderer.render(JaxbUtil.toDocument(chart)); response.setContentType("image/png"); ChartUtilities.writeChartAsPNG(out,jfreeChart,chart.getDimension().getWidth(),chart.getDimension().getHeight()); } catch (IOException e) {e.printStackTrace();} } }
ChartUtilities.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height));
public void createChartToOutputStream(DesignOptions options, ChartRenderingInfo renderingInfo, OutputStream outputStream) { try { Map<String, OXFFeatureCollection> entireCollMap = getFeatureCollectionFor(options, true); JFreeChart chart = producePresentation(entireCollMap, options); chart.removeLegend(); int width = options.getWidth(); int height = options.getHeight(); ChartUtilities.writeChartAsPNG(outputStream, chart, width, height, renderingInfo); } catch (Exception e) { LOGGER.warn("Error while rendering chart.", e); } }
/** * @param out * @return extension png or jpg for usage as file name extension. */ public String write(final OutputStream out) { final JFreeChart chart = getJFreeChart(); final int width = getWidth(); final int height = getHeight(); String extension = null; try { if (getImageType() == JFreeChartImageType.PNG) { extension = "png"; ChartUtilities.writeChartAsPNG(out, chart, width, height); } else { extension = "jpg"; ChartUtilities.writeChartAsJPEG(out, chart, width, height); } } catch (final IOException ex) { log.error("Exception encountered " + ex, ex); } return extension; }
/** * Renders a single result as a chart * * @param singleValueName * @param domainAxisName * @param rangeAxisName * @param principalDataset * @param target */ private void renderChart(String name, XYPlot plot, File target) throws IOException { OutputStream out = getOut(target); try { ConfigurationCharts configurationCharts = ENVIRONMENT.getConfigurationCharts(); writeChartAsPNG(out, ChartUtil.createJFreeChart(name, plot, configurationCharts.getHeight()), configurationCharts.getWidth(), configurationCharts.getHeight(), null); } finally { out.close(); } }
ChartUtilities.writeChartAsPNG(out, chart, hzPixels, vtPixels, false, 6);
ChartUtilities.writeChartAsPNG(out, chart, hzPixels, vtPixels, false, 6);