List of usage examples for org.jfree.chart.plot PiePlot setLabelFont
public void setLabelFont(Font font)
From source file:com.netsteadfast.greenstep.action.CommonPieChartAction.java
private void fillChart(String title, List<String> names, List<String> colors, List<Float> values) throws Exception { DefaultPieDataset data = new DefaultPieDataset(); for (int ix = 0; ix < names.size(); ix++) { data.setValue(names.get(ix), values.get(ix)); }/* www . j a v a 2 s. c o m*/ this.chart = ChartFactory.createPieChart3D(title, data, true, true, false); LegendTitle legend = this.chart.getLegend(); legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9)); PiePlot plot = (PiePlot) this.chart.getPlot(); plot.setCircular(true); plot.setBackgroundAlpha(0.9f); plot.setForegroundAlpha(0.5f); plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9)); this.setPlotColor(plot, names, colors); this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9))); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.SimplePie.java
public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); JFreeChart chart = null;/*w w w . j a va 2s .com*/ if (!threeD) { chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data legend, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } else { chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data true, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDarkerSides(true); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(1.0f); plot.setDepthFactor(0.2); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); // plot.setNoDataMessages("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreePieChartData.java
@Override public JFreeChart getJFreeChart() { DefaultPieDataset pieDataset = makeDataSet(); JFreeChart chart = ChartFactory.createPieChart(title, // Title pieDataset, // Dataset true // Show legend , false, false);/*from w w w. jav a 2 s. c om*/ PiePlot plot = (PiePlot) chart.getPlot(); StandardPieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0} ({2})"); plot.setLabelGenerator(gen); plot.setMaximumLabelWidth(0.07); plot.setLabelFont(plot.getLabelFont().deriveFont(9.0F)); LegendTitle leg = chart.getLegend(); leg.setPosition(RectangleEdge.RIGHT); if (!colours.isEmpty()) { String legends[] = ds.getLegends(); for (int i = 0; i < ds.getNumSets(); i++) { if (legends != null && legends.length > i && colours.size() > i) { Color c = colours.get(i); plot.setSectionPaint(legends[i], c); } } } return chart; }
From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java
/** * @param list/* ww w . j a va 2s.co m*/ * @param title * @param xAxisTitle * @param yAxisTitle * @param isVertical * @param width * @param height */ public JFreeChart createPieChart(final List<Object> list, final String title, final int width, final int height, final boolean do3D) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < list.size(); i++) { Object descObj = list.get(i++); Object valObj = list.get(i); dataset.setValue(getString(descObj), getInt(valObj)); } String adjTitle = title; JFreeChart chart = do3D ? ChartFactory.createPieChart3D(adjTitle, dataset, false, false, false) : ChartFactory.createPieChart(adjTitle, dataset, false, false, false); chart.setBackgroundPaint(new Color(0, 0, 0, 0)); // transparent black PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); //$NON-NLS-1$ plot.setBackgroundPaint(new Color(0, 0, 0, 0)); // transparent black plot.setOutlinePaint(null); setColors(plot, dataset); return chart; }
From source file:org.gephi.desktop.context.ContextPieChart.java
public ContextPieChart() { data = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null);/*from www . j a va 2 s. c om*/ chart.setPadding(new RectangleInsets(0, 0, 0, 0)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.WHITE); plot.setLabelGap(0.5); plot.setCircular(true); plot.setInteriorGap(0); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222)); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD)); chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false); ((FlowLayout) chartPanel.getLayout()).setHgap(0); ((FlowLayout) chartPanel.getLayout()).setVgap(0); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.PieChartRenderer.java
public void createChart() { PieDataset dataset = (PieDataset) this.datasetStrategy.getDataset(); report = ChartFactory.createPieChart(this.datasetStrategy.getTitle(), dataset, true, true, false); PiePlot plot = (PiePlot) report.getPlot(); // plot.setCircular( false ); plot.setDirection(Rotation.ANTICLOCKWISE); /*// ww w . j a v a 2 s.co m * plot.setExplodePercent(0, 0.15D); plot.setExplodePercent(1, 0.15D); */ // plot.setInteriorGap( PieChartRenderer.INTERIOR_GAP ); plot.setLabelFont(new Font("Lucida", 0, PieChartRenderer.FONT_SIZE)); plot.setLabelGap(PieChartRenderer.LABEL_GAP); plot.setNoDataMessage("No data available"); plot.setStartAngle(PieChartRenderer.START_ANGLE); Paint[] paints = this.datasetStrategy.getPaintColor(); for (int i = 0; i < dataset.getItemCount() && i < paints.length; i++) { plot.setSectionPaint(dataset.getKey(i), paints[i]); } }
From source file:org.gephi.desktop.partition.PartitionPie.java
public void setup(Partition partition) { data = new DefaultPieDataset(); for (Part p : partition.getParts()) { data.setValue(p.getDisplayName(), p.getPercentage()); }/*w w w .j av a 2 s . com*/ final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); //plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.BLACK); //plot.setLabelGap(0.05); plot.setCircular(true); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); for (Part p : partition.getParts()) { plot.setSectionPaint(p.getDisplayName(), p.getColor()); } chartPanel = new ChartPanel(chart, true); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); add(chartPanel, BorderLayout.CENTER); }
From source file:org.jfree.chart.demo.MultiplePieChartDemo2.java
/** * Creates a sample chart with the given dataset. * /*from w ww . jav a 2 s .com*/ * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title dataset, // dataset TableOrder.BY_COLUMN, true, // include legend true, false); final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setOutlineStroke(new BasicStroke(1.0f)); final JFreeChart subchart = plot.getPieChart(); final PiePlot p = (PiePlot) subchart.getPlot(); p.setBackgroundPaint(null); p.setOutlineStroke(null); p.setLabelGenerator(new StandardPieItemLabelGenerator("{0} ({2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); p.setMaximumLabelWidth(0.35); p.setLabelFont(new Font("SansSerif", Font.PLAIN, 9)); p.setInteriorGap(0.30); return chart; }
From source file:probe.com.view.body.quantcompare.PieChart.java
private String initPieChart(int width, int height, String title) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int x = 0; x < labels.length; x++) { dataset.setValue(labels[x], values[x]); }/*w ww. j a v a 2 s .c om*/ PiePlot plot = new PiePlot(dataset); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0); plot.setLabelFont(new Font("Verdana", Font.BOLD, 10)); plot.setLabelGenerator(new PieSectionLabelGenerator() { @Override public String generateSectionLabel(PieDataset pd, Comparable cmprbl) { return valuesMap.get(cmprbl.toString()); } @Override public AttributedString generateAttributedSectionLabel(PieDataset pd, Comparable cmprbl) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelShadowPaint(null); plot.setLabelPaint(Color.WHITE); plot.setLabelOutlinePaint(null); plot.setBackgroundPaint(Color.WHITE); plot.setInteriorGap(0); plot.setShadowPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f)); plot.setInteriorGap(0.05); for (String label : labels) { plot.setSectionPaint(label, defaultKeyColorMap.get(label)); } JFreeChart chart = new JFreeChart(plot); // chart.setTitle(new TextTitle(title, new Font("Verdana", Font.BOLD, 13))); chart.setBorderPaint(null); chart.setBackgroundPaint(null); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setItemFont(new Font("Verdana", Font.PLAIN, 10)); String imgUrl = saveToFile(chart, width, height); return imgUrl; }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java
/** * Creates a chart/*from w ww . j av a 2 s .c o m*/ * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title dataset, // data !legendPanelOn, // include legend true, false); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); for (int i = 0; i < pulloutFlag.length; i++) { //System.out.println("\""+pulloutFlag[i]+"\""); if (isPullout(i)) { Comparable key = dataset.getKey(i); plot.setExplodePercent(key, 0.30); } } plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); setCategorySummary(dataset); if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } return chart; }