List of usage examples for org.jfree.chart.plot PiePlot setLabelGenerator
public void setLabelGenerator(PieSectionLabelGenerator generator)
From source file:com.qspin.qtaste.reporter.testresults.html.HTMLReportFormatter.java
private void generatePieChart() { if (currentTestSuite == null) { return;/*from w w w. j a v a2 s .co 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.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Creates a Pie Chart based on map.//from w w w . j av a 2s . com * * @return the Pie Chart generated. */ public JFreeChart getPieChart(Map<String, Double> pieValues) { DefaultPieDataset dataset = new DefaultPieDataset(); for (String key : pieValues.keySet()) { dataset.setValue(key, pieValues.get(key)); } JFreeChart chart = ChartFactory.createPieChart3D(null, // chart title dataset, // data true, // include legend true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(false); chart.setBorderPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); plot.setOutlinePaint(null); plot.setLabelLinksVisible(false); plot.setLabelGenerator(null); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.33); return chart; }
From source file:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java
/** * Creates the impact Pie Chart page. It allows users to select a Crosscutting Concern and see Design Decision type distribution *//* ww w .ja v a2 s . c om*/ void impactPieChartPage() { ddDataset = new DefaultPieDataset(); impactDataset = new DefaultPieDataset(); JFreeChart ddChart = ChartFactory.createPieChart("Crosscutting Concerns", ddDataset, true, true, false); JFreeChart impactChart = ChartFactory.createPieChart("Design Decisions", impactDataset, true, true, false); PiePlot ddPlot = (PiePlot) ddChart.getPlot(); ddPlot.setStartAngle(290); ddPlot.setDirection(Rotation.CLOCKWISE); ddPlot.setForegroundAlpha(0.5f); PiePlot impactPlot = (PiePlot) impactChart.getPlot(); impactPlot.setStartAngle(290); impactPlot.setDirection(Rotation.CLOCKWISE); impactPlot.setForegroundAlpha(0.5f); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0} ({2})"); ddPlot.setLabelGenerator(gen); impactPlot.setLabelGenerator(gen); Composite composite = new Composite(getContainer(), SWT.NONE); FillLayout layout = new FillLayout(); composite.setLayout(layout); final ChartComposite cComposite = new ChartComposite(composite, SWT.NONE, ddChart, true); cComposite.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent event) { String[] parts = event.getEntity().getToolTipText().split(":"); HashMap<String, Integer> values = PluginUtil.getDDDistributionForCrossCuttingConcern(cp, parts[0]); logger.info("Impact Pie Chart for: " + parts[0]); impactDataset.clear(); for (String key : values.keySet()) { impactDataset.setValue(key, values.get(key)); } } @Override public void chartMouseMoved(ChartMouseEvent event) { } }); new ChartComposite(composite, SWT.NONE, impactChart, true); int index = addPage(composite); setPageText(index, "Graph"); }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getNoChapterPie() { JFreeChart chart;//from ww w . j av a 2 s . c om DefaultPieDataset ds = new DefaultPieDataset(); Integer numChapter = Helpers.getGroup("Chapter").getNumMembers(); ds.setValue("in a chapter", numChapter); ds.setValue("not in a chapter", Helpers.getGroup("Org").getNumMembers() - numChapter); chart = ChartFactory.createPieChart("Chapter Membership Breakdown", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getRankPie() { JFreeChart chart;/*from ww w. j a v a2 s . c o m*/ DefaultPieDataset ds = new DefaultPieDataset(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); int numUsers = Helpers.getGroup("Org").getNumMembers(); ds.setValue("Regular Members", numRegular); ds.setValue("Associate Members", numAssociate); ds.setValue("Mailing list Members", numUsers - numAssociate - numRegular); chart = ChartFactory.createPieChart("Status breakdown for " + numUsers + " members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getProvincePie(Session s) { JFreeChart chart;/*from w w w.j av a 2 s. com*/ String[] provinces = { "PE", "YT", "NT", "NU", "ON", "QC", "AB", "BC", "NL", "MB", "NB", "NS", "SK" }; DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.province=?"; int total = 0; for (String province : provinces) { Integer integer = ((Long) s.createQuery(query).setString(0, province).list().get(0)).intValue(); total += integer; ds.setValue(province, integer); } chart = ChartFactory.createPieChart("Province Breakdown (for " + total + " known addresses)", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getLanguagePie(Session s) { JFreeChart chart;/*from w ww.j a v a2 s . com*/ DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.language='en'"; int numEn = ((Long) s.createQuery(query).list().get(0)).intValue(); query = "select count(*) from UserModel as u where u.language='fr'"; int numFr = ((Long) s.createQuery(query).list().get(0)).intValue(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); ds.setValue("English", numEn); ds.setValue("Unspecified", numAssociate + numRegular - numEn - numFr); ds.setValue("French", numFr); chart = ChartFactory.createPieChart("Preferred Language Breakdown for Associate/Regular members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getGenderPie(Session s) { JFreeChart chart;// w ww . j a v a2 s . co m DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.gender='f'"; int numFemale = ((Long) s.createQuery(query).list().get(0)).intValue(); query = "select count(*) from UserModel as u where u.gender='m'"; int numMale = ((Long) s.createQuery(query).list().get(0)).intValue(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); ds.setValue("Female users", numFemale); ds.setValue("Unspecified", numAssociate + numRegular - numFemale - numMale); ds.setValue("Male users", numMale); chart = ChartFactory.createPieChart("Gender Breakdown for Associate/Regular members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getStudentPie(Session s) { JFreeChart chart;// ww w . j av a 2s.co m DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.student='y'"; int numStudent = ((Long) s.createQuery(query).list().get(0)).intValue(); query = "select count(*) from UserModel as u where u.student='n'"; int numNonStudent = ((Long) s.createQuery(query).list().get(0)).intValue(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); ds.setValue("Student users", numStudent); ds.setValue("Unspecified", numAssociate + numRegular - numStudent - numNonStudent); ds.setValue("Non-Student users", numNonStudent); chart = ChartFactory.createPieChart("Student Status Breakdown for Associate/Regular members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getChapterRankPie(Session s, String url) { String[] path = url.split("/"); String lastPiece = path[path.length - 1]; Integer chapterId = new Integer(lastPiece.substring(0, lastPiece.length() - 4)); GroupChapterModel chapter = (GroupChapterModel) s.get(GroupChapterModel.class, chapterId); JFreeChart chart;// w ww . j a v a2 s .c o m DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) as num from roles r1, roles r2 " + "where r1.userid=r2.userid and r1.groupid=? and r1.level='m' and r2.level='m' " + "and r1.end is null and r2.end is null and r2.groupid=?"; int numRegular = ((Integer) s.createSQLQuery(query).addScalar("num", Hibernate.INTEGER) .setInteger(0, chapter.getId()).setInteger(1, Helpers.getGroup("Regular").getId()).list().get(0)) .intValue(); int numAssociate = ((Integer) s.createSQLQuery(query).addScalar("num", Hibernate.INTEGER) .setInteger(0, chapter.getId()).setInteger(1, Helpers.getGroup("Associate").getId()).list().get(0)) .intValue(); int numUsers = chapter.getNumMembers(); ds.setValue("Regular Members", numRegular); ds.setValue("Associate Members", numAssociate); ds.setValue("Mailing list Members", numUsers - numAssociate - numRegular); chart = ChartFactory.createPieChart("Status breakdown for " + numUsers + " chapter members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }