List of usage examples for org.jfree.chart ChartUtilities getImageMap
public static String getImageMap(String name, ChartRenderingInfo info)
From source file:nl.wur.plantbreeding.www.marker2seq.GoDistribution.java
/** * Generate the Pie chart for a set of given Go terms. * @param distrib a HashMap of GO name and GO frequency * @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/* w w w.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 HashMap<String, Integer> distrib, 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 piedata = piec.createDataset(distrib); final JFreeChart chart = piec.createChart(piedata, title, legend, tooltips, urls); final PiePlot plot = (PiePlot) chart.getPlot(); if (distrib.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:org.squale.squaleweb.util.graph.GraphMaker.java
/** * Factorisation du code mettant jour les donns d'une image cliquables * // www . java 2s.co m * @param fileName le nom du fichier * @param info le ChartRenderingInfo de l'image * @param pRequest la requete pour internationalisation */ public GraphMaker(HttpServletRequest pRequest, String fileName, ChartRenderingInfo info) { setMapDescription(ChartUtilities.getImageMap(fileName, info)); setSrcName(pRequest.getContextPath() + WebMessages.getString("default.path.display") + fileName); setUseMapName("#" + fileName); }
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// w w w .ja v a 2 s .c om * @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: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 ww . ja v a 2s. c o 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:org.sakaiproject.gradebookng.tool.component.JFreeChartImageWithToolTip.java
@Override public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { final JFreeChart chart = (JFreeChart) getDefaultModelObject(); if (chart == null) { return;//from ww w .ja v a2 s . c o m } final ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { this.chartRenderingInfo.clear(); ChartUtilities.writeChartAsPNG(stream, chart, this.width, this.height, this.chartRenderingInfo); } catch (final IOException ex) { // do something } replaceComponentTagBody(markupStream, openTag, ChartUtilities.getImageMap(this.imageMapId, this.chartRenderingInfo)); }
From source file:hudson.util.Graph.java
/** * Renders a clickable map.//from w ww .j a v a 2 s . co m */ public void doMap(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.checkIfModified(timestamp, rsp)) return; String w = req.getParameter("width"); if (w == null) w = String.valueOf(defaultW); String h = req.getParameter("height"); if (h == null) h = String.valueOf(defaultH); ChartRenderingInfo info = new ChartRenderingInfo(); render(req, info); rsp.setContentType("text/plain;charset=UTF-8"); rsp.getWriter().println(ChartUtilities.getImageMap("map", info)); }
From source file:hudson.graph.jfreechart.JFreeChartSupport.java
@Override public String getImageMap(String id, int width, int height) { //Unfortunately we have to render it again, because the map is loaded lazily in another HTTP request render(width, height);//from www.j ava 2 s . com return ChartUtilities.getImageMap(id, info); }
From source file:tdunnick.jphineas.console.queue.Charts.java
/** * Get a PNG image/HTML map pair for storing in the dashboard data * @param chart to use/*w ww. j av a2 s . c o m*/ * @param id for the map * @param width of the image * @param height of the image * @return the PNG/map pair */ private Object[] getJFreeObject(JFreeChart chart, String id, int width, int height) { ChartRenderingInfo info = new ChartRenderingInfo(); BufferedImage img = getJFreeImage(chart, width, height, info); Object[] o = { getPNG(img), ChartUtilities.getImageMap(id, info) }; return o; }
From source file:hudson.plugins.plot.PlotData.java
/** * Generates and writes the plot's clickable map to the response * output stream.//from w ww. j a v a 2 s . co m * * @param req the incoming request * @param rsp the response stream * @throws IOException */ public void plotGraphMap(StaplerRequest req, StaplerResponse rsp) throws IOException { if (ChartUtil.awtProblemCause != null) { // not available. send out error message rsp.sendRedirect2(req.getContextPath() + "/images/headless.png"); return; } setWidth(req); setHeight(req); setNumBuilds(req); setRightBuildNum(req); setHasLegend(req); // setTitle(req); setStyle(req); setUseDescr(req); generatePlot(false); ChartRenderingInfo info = new ChartRenderingInfo(); plot.createBufferedImage(getWidth(), getHeight(), info); rsp.setContentType("text/plain;charset=UTF-8"); rsp.getWriter().println(ChartUtilities.getImageMap(csvFilePath.getName(), info)); }
From source file:hudson.plugins.plot.Plot.java
/** * Generates and writes the plot's clickable map to the response output * stream./*w w w. j a v a 2s . com*/ * * @param req * the incoming request * @param rsp * the response stream * @throws IOException */ public void plotGraphMap(StaplerRequest req, StaplerResponse rsp) throws IOException { if (ChartUtil.awtProblemCause != null) { // not available. send out error message rsp.sendRedirect2(req.getContextPath() + "/images/headless.png"); return; } setWidth(req); setHeight(req); setNumBuilds(req); setRightBuildNum(req); setHasLegend(req); setTitle(req); setStyle(req); setUseDescr(req); generatePlot(false); ChartRenderingInfo info = new ChartRenderingInfo(); plot.createBufferedImage(getWidth(), getHeight(), info); rsp.setContentType("text/plain;charset=UTF-8"); rsp.getWriter().println(ChartUtilities.getImageMap(getCsvFileName(), info)); }