List of usage examples for org.jfree.chart.entity StandardEntityCollection StandardEntityCollection
public StandardEntityCollection()
From source file:org.squale.squaleweb.applicationlayer.action.results.audit.AuditAction.java
/** * Consrtuit les grpahes reprsentant les statistiques par serveur sur le temps et la taille des audits * //from www. j a v a2 s . c o m * @param pRequest la requte * @param auditsList la liste des audits * @param serverName le nom du serveur * @return un tableau de GraphMaker deux lment : [TimeMaker, SizeMaker] * @throws IOException si erreur la transformation des graphes en image */ private GraphMaker[] buildStatGraphics(HttpServletRequest pRequest, List auditsList, String serverName) throws IOException { // Initialisation GraphMaker timeMaker = null; List durationList = new ArrayList(0); List fsSizeList = new ArrayList(0); GraphMaker sizeMaker = null; // ajoute les valeurs dj rcupres aux maps for (int i = 0; i < auditsList.size(); i++) { AuditForm form = (AuditForm) auditsList.get(i); if (serverName.equals(form.getServerName())) { String auditDate = SqualeWebActionUtils.getFormattedDate(pRequest.getLocale(), form.getDate(), "date.format.simple.short"); durationList.add(new Object[] { auditDate, form.getDuration(), form.getApplicationName() }); fsSizeList.add(new Object[] { auditDate, form.getMaxFileSystemSize(), form.getApplicationName() }); } } // construit le maker et lui passe les valeurs afin qu'il construise // les diffrentes courbes si il y a des donnes if (durationList.size() > 0) { AuditTimeMaker statsTimeMaker = new AuditTimeMaker(pRequest); statsTimeMaker.setValues(durationList); AuditsSizeMaker statsSizeMaker = new AuditsSizeMaker(pRequest); statsSizeMaker.addCurve(fsSizeList); JFreeChart timeChart = statsTimeMaker.getChart(); JFreeChart sizeChart = statsSizeMaker.getChart(); ChartRenderingInfo infoStats = new ChartRenderingInfo(new StandardEntityCollection()); // Initialisation des graphs String fileNameTime = ServletUtilities.saveChartAsPNG(timeChart, statsTimeMaker.getDefaultWidth(), statsTimeMaker.getDefaultHeight(), infoStats, pRequest.getSession()); timeMaker = new GraphMaker(pRequest, fileNameTime, infoStats); infoStats = new ChartRenderingInfo(new StandardEntityCollection()); String fileNameSize = ServletUtilities.saveChartAsPNG(sizeChart, statsSizeMaker.getDefaultWidth(), statsSizeMaker.getDefaultHeight(), infoStats, pRequest.getSession()); sizeMaker = new GraphMaker(pRequest, fileNameSize, infoStats); } return new GraphMaker[] { timeMaker, sizeMaker }; }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Return rendering information for the chart. *//* w ww . j ava 2s. c om*/ public static final ChartRenderingInfo getAverageAreaTestTimeRenderingInfo() { return new ChartRenderingInfo(new StandardEntityCollection()); }
From source file:com.qspin.qtaste.reporter.testresults.html.HTMLReportFormatter.java
private void generatePieChart() { if (currentTestSuite == null) { return;/*from w ww .j av a 2s . c o m*/ } File testSummaryFile = new File(reportFile.getParentFile(), testSummaryFileName); File tempTestSummaryFile = new File(testSummaryFile.getPath() + ".tmp"); final DefaultPieDataset pieDataSet = new DefaultPieDataset(); pieDataSet.setValue("Passed", new Integer(currentTestSuite.getNbTestsPassed())); pieDataSet.setValue("Failed", new Integer(currentTestSuite.getNbTestsFailed())); pieDataSet.setValue("Tests in error", new Integer(currentTestSuite.getNbTestsNotAvailable())); pieDataSet.setValue("Not executed", new Integer(currentTestSuite.getNbTestsToExecute() - currentTestSuite.getNbTestsExecuted())); JFreeChart chart = null; final boolean drilldown = true; // create the chart... if (drilldown) { final PiePlot plot = new PiePlot(pieDataSet); Color[] colors = { new Color(100, 230, 40), new Color(210, 35, 35), new Color(230, 210, 40), new Color(100, 90, 40) }; PieRenderer renderer = new PieRenderer(colors); renderer.setColor(plot, (DefaultPieDataset) pieDataSet); plot.setURLGenerator(new StandardPieURLGenerator("pie_chart_detail.jsp")); plot.setLabelGenerator(new TestSectiontLabelPieGenerator()); chart = new JFreeChart("Test summary", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createPieChart("Test summary", // chart title pieDataSet, // data true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); ChartUtilities.saveChartAsPNG(tempTestSummaryFile, chart, 600, 400, info); } catch (IOException e) { logger.error("Problem saving png chart", e); } testSummaryFile.delete(); if (!tempTestSummaryFile.renameTo(testSummaryFile)) { logger.error("Couldn't rename test summary file " + tempTestSummaryFile + " into " + testSummaryFile); } }
From source file:org.squale.squaleweb.applicationlayer.action.IndexAction.java
/** * Action to do for display kiviat//from w w w . java 2 s.co m * * @param applicationList The list of component * @param request The http request * @param form The page form * @throws JrafEnterpriseException Exception happened during the action */ private void resultKiviat(List<ComponentDTO> applicationList, HttpServletRequest request, ActionForm form) throws JrafEnterpriseException { try { IApplicationComponent ac1 = AccessDelegateHelper.getInstance("Component"); IApplicationComponent ac2 = AccessDelegateHelper.getInstance("Graph"); HomepageForm currentForm = (HomepageForm) form; HashMap<Long, GraphMaker> graphMakerMap = new HashMap<Long, GraphMaker>(); for (ComponentDTO application : applicationList) { // Recovering of the last audit successful for the application Integer nbLigne = new Integer(1); Integer indexDepart = new Integer(0); Integer status = new Integer(AuditBO.TERMINATED); Object[] paramIn = { application, nbLigne, indexDepart, status }; List<AuditDTO> auditsDTO = (List<AuditDTO>) ac1.execute("getLastAllAudits", paramIn); // Instanciation of the kiviat graph String appli = WebMessages.getString("homepage.result.kiviatApplication"); KiviatMaker maker = new KiviatMaker(appli + application.getName()); // Recovering the list of values needed for built the graph Long pCurrentAuditId = new Long(auditsDTO.get(0).getID()); Boolean allFactors = new Boolean(isDisplayResultKiviatAllFactors); Object[] paramAuditId = { pCurrentAuditId, String.valueOf(allFactors) }; Map projectsValues = (Map) ac2.execute("getApplicationKiviatGraph", paramAuditId); Set keysSet = projectsValues.keySet(); Iterator it = keysSet.iterator(); // For each series of values we add them while (it.hasNext()) { String key = (String) it.next(); maker.addValues(key, (SortedMap) projectsValues.get(key), request); } // Create the JfreChart object JFreeChart chartKiviat = maker.getChart(false, false); // Calculation of the height of the graph based on the width of the graph choose by the user int kiviatHeight = Math.round(kiviatWidth * 2.0f / 3); // Create the picture ChartRenderingInfo infoKiviat = new ChartRenderingInfo(new StandardEntityCollection()); String fileNameKiviat = ServletUtilities.saveChartAsPNG(chartKiviat, kiviatWidth, kiviatHeight, infoKiviat, request.getSession()); // For a clickable picture GraphMaker applicationKiviatChart = new GraphMaker(request, fileNameKiviat, infoKiviat); graphMakerMap.put(pCurrentAuditId, applicationKiviatChart); } currentForm.setGraphMakerMap(graphMakerMap); } catch (IOException e) { throw new JrafEnterpriseException("IOException", e); } }
From source file:org.squale.squaleweb.applicationlayer.action.results.project.ProjectResultsAction.java
/** * Rcupre les dtails de la pratique/*from w ww . ja v a 2 s .com*/ * * @param pMapping le mapping. * @param pForm le formulaire lire. * @param pRequest la requte HTTP. * @param pResponse la rponse de la servlet. * @return l'action raliser. */ public ActionForward practice(ActionMapping pMapping, ActionForm pForm, HttpServletRequest pRequest, HttpServletResponse pResponse) { ActionForward forward = null; ActionErrors errors = new ActionErrors(); try { // On rcupre l'indicateur pour le traceur car il va tre mis false // dans la mthode commune "getForm" or il se peut que l'on vienne // de la page composant. String tracker_bool = (String) pRequest.getSession().getAttribute(SqualeWebConstants.TRACKER_BOOL); WActionForm form = getForm(pMapping, pRequest, pForm); changeWay(pRequest, tracker_bool); if (form instanceof ResultRulesCheckingForm) { forward = pMapping.findForward("practiceruleschecking"); } else { ResultForm resForm = (ResultForm) form; // rempli les champs passer de requete en requete resForm.copyValues((RootForm) pForm); // if practice is not a manual practice if (resForm.getFormulaType() != null) { forward = pMapping.findForward("practice"); // le graph double[] tab; // Dans les 2 cas on affiche le graph en barre RepartitionBarMaker barMaker = new RepartitionBarMaker(pRequest, resForm.getProjectId(), resForm.getCurrentAuditId(), resForm.getPreviousAuditId(), resForm.getId(), resForm.getParentId()); barMaker.setValues(resForm.getIntRepartition()); // Sauvegarde de l'image de l'histogramme au format png dans un espace temporaire ChartRenderingInfo infoRepartition = new ChartRenderingInfo(new StandardEntityCollection()); String repartitionFileName = ServletUtilities.saveChartAsPNG(barMaker.getChart(), RepartitionBarMaker.DEFAULT_WIDTH, RepartitionBarMaker.DEFAULT_HEIGHT, infoRepartition, pRequest.getSession()); GraphMaker repartitionChart = new GraphMaker(pRequest, repartitionFileName, infoRepartition); ((ProjectSummaryForm) pForm).setBarGraph(repartitionChart); // Dans ce cas l, on affiche en plus l'histogramme if (resForm.getFormulaType().equals(AbstractFormulaBO.TYPE_SIMPLE)) { RepartitionMaker maker = new RepartitionMaker(pRequest, resForm.getProjectId(), resForm.getCurrentAuditId(), resForm.getPreviousAuditId(), resForm.getId(), resForm.getParentId()); maker.build(resForm.getFloatRepartition()); // Sauvegarde de l'image de l'histogramme au format png dans un espace temporaire infoRepartition = new ChartRenderingInfo(new StandardEntityCollection()); repartitionFileName = ServletUtilities.saveChartAsPNG(maker.getChart(), RepartitionMaker.DEFAULT_WIDTH, RepartitionMaker.DEFAULT_HEIGHT, infoRepartition, pRequest.getSession()); repartitionChart = new GraphMaker(pRequest, repartitionFileName, infoRepartition); ((ProjectSummaryForm) pForm).setHistoBarGraph(repartitionChart); } else { // on remet l'histogramme null pour le rinitialiser et ne pas l'afficher ((ProjectSummaryForm) pForm).setHistoBarGraph(null); } } // if the practice is a manual practice else { forward = pMapping.findForward("manualpractice"); } } ((ProjectSummaryForm) pForm).setResults(form); } catch (Exception e) { // Traitement factoris des exceptions handleException(e, errors, pRequest); } if (!errors.isEmpty()) { // Sauvegarde des messages et renvoi vers la page d'erreur saveMessages(pRequest, errors); forward = pMapping.findForward("total_failure"); } return forward; }
From source file:org.apache.hadoopts.app.bucketanalyser.TSOperationControlerPanel.java
public void storeChartImageAsPNG(JFreeChart chart, File folder, String filename) { String fn = filename;/*from w ww . ja va 2 s .co m*/ try { final File file1 = new File(folder.getAbsolutePath() + File.separator + fn + ".png"); System.out.println("\n>>> Save as PNG Image - Filename: " + file1.getAbsolutePath() + "; CP: " + chart); try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); Thread.currentThread().sleep(1000); ChartUtilities.saveChartAsPNG(file1, chart, 800, 600, info); Thread.currentThread().sleep(1000); } catch (Exception e) { e.printStackTrace(); } // File file = new File(folder.getAbsolutePath() + File.separator + fn + ".svg"); // System.out.println(">>> Save as SVG Image - Filename: " + file.getAbsolutePath() // + "; CP: "+ cp); // // // // Get a DOMImplementation and create an XML document // DOMImplementation domImpl = // GenericDOMImplementation.getDOMImplementation(); // Document document = domImpl.createDocument(null, "svg", null); // // // Create an instance of the SVG Generator // SVGGraphics2D svgGenerator = new SVGGraphics2D(document); // // // draw the chart in the SVG generator // cp.draw(svgGenerator, new Rectangle(800, 600)); // // // Write svg file // OutputStream outputStream = new FileOutputStream(file); // Writer out = new OutputStreamWriter(outputStream, "UTF-8"); // svgGenerator.stream(out, true /* use css */); // outputStream.flush(); // outputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:UserInfo_Frame.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed String pressure = txt_pressure.getText(); String temperature = txt_temperature.getText(); String volumeflow = txt_volume.getText(); String rotationalSpeed = txt_rotationalSpd.getText(); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Pressure", new Double(pressure)); pieDataset.setValue("Temperature", new Double(temperature)); pieDataset.setValue("Volume Flow", new Double(volumeflow)); pieDataset.setValue("Rotational Speeed", new Double(rotationalSpeed)); //JFreeChart chart = ChartFactory.createPieChart("Pie Chart",pieDataset,true,true,true); // create normal piechart //PiePlot3D p = (PiePlot)chart.getPlot(); JFreeChart chart = ChartFactory.createPieChart3D("Parameter Pie Chart", pieDataset, true, true, true);// create 3D piechart PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame cframe = new ChartFrame("Pie Chart", chart); cframe.setVisible(true);/*w w w. ja v a 2s . c o m*/ cframe.setSize(450, 500); try { //save chart as PNG final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("chart.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception e) { } }
From source file:servlets.LeasingControllerServlet.java
public void doGetChart() { PieDataset pieDataset = createDataset(); JFreeChart chart = ChartFactory.createPieChart("Tenant Mix ", pieDataset, true, true, false); //chart.setBackgroundPaint(new Color(222, 222, 255)); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}")); plot.setCircular(true);//from w w w. j a v a 2 s . c o m plot.setSectionPaint("F&B", new Color(15, 192, 252)); try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File( getServletContext().getRealPath("") + "/leasingSystem/leasingSystemAssets/chart/piechart.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception e) { System.out.println(e); } }
From source file:it.eng.spagobi.kpi.utils.BasicTemplateBuilder.java
private SourceBean setLineAttributes(KpiLine line, SourceBean semaphor, SourceBean textCodeName, SourceBean textValue, SourceBean textWeight, SourceBean image1, int level, SourceBean separatorline, SourceBean threshCode, SourceBean threshValue, SourceBean extraimageToAdd) { logger.debug("IN"); KpiValue kpiValue = line.getValue(); ThresholdValue t = null;// w w w . ja v a2s. com Color colorSemaphor = null; if (kpiValue != null && kpiValue.getValue() != null) { t = kpiValue.getThresholdOfValue(); if (t != null) { colorSemaphor = t.getColor(); } } Integer xValue = xStarter + (xIncrease * Integer.valueOf(level)); Integer yValue = actualHeight; try { //set Semaphor semaphor.setAttribute("reportElement.x", xValue.toString()); semaphor.setAttribute("reportElement.y", new Integer(yValue.intValue() + 2).toString()); if (colorSemaphor != null) { String color = Integer.toHexString(colorSemaphor.getRGB()); color = "#" + color.substring(2); semaphor.setAttribute("reportElement.forecolor", "#000000"); semaphor.setAttribute("reportElement.backcolor", color); } else { semaphor.setAttribute("reportElement.forecolor", "#FFFFFF"); semaphor.setAttribute("reportElement.backcolor", "#FFFFFF"); } xValue = xValue + semaphorWidth + separatorWidth; // set text 1: Model CODE - Model NAME textCodeName.setAttribute("reportElement.x", (xValue)); textCodeName.setAttribute("reportElement.y", yValue.toString()); SourceBean textValue1 = (SourceBean) textCodeName.getAttribute("text"); textValue1.setCharacters(line.getModelInstanceCode() + "-" + line.getModelNodeName()); xValue = xValue + textWidth + separatorWidth; //Set Value, weight and threshold code and value if (kpiValue != null) { String value1 = kpiValue.getValue() != null ? kpiValue.getValue() : ""; //set text2 textValue.setAttribute("reportElement.y", yValue.toString()); SourceBean textValue2 = (SourceBean) textValue.getAttribute("text"); textValue2.setCharacters(value1); String weight = (kpiValue.getWeight() != null) ? kpiValue.getWeight().toString() : ""; //set text2 xValue = xValue + numbersWidth + separatorWidth; textWeight.setAttribute("reportElement.y", new Integer(yValue.intValue() + 2).toString()); SourceBean textValue3 = (SourceBean) textWeight.getAttribute("text"); textValue3.setCharacters(weight); if (t != null) { try { Threshold tr = DAOFactory.getThresholdDAO().loadThresholdById(t.getThresholdId()); if (!thresholdsList.contains(tr)) { thresholdsList.add(tr); } } catch (EMFUserError e) { logger.error("error in loading the Threshold by Id", e); e.printStackTrace(); } String code = t.getThresholdCode() != null ? t.getThresholdCode() : ""; String codeTh = "Code: " + code; if (codeTh.length() > 20) codeTh = codeTh.substring(0, 19); threshCode.setAttribute("reportElement.y", new Integer(yValue.intValue() - 2).toString()); SourceBean threshCode2 = (SourceBean) threshCode.getAttribute("text"); threshCode2.setCharacters(codeTh); String labelTh = t.getLabel() != null ? t.getLabel() : ""; String min = t.getMinValue() != null ? t.getMinValue().toString() : null; String max = t.getMaxValue() != null ? t.getMaxValue().toString() : null; String valueTh = "Value: "; if (t.getThresholdType().equalsIgnoreCase("RANGE")) { if (min != null && max != null) { valueTh = valueTh + min + "-" + max + " " + labelTh; } else if (min != null && max == null) { valueTh = valueTh + "> " + min + " " + labelTh; } else if (min == null && max != null) { valueTh = valueTh + "< " + max + " " + labelTh; } } else if (t.getThresholdType().equalsIgnoreCase("MINIMUM")) { valueTh = valueTh + "< " + min + " " + labelTh; } else if (t.getThresholdType().equalsIgnoreCase("MAXIMUM")) { valueTh = valueTh + "> " + max + " " + labelTh; } if (valueTh.length() > 25) valueTh = valueTh.substring(0, 24); threshValue.setAttribute("reportElement.y", new Integer(yValue.intValue() + 7).toString()); SourceBean threshValue2 = (SourceBean) threshValue.getAttribute("text"); threshValue2.setCharacters(valueTh); } } //Sets the bullet chart and or the threshold image if (options.getDisplay_bullet_chart() && options.getDisplay_threshold_image()) { //both threshold image and bullet chart have to be seen if (kpiValue != null && kpiValue.getValue() != null && kpiValue.getThresholdValues() != null && !kpiValue.getThresholdValues().isEmpty()) { List thresholdValues = kpiValue.getThresholdValues(); // String chartType = value.getChartType(); String chartType = "BulletGraph"; Double val = new Double(kpiValue.getValue()); Double target = kpiValue.getTarget(); ChartImpl sbi = ChartImpl.createChart(chartType); sbi.setValueDataSet(val); if (target != null) { sbi.setTarget(target); } sbi.setShowAxis(options.getShow_axis()); sbi.setThresholdValues(thresholdValues); JFreeChart chart = sbi.createChart(); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); String requestIdentity = null; UUIDGenerator uuidGen = UUIDGenerator.getInstance(); UUID uuid = uuidGen.generateTimeBasedUUID(); requestIdentity = uuid.toString(); requestIdentity = requestIdentity.replaceAll("-", ""); String path_param = requestIdentity; String dir = System.getProperty("java.io.tmpdir"); String path = dir + "/" + requestIdentity + ".png"; java.io.File file1 = new java.io.File(path); logger.debug("Where is the image: " + path); try { ChartUtilities.saveChartAsPNG(file1, chart, 89, 11, info); } catch (IOException e) { e.printStackTrace(); logger.error("Error in saving chart", e); } String urlPng = GeneralUtilities.getSpagoBiHost() + GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() + "?ACTION_NAME=GET_PNG2&NEW_SESSION=TRUE&path=" + path_param + "&LIGHT_NAVIGATOR_DISABLED=TRUE"; urlPng = "new java.net.URL(\"" + urlPng + "\")"; logger.debug("Image url: " + urlPng); image1.setAttribute("reportElement.y", yValue.toString()); image1.setAttribute("reportElement.x", new Integer(310).toString()); image1.setAttribute("reportElement.width", 90); SourceBean imageValue = (SourceBean) image1.getAttribute("imageExpression"); imageValue.setCharacters(urlPng); } ThresholdValue tOfVal = line.getThresholdOfValue(); if (tOfVal != null && tOfVal.getPosition() != null && tOfVal.getThresholdCode() != null) { String fileName = "position_" + tOfVal.getPosition().intValue(); String dirName = tOfVal.getThresholdCode(); String urlPng = GeneralUtilities.getSpagoBiHost() + GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() + "?ACTION_NAME=GET_THR_IMAGE&NEW_SESSION=TRUE&fileName=" + fileName + "&dirName=" + dirName + "&LIGHT_NAVIGATOR_DISABLED=TRUE"; urlPng = "new java.net.URL(\"" + urlPng + "\")"; logger.debug("url: " + urlPng); extraimageToAdd = new SourceBean(image); extraimageToAdd.setAttribute("reportElement.y", yValue.toString()); extraimageToAdd.setAttribute("reportElement.width", 35); extraimageToAdd.setAttribute("reportElement.x", new Integer(408).toString()); SourceBean imageValue = (SourceBean) extraimageToAdd.getAttribute("imageExpression"); imageValue.setCharacters(urlPng); } } else if (options.getDisplay_bullet_chart() && !options.getDisplay_threshold_image()) { //only bullet chart has to be seen if (kpiValue != null && kpiValue.getValue() != null && kpiValue.getThresholdValues() != null && !kpiValue.getThresholdValues().isEmpty()) { List thresholdValues = kpiValue.getThresholdValues(); // String chartType = value.getChartType(); String chartType = "BulletGraph"; Double val = new Double(kpiValue.getValue()); Double target = kpiValue.getTarget(); ChartImpl sbi = ChartImpl.createChart(chartType); sbi.setValueDataSet(val); if (target != null) { sbi.setTarget(target); } sbi.setShowAxis(options.getShow_axis()); sbi.setThresholdValues(thresholdValues); JFreeChart chart = sbi.createChart(); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); String requestIdentity = null; UUIDGenerator uuidGen = UUIDGenerator.getInstance(); UUID uuid = uuidGen.generateTimeBasedUUID(); requestIdentity = uuid.toString(); requestIdentity = requestIdentity.replaceAll("-", ""); String path_param = requestIdentity; String dir = System.getProperty("java.io.tmpdir"); String path = dir + "/" + requestIdentity + ".png"; java.io.File file1 = new java.io.File(path); logger.debug("Where is the image: " + path); try { ChartUtilities.saveChartAsPNG(file1, chart, 130, 11, info); } catch (IOException e) { e.printStackTrace(); logger.error("Error in saving chart", e); } String urlPng = GeneralUtilities.getSpagoBiHost() + GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() + "?ACTION_NAME=GET_PNG2&NEW_SESSION=TRUE&path=" + path_param + "&LIGHT_NAVIGATOR_DISABLED=TRUE"; urlPng = "new java.net.URL(\"" + urlPng + "\")"; logger.debug("Image url: " + urlPng); image1.setAttribute("reportElement.y", yValue.toString()); SourceBean imageValue = (SourceBean) image1.getAttribute("imageExpression"); imageValue.setCharacters(urlPng); } } else if (!options.getDisplay_bullet_chart() && options.getDisplay_threshold_image()) { //only threshold image has to be seen ThresholdValue tOfVal = line.getThresholdOfValue(); if (tOfVal != null && tOfVal.getPosition() != null && tOfVal.getThresholdCode() != null) { String fileName = "position_" + tOfVal.getPosition().intValue(); String dirName = tOfVal.getThresholdCode(); String urlPng = GeneralUtilities.getSpagoBiHost() + GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() + "?ACTION_NAME=GET_THR_IMAGE&NEW_SESSION=TRUE&fileName=" + fileName + "&dirName=" + dirName + "&LIGHT_NAVIGATOR_DISABLED=TRUE"; urlPng = "new java.net.URL(\"" + urlPng + "\")"; logger.debug("url: " + urlPng); image1.setAttribute("reportElement.y", yValue.toString()); SourceBean imageValue = (SourceBean) image1.getAttribute("imageExpression"); imageValue.setCharacters(urlPng); } } separatorline.setAttribute("reportElement.y", new Integer(yValue.intValue() + 16).toString()); } catch (SourceBeanException e) { logger.error("error in drawing the line", e); e.printStackTrace(); } logger.debug("OUT"); return extraimageToAdd; }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
public cfTagReturnType render(cfSession _Session) throws cfmRunTimeException { if ((storage == DB) && (!storageDBInit)) initDBStorage(_Session);//from w w w. ja v a 2 s. c om try { JFreeChart chart = null; cfTag defaultChartTag = setDefaultParameters(_Session); // --[ Get the FORMAT property out byte format; String formatStr = getDynamic(_Session, "FORMAT").toString().toLowerCase(); if (formatStr.equals("jpg")) { format = FORMAT_JPG; } else if (formatStr.equals("png")) { format = FORMAT_PNG; } else { throw newBadFileException("Invalid FORMAT Attribute", "Only the jpg and png formats are supported."); } if (getConstant("STYLE") != null) throw newBadFileException("Attribute not supported", "The STYLE attribute is not supported. Use the DEFAULT attribute instead"); int height = getDynamic(_Session, "CHARTHEIGHT").getInt(); int width = getDynamic(_Session, "CHARTWIDTH").getInt(); String xAxisType = getDynamic(_Session, "XAXISTYPE").toString().toLowerCase(); cfCHARTInternalData data = new cfCHARTInternalData(xAxisType, defaultChartTag); _Session.setDataBin(DATA_BIN_KEY, data); // Render the CFCHARTSERIES tags renderToString(_Session); // Get the chart series List<cfCHARTSERIESData> series = data.getSeries(); if (series.size() == 0) throw newRunTimeException("You must specify at least one series"); String tipStyle = getDynamic(_Session, "TIPSTYLE").toString().toLowerCase(); String drillDownUrl = null; if (containsAttribute("URL")) drillDownUrl = getDynamic(_Session, "URL").toString(); String name = null; if (containsAttribute("NAME")) name = getDynamic(_Session, "NAME").toString(); // Check if this is a Pie or Ring chart boolean isPieOrRingChart = false; if (series.size() == 1) { cfCHARTSERIESData seriesData = series.get(0); if (seriesData.getType().equals("pie") || seriesData.getType().equals("ring")) { // Render the pie or ring chart chart = renderPieChart(_Session, data, series, tipStyle, drillDownUrl); isPieOrRingChart = true; } } if (!isPieOrRingChart) { // This must be a category chart so make sure none of the series are set // to Pie or Ring type // Also, if show3D is true then make sure there are only bar, line and // horizontalbar types boolean bShow3D = getDynamic(_Session, "SHOW3D").getBoolean(); String seriesPlacement = getDynamic(_Session, "SERIESPLACEMENT").toString().toLowerCase(); if (!seriesPlacement.equals("default") && !seriesPlacement.equals("cluster") && !seriesPlacement.equals("stacked") && !seriesPlacement.equals("percent")) throw newRunTimeException( "The seriesPlacement value '" + seriesPlacement + "' is not supported"); if (bShow3D && seriesPlacement.equals("percent")) throw newRunTimeException( "The seriesPlacement value '" + seriesPlacement + "' is not supported in 3D charts"); boolean bCluster = true; if (seriesPlacement.equals("stacked") || seriesPlacement.equals("percent")) bCluster = false; if (series.size() > 1) { for (int i = 0; i < series.size(); i++) { cfCHARTSERIESData seriesData = series.get(i); if (seriesData.getType().equals("pie") || seriesData.getType().equals("ring")) throw newRunTimeException( "A chart can only have 1 series when a pie or ring series is specified"); if (bShow3D && !seriesData.getType().equals("bar") && !seriesData.getType().equals("line") && !seriesData.getType().equals("horizontalbar")) throw newRunTimeException( "Only bar, line, horizontal bar and pie charts can be displayed in 3D"); if (!bCluster && !seriesData.getType().equals("bar") && !seriesData.getType().equals("horizontalbar")) throw newRunTimeException("The seriesPlacement value '" + seriesPlacement + "' is only supported in bar and horizontal bar charts"); } } int seriesDataType = series.get(0).getSeriesDataType(); // Render the scale(xy) or category chart // This is overriding the type from the cfchart variable as it is // determined // by the series data. if (seriesDataType == cfCHARTSERIESData.CATEGORY_SERIES) { chart = renderCategoryChart(_Session, data, tipStyle, drillDownUrl, seriesPlacement, height); } else { chart = renderXYChart(_Session, data, tipStyle, drillDownUrl, seriesPlacement, height); } } // Output the chart try { ChartRenderingInfo info = null; if ((drillDownUrl != null) || (!tipStyle.equals("none"))) info = new ChartRenderingInfo(new StandardEntityCollection()); if (name != null) { // Generate the chart and save the contents in the name variable byte[] chartBytes = generateChart(chart, format, width, height, info); _Session.setData(name, new cfBinaryData(chartBytes)); } else { // Return the chart to the browser String path = null; if (containsAttribute("PATH")) path = getDynamic(_Session, "PATH").toString(); String filename = saveChart(_Session, chart, format, width, height, info); String chartUrl = generateChartUrl(_Session, filename, path); if (info == null) { _Session.write("<img src=\"" + chartUrl + "\" width=\"" + width + "\" height=\"" + height + "\" />"); } else { ImageMapUtilities.writeImageMap(_Session.RES.getWriter(), filename, info); _Session.write("<img src=\"" + chartUrl + "\" width=\"" + width + "\" height=\"" + height + "\" usemap=\"#" + filename + "\" border=\"0\"/>"); } } } catch (IOException ioe) { throw newRunTimeException("Failed to generate chart - " + ioe.toString()); } } finally { _Session.deleteDataBin(DATA_BIN_KEY); } return cfTagReturnType.NORMAL; }