List of usage examples for org.jfree.chart.entity StandardEntityCollection StandardEntityCollection
public StandardEntityCollection()
From source file:playground.anhorni.crossborder.verification.Verification.java
private void writeTGZMGraph() { int width = 800; int height = 600; for (int i = 0; i < 4; i++) { TGZMCompare tgzm = new TGZMCompare(this.xTripsPerHour[i], this.aggregatedVolumePerHourTGZM[i]); JFreeChart chart = tgzm.createChart(this.getActTypeString(i)); String fileName = "TGZMCompare" + this.getActTypeString(i); try {/* w w w. j ava 2 s . c om*/ ChartRenderingInfo info = null; info = new ChartRenderingInfo(new StandardEntityCollection()); File file1 = new File("output/" + fileName + ".png"); ChartUtilities.saveChartAsPNG(file1, chart, width, height, info); } catch (IOException e) { System.out.println(e.toString()); } //catch } int[] sumTripsPerHour = new int[24]; double[] sumAggregatedVolumePerHour = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; for (int i = 0; i < 24; i++) { for (int j = 0; j < 4; j++) { sumTripsPerHour[i] += this.xTripsPerHour[j][i]; sumAggregatedVolumePerHour[i] += this.aggregatedVolumePerHourTGZM[j][i]; } } TGZMCompare tgzm = new TGZMCompare(sumTripsPerHour, sumAggregatedVolumePerHour); JFreeChart chart = tgzm.createChart("All"); String fileName = "TGZMCompare All"; try { ChartRenderingInfo info = null; info = new ChartRenderingInfo(new StandardEntityCollection()); File file1 = new File("output/" + fileName + ".png"); ChartUtilities.saveChartAsPNG(file1, chart, width, height, info); } catch (IOException e) { System.out.println(e.toString()); } //catch }
From source file:org.n52.series.api.proxy.v0.srv.GetImageService.java
private void performChartRendering(DesignOptions options, OutputStream outputStream) { try {/* w w w. j a v a 2 s. c om*/ 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 InternalServerException("internal error!", e); } }
From source file:org.jfree.chart.demo.ImageMapDemo5.java
/** * Saves the chart image and HTML./*from w w w . ja va 2 s . c o m*/ */ public void saveImageAndHTML() { // create a dataset final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 }, { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 }, { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); 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("areachart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("areachart100.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=\"areachart100.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()); } }
From source file:gov.nih.nci.ispy.web.taglib.CatCorrPlotTag.java
public int doStartTag() { ServletRequest request = pageContext.getRequest(); HttpSession session = pageContext.getSession(); Object o = request.getAttribute(beanName); JspWriter out = pageContext.getOut(); ServletResponse response = pageContext.getResponse(); ISPYCategoricalCorrelationFinding corrFinding = (ISPYCategoricalCorrelationFinding) businessTierCache .getSessionFinding(session.getId(), taskId); try {/*w ww. j a v a2 s. c om*/ List<DataPointVector> dataSet = corrFinding.getDataVectors(); List<ReporterInfo> reporterInfoList = corrFinding.getCatCorrRequest().getReporters(); //get better labels for X and Y axis. ContinuousType ct = corrFinding.getContType(); String xLabel, yLabel; if (ct == ContinuousType.GENE) { yLabel = "Log base 2 expression value"; } else { yLabel = ct.toString(); } //if there are reporters involved then send them in so that they can be used to create //a series. ISPYCategoricalCorrelationPlot plot = new ISPYCategoricalCorrelationPlot(dataSet, reporterInfoList, "Category", yLabel, corrFinding.getContType(), ColorByType.CLINICALRESPONSE); chart = plot.getChart(); ISPYImageFileHandler imageHandler = new ISPYImageFileHandler(session.getId(), "png", 650, 600); //The final complete path to be used by the webapplication String finalPath = imageHandler.getSessionTempFolder(); String finalURLpath = imageHandler.getFinalURLPath(); /* * Create the actual charts, writing it to the session temp folder */ ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); String mapName = imageHandler.createUniqueMapName(); //PrintWriter writer = new PrintWriter(new FileWriter(mapName)); ChartUtilities.writeChartAsPNG(new FileOutputStream(finalPath), chart, 650, 600, info); //ImageMapUtil.writeBoundingRectImageMap(writer,"PCAimageMap",info,true); //writer.close(); /* This is here to put the thread into a loop while it waits for the * image to be available. It has an unsophisticated timer but at * least it is something to avoid an endless loop. **/ boolean imageReady = false; int timeout = 1000; FileInputStream inputStream = null; while (!imageReady) { timeout--; try { inputStream = new FileInputStream(finalPath); inputStream.available(); imageReady = true; inputStream.close(); } catch (IOException ioe) { imageReady = false; if (inputStream != null) { inputStream.close(); } } if (timeout <= 1) { break; } } out.print(ImageMapUtil.getBoundingRectImageMapTag(mapName, true, info)); finalURLpath = finalURLpath.replace("\\", "/"); long randomness = System.currentTimeMillis(); //prevent image caching out.print("<img id=\"geneChart\" name=\"geneChart\" src=\"" + finalURLpath + "?" + randomness + "\" usemap=\"#" + mapName + "\" border=\"0\" />"); //(imageHandler.getImageTag(mapFileName)); } catch (IOException e) { logger.error(e); } catch (Exception e) { logger.error(e); } catch (Throwable t) { logger.error(t); } return EVAL_BODY_INCLUDE; }
From source file:org.matsim.counts.algorithms.graphs.helper.OutputDelegate.java
private void writeHtml(final CountsGraph cg, final String iter_path, boolean indexFile) { /* we want landscape, thus exchange width / height */ int width = 800; int height = 600; JFreeChart chart = null;//from ww w . ja va 2 s. co m String fileName = ""; File file2; if (!indexFile) { chart = cg.getChart(); fileName = cg.getFilename(); file2 = new File(iter_path + "/" + fileName + ".html"); } else { file2 = new File(iter_path + "/start.html"); } PrintWriter writer = null; try { ChartRenderingInfo info = null; File file1; if (!indexFile) { info = new ChartRenderingInfo(new StandardEntityCollection()); file1 = new File(iter_path + "/png/" + fileName + ".png"); ChartUtilities.saveChartAsPNG(file1, chart, width, height, info); } writer = new PrintWriter(new BufferedOutputStream(new FileOutputStream(file2))); writer.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); //writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"); writer.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); writer.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">"); writer.println("<head>"); //writer.println("<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\" />"); writer.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); writer.println("<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\"/>"); writer.println("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"/>"); writer.println("<title> MATSim validation </title>"); writer.println("<script type=\"text/javascript\" src=\"div/overlib.js\"></script>"); writer.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"div/style1.css\"/>"); writer.println("</head>"); writer.println("<body>"); writer.println("<div id=\"overDiv\" style=\"Z-INDEX: 1; POSITION: absolute\"></div>"); writer.println("<div id=\"header\">"); writer.println("<div id=\"logo\">"); writer.println( "<img src=\"div/logo.png\" width=\"224\" height=\"52\" style=\"border:none;\" alt=\"logo\"/><br>Multi-Agent Transport Simulation Toolkit"); writer.println("</div>"); writer.println("<h3>Counting Volumes</h3>"); writer.println("</div>"); writer.println("<div id=\"footer\">"); GregorianCalendar cal = new GregorianCalendar(); writer.println(cal.get(Calendar.DATE) + "."); writer.println(cal.get(Calendar.MONTH) + 1 + "."); writer.println(cal.get(Calendar.YEAR) + "\t "); writer.println(System.getProperty("user.name")); writer.println("</div>"); writer.println("<div id=\"links\">"); for (Section sec : this.sections_) { writer.print("<h3>"); writer.print(sec.getTitle() + ":<br />"); writer.print("</h3>"); Iterator<MyURL> url_it = sec.getURLs().iterator(); while (url_it.hasNext()) { MyURL url = url_it.next(); writer.println("<a href=\"" + url.address + "\">" + url.displayText + "</a><br />"); } } writer.println("</div>"); writer.println("<div id=\"contents\">"); writer.println("<p>"); if (!indexFile) { ChartUtilities.writeImageMap(writer, "chart", info, true); /* chart=cg.getChart(); CategoryPlot plot=chart.getCategoryPlot(); Renderer renderer=(BarRenderer) plot.getRenderer(); renderer.getSeriesToolTipGenerator(0); */ /* how to get tooltips in there, without using xxxToolTipTagFragmentGenerator? Wait for next version of jFreeChart? Meanwhile doing slight changes to the libarary String imagemap=ChartUtilities.getImageMap("chart", info); System.out.println(imagemap); */ // reference '#chart' not working without '#' writer.println("<img src=\"png/" + fileName + ".png\" " + "width=\"" + width + "\" height=\"" + height + "\" style=\"border:none;\" alt=\"graph\" usemap=\"#chart\"/>"); } else { writer.println("<img src=\"div/title.png\" " + "width=\"972\" height=\"602\" style=\"border:none;\" alt=\"title\"/>"); } writer.println("</p>"); writer.println("</div>"); writer.println("</body>"); writer.println("</html>"); } catch (IOException e) { System.out.println(e.toString()); } finally { if (writer != null) { writer.close(); } } }
From source file:domainhealth.frontend.graphics.JFreeChartGraphImpl.java
/** * Write a PNG image representation of the Graph to the given output * stream/*from w w w . jav a 2 s . com*/ * * @param out The output stream to write the PNG bytes to * @throws IOException Indicates a problem writing to the output stream */ public void writeGraphImage(int numServersDisplayed, OutputStream out) throws IOException { ValueAxis xAxis = new DateAxis(MonitorProperties.units(DATE_TIME)); NumberAxis yAxis = new NumberAxis(yAxisUnits); yAxis.setAutoRangeIncludesZero(true); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot xyPlotLine = new XYPlot(xySeriesCollection, xAxis, yAxis, new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, xyPlotLine, true); chart.setBackgroundPaint(java.awt.Color.white); // Increase size of graph height to accommodate large legends for when many servers in the domain int graphAdditionalHeight = GRAPH_INCREMENT_HEIGHT * ((int) (numServersDisplayed / GRAPH_INCREMENT_SERVER_RATIO)); BufferedImage graphImage = chart.createBufferedImage(GRAPH_WIDTH, INITIAL_GRAPH_HEIGHT + graphAdditionalHeight, new ChartRenderingInfo(new StandardEntityCollection())); addNoDataLogoIfEmpty(graphImage); ChartUtilities.writeBufferedImageAsPNG(out, graphImage); // Could try extra two PNG related params: encodeAlpha and compression }
From source file:fr.paris.lutece.plugins.form.web.DoDownloadGraph.java
/** * Write in the http response the statistic graph of a question * @param request the http request/*w ww . j ava 2s . c om*/ * @param response The http response * */ public void doGenerateGraph(HttpServletRequest request, HttpServletResponse response) { JFreeChart chart = null; Plugin plugin = null; IEntry entry; GraphType graphType = null; int nIdEntry = -1; int nIdGraphType = -1; String strIdEntry = request.getParameter(PARAMETER_ID_ENTRY); String strIdGraphType = request.getParameter(PARAMETER_ID_GRAPH_TYPE); String strPluginName = request.getParameter(PARAMETER_PLUGIN_NAME); String strGraphThreeDimension = request.getParameter(PARAMETER_GRAPH_THREE_DIMENSION); String strGraphLabelValue = request.getParameter(PARAMETER_GRAPH_LABEL_VALUE); boolean nGraphThreeDimension = false; boolean nGraphLabelValue = false; if ((strGraphThreeDimension != null) && strGraphThreeDimension.equals("1")) { nGraphThreeDimension = true; } if ((strGraphLabelValue != null) && strGraphLabelValue.equals("1")) { nGraphLabelValue = true; } if ((strIdEntry != null) && !strIdEntry.equals(EMPTY_STRING) && (strIdGraphType != null) && !strIdGraphType.equals(EMPTY_STRING) && (strPluginName != null) && !strPluginName.equals(EMPTY_STRING)) { plugin = PluginService.getPlugin(strPluginName); try { nIdEntry = Integer.parseInt(strIdEntry); nIdGraphType = Integer.parseInt(strIdGraphType); } catch (NumberFormatException ne) { AppLogService.error(ne); } entry = EntryHome.findByPrimaryKey(nIdEntry, plugin); List<StatisticEntrySubmit> listStatistic = ResponseHome.getStatisticByIdEntry(nIdEntry, plugin); graphType = GraphTypeHome.findByPrimaryKey(nIdGraphType, plugin); if (graphType != null) { chart = graphType.createChart(listStatistic, entry.getTitle(), nGraphThreeDimension, nGraphLabelValue); } try { ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); BufferedImage chartImage = chart.createBufferedImage(600, 200, info); response.setContentType("image/PNG"); PngEncoder encoder = new PngEncoder(chartImage, false, 0, 9); response.getOutputStream().write(encoder.pngEncode()); response.getOutputStream().close(); } catch (Exception e) { AppLogService.error(e); } } }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Return rendering information for the chart. *//* www.java 2 s . c o m*/ public static final ChartRenderingInfo getAverageMetricRenderingInfo() { return new ChartRenderingInfo(new StandardEntityCollection()); }
From source file:org.cyberoam.iview.charts.Chart.java
/** * Get chart for web application rendering. * @param Request instance used for chart generation process * @param out instance used for tool tip image map * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @param imagehieght used for image height * @param imagewidht used for image width * @return fileName//from w ww .j av a 2 s .c om */ public static String getChartForWeb(HttpServletRequest request, PrintWriter out, ResultSetWrapper rsw, int imageWidth, int imageHeight) { String fileName = null; try { int reportID = request.getParameter("reportid") == null ? -1 : Integer.parseInt(request.getParameter("reportid")); JFreeChart chart = Chart.getChart(reportID, rsw, request); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); //Save the generated Chart image to system temporary directory. fileName = ServletUtilities.saveChartAsPNG(chart, imageWidth, imageHeight, info, request.getSession()); // Write the tool tip map to GUI. org.jfree.chart.ChartUtilities.writeImageMap(out, fileName, info, false); out.flush(); } catch (Exception e) { CyberoamLogger.appLog.debug("Chart.getChartForWeb:" + e, e); } return fileName; }
From source file:action.GraphAction.java
public String drawgraph() { List<CustomerOrder> orderList = new ArrayList<CustomerOrder>(); HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); TransactionDao transactionDao = new TransactionDao(); // orderList = transactionDao.findByDate(fromdate, todate); orderList = (List<CustomerOrder>) request.getSession().getAttribute("orderList"); int a = orderList.size(); System.out.println("Size--->" + a); Number[] values = getValues(orderList); System.out.println("final values are " + Arrays.toString(values)); final Number[][] data = new Number[][] { values, {} }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("", "", data); JFreeChart chart = null;//from w ww . j av a2 s .c om BarRenderer renderer3D = null; CategoryPlot plot = null; final CategoryAxis3D categoryAxis = new CategoryAxis3D("Month"); final ValueAxis valueAxis = new NumberAxis3D("Number of Transactions"); renderer3D = new BarRenderer3D(); plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer3D); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("Online Transactions", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(new Color(152, 169, 236)); try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("D:\\3dbarchart.png"); OutputStream out = ServletActionContext.getResponse().getOutputStream(); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); ChartUtilities.writeChartAsPNG(out, chart, 600, 400, info); out.close(); //returnString = "success"; } catch (Exception e) { System.out.println(e); // returnString = "error"; } return SUCCESS; }