List of usage examples for org.jfree.chart.entity StandardEntityCollection StandardEntityCollection
public StandardEntityCollection()
From source file:org.n52.server.sos.generator.EESGenerator.java
@Override public RepresentationResponse producePresentation(DesignOptions options) throws Exception { ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection()); String chartUrl = createChart(options, renderingInfo); Rectangle2D plotArea = renderingInfo.getPlotInfo().getDataArea(); for (Axis axis : renderer.getAxisMapping().values()) { axis.setMaxY(plotArea.getMaxY()); axis.setMinY(plotArea.getMinY()); }//from w w w .jav a2 s . c o m ImageEntity[] entities = {}; if (!this.isOverview) { LOGGER.debug("Produced EES diagram " + chartUrl); entities = createImageEntities(renderingInfo.getEntityCollection()); } else { LOGGER.debug("Produced EES Overview diagram " + chartUrl); } Bounds chartArea = new Bounds(plotArea.getMinX(), plotArea.getMaxX(), plotArea.getMinY(), plotArea.getMaxY()); return new EESDataResponse(chartUrl, options, chartArea, entities, renderer.getAxisMapping()); }
From source file:org.gephi.statistics.plugin.ChartUtils.java
public static String renderChart(JFreeChart chart, String fileName) { String imageFile = ""; try {/*from ww w . j a v a 2 s . c o m*/ final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); TempDir tempDir = TempDirUtils.createTempDir(); File file1 = tempDir.createFile(fileName); imageFile = "<IMG SRC=\"file:" + file1.getAbsolutePath() + "\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\"></IMG>"; ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (IOException e) { System.out.println(e.toString()); } return imageFile; }
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(); }/*ww w .j a v a 2 s . co 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:org.n52.server.io.EESGenerator.java
@Override public RepresentationResponse producePresentation(DesignOptions options) throws GeneratorException { ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection()); String chartUrl = createChart(options, renderingInfo); Rectangle2D plotArea = renderingInfo.getPlotInfo().getDataArea(); for (Axis axis : renderer.getAxisMapping().values()) { axis.setMaxY(plotArea.getMaxY()); axis.setMinY(plotArea.getMinY()); }//from w w w . j a va2 s . co m ImageEntity[] entities = {}; if (!this.isOverview) { LOGGER.debug("Produced EES diagram " + chartUrl); entities = createImageEntities(renderingInfo.getEntityCollection()); } else { LOGGER.debug("Produced EES Overview diagram " + chartUrl); } Bounds chartArea = new Bounds(plotArea.getMinX(), plotArea.getMaxX(), plotArea.getMinY(), plotArea.getMaxY()); return new EESDataResponse(chartUrl, options, chartArea, entities, renderer.getAxisMapping()); }
From source file:gov.nih.nci.cma.web.graphing.PCAPlot.java
public String generatePCAPlotChart(String components, HttpServletRequest request, PrintWriter pw) { String finalURLpath = null; //imageHandler.getFinalURLPath(); try {//from w w w. j a v a2 s. c om //check the components to see which graph to get CMAPrincipalComponentAnalysisPlot plot = null; if (components.equalsIgnoreCase("PC1vsPC2")) { plot = new CMAPrincipalComponentAnalysisPlot(pcaData, PCAcomponent.PC2, PCAcomponent.PC1, sampleGroupNames); } if (components.equalsIgnoreCase("PC1vsPC3")) { plot = new CMAPrincipalComponentAnalysisPlot(pcaData, PCAcomponent.PC3, PCAcomponent.PC1, sampleGroupNames); } if (components.equalsIgnoreCase("PC2vsPC3")) { plot = new CMAPrincipalComponentAnalysisPlot(pcaData, PCAcomponent.PC3, PCAcomponent.PC2, sampleGroupNames); } chart = plot.getChart(); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); // BW if (chart != null) { //int bwwidth = new BigDecimal(1.5).multiply(new BigDecimal(imgW)).intValue(); finalURLpath = ServletUtilities.saveChartAsPNG(chart, 500, 400, info, request.getSession()); CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator(); ttip.setExtra(" href='javascript:void(0);' "); //must have href for area tags to have cursor:pointer //ChartUtilities.writeImageMap(pw, finalURLpath, info, // ttip, // new StandardURLTagFragmentGenerator()); //ChartUtilities.writeImageMap(pw, finalURLpath, info, true); pw.write(ImageMapUtil.getBoundingRectImageMapTag(finalURLpath, false, info)); info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); } pw.flush(); } catch (IOException e) { logger.error(e); } catch (Exception e) { logger.error(e); } catch (Throwable t) { logger.error(t); } return finalURLpath; }
From source file:org.n52.server.service.GetImageService.java
private void performChartRendering(DesignOptions options, OutputStream outputStream) { try {/* w w w.j a v a 2s . c o m*/ EESGenerator chartGenerator = new EESGenerator(); ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection()); chartGenerator.createChartToOutputStream(options, renderingInfo, outputStream); } catch (Exception e) { LOGGER.error("Could not render timeseries chart.", e); throw new InternalServiceException(); } }
From source file:org.gaixie.micrite.action.GenericAction.java
public void putChartResultList(JFreeChart chart) { StandardEntityCollection entityCollection = new StandardEntityCollection(); ChartRenderingInfo info = new ChartRenderingInfo(entityCollection); String filename = ""; try {/*from w w w .ja v a 2 s. co m*/ filename = ServletUtilities.saveChartAsPNG(chart, getChartWidth(), getChartHeight(), info, null); String mapName = "map" + new Date(); String mapInfo = ChartUtilities.getImageMap(mapName, info); resultMap.put("success", true); resultMap.put("filename", filename); resultMap.put("map", mapInfo); resultMap.put("mapName", mapName); } catch (IOException e) { resultMap.put("success", false); } }
From source file:nl.wur.plantbreeding.www.marker2seq.GoDistribution.java
/** * Generate the Pie chart for a set of given Go terms. * @param gotermlist of String (here GO names) * @param title the title of the GO graph * @param url the url used for the tooltips * @param session the HttpSession used to save the file * @param legend Print the legend or not * @param tooltips Add tooltip or not//from w ww. j a va2 s . c o m * @param urls Add urls or not (link in the graph) * @param max Maximum number of item to display * @return a list containing the filename and the map for the figure * @throws IOException when something happens while writting the image */ public static String[] generateDistribution(final List<String> gotermlist, final String title, final String url, final HttpSession session, final boolean legend, final boolean tooltips, final boolean urls, final int max) throws IOException { final PieChart piec = new PieChart(); final PieDataset dataset = piec.createDataset(gotermlist); final JFreeChart chart = piec.createChart(dataset, title, legend, tooltips, urls); final PiePlot plot = (PiePlot) chart.getPlot(); if (gotermlist.size() >= max) { plot.setLabelGenerator(null); } plot.setURLGenerator(new StandardPieURLGenerator(url, "section")); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final String filename = ServletUtilities.saveChartAsPNG(chart, 500, 400, info, session); final String map = ChartUtilities.getImageMap(filename, info); final String[] output = { filename, map }; return output; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.ColoredBlockContainer.java
/** * Disclaimer: this is a "works for me" implementation, and probably only works as long as the * items are arranged horizontally in exactly one line, since it brutally enforces the items to * be aligned vertically centered./* w w w. j ava 2 s .com*/ */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = drawFill(g2, area); // check if we need to collect chart entities from the container EntityBlockParams ebp = null; StandardEntityCollection sec = null; if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { sec = new StandardEntityCollection(); } } Rectangle2D contentArea = (Rectangle2D) area.clone(); contentArea = trimMargin(contentArea); drawBorder(g2, contentArea); contentArea = trimBorder(contentArea); contentArea = trimPadding(contentArea); Iterator iterator = getBlocks().iterator(); while (iterator.hasNext()) { Block block = (Block) iterator.next(); Rectangle2D bounds = block.getBounds(); // enforce vertically centered alignment double y = area.getY() + (area.getHeight() - bounds.getHeight()) / 2.0; Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX() + area.getX(), y, bounds.getWidth(), bounds.getHeight()); Object r = block.draw(g2, drawArea, params); if (sec != null) { if (r instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) r; EntityCollection ec = ebr.getEntityCollection(); sec.addAll(ec); } } } BlockResult result = null; if (sec != null) { result = new BlockResult(); result.setEntityCollection(sec); } return result; }
From source file:org.jfree.chart.demo.ImageMapDemo6.java
/** * Saves the chart image and HTML.// w ww .j a v a 2 s .c o m */ public void saveImageAndHTML() { final CategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("multipiechart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("multipiechart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"multipiechart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }