List of usage examples for org.jfree.chart ChartUtilities getImageMap
public static String getImageMap(String name, ChartRenderingInfo info)
From source file:lucee.runtime.tag.Chart.java
private void writeOut(JFreeChart jfc) throws PageException, IOException { final ChartRenderingInfo info = new ChartRenderingInfo(); // map name/*from www . j ava 2s . c o m*/ chartIndex++; if (chartIndex < 0) chartIndex = 0; String mapName = "chart_" + chartIndex; setUrl(jfc); // write out to variable if (!StringUtil.isEmpty(name)) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(baos, jfc, info); pageContext.setVariable(name, baos.toByteArray()); return; } // write out as link String id = Md5.getDigestAsString(JavaConverter.serialize(this)); Resource graph = pageContext.getConfig().getTempDirectory().getRealResource("graph"); Resource res = graph.getRealResource(id); if (!res.exists()) { clean(graph); copy(res.getOutputStream(), jfc, info); } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(baos, jfc, info); } String contextPath = pageContext.getHttpServletRequest().getContextPath(); contextPath = StringUtil.isEmpty(contextPath) ? "/" : contextPath + "/"; String src = contextPath + "lucee/graph.cfm?img=" + id + "&type=" + formatToString(format); if (!StringUtil.isEmpty(source)) { pageContext.setVariable(source, src); return; } try { if (showtooltip || !StringUtil.isEmpty(url)) { String map = ChartUtilities.getImageMap(mapName, info).trim(); pageContext.write(map); } pageContext.write("<img border=\"0\" usemap=\"#" + mapName + "\" src=\"" + src + "\">"); } catch (IOException e) { throw Caster.toPageException(e); } }
From source file:eu.planets_project.tb.gui.backing.ExperimentBean.java
public String getResultChartUrl() { try {// w w w. jav a 2 s .c o m ExperimentChartServlet ec = new ExperimentChartServlet(); chart = ec.createWallclockChart("" + this.getExperiment().getEntityID()); // Pick into the session... HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest(); HttpSession session = request.getSession(); // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); this.graphId = ServletUtilities.saveChartAsPNG(chart, 600, 500, info, session); this.graphImageMap = ChartUtilities.getImageMap(graphId, info); this.graphUrl = request.getContextPath() + "/servlet/DisplayChart?filename=" + graphId; return this.graphUrl; } catch (Exception e) { log.error("Failure while generating graph: " + e); e.printStackTrace(); return null; } }