List of usage examples for org.jfree.chart.plot PieLabelLinkStyle STANDARD
PieLabelLinkStyle STANDARD
To view the source code for org.jfree.chart.plot PieLabelLinkStyle STANDARD.
Click Source Link
From source file:fr.gouv.diplomatie.applitutoriel.utility.Graphique.java
/** * Creer camember3 d./*w w w.jav a 2 s . c om*/ * * @param title * the title * @param dataset * the dataset * @param legend * the legend * @param tooltips * the tooltips * @param urls * the urls * @return the j free chart * @throws FontFormatException * the font format exception * @throws IOException * Signals that an I/O exception has occurred. */ public static JFreeChart creerCamember3D(final String title, final DefaultPieDataset dataset, final boolean legend, final boolean tooltips, final boolean urls) throws FontFormatException, IOException { dataset.sortByValues(SortOrder.DESCENDING); final JFreeChart jfreeChart = ChartFactory.createPieChart3D(title, dataset, legend, tooltips, urls); jfreeChart.setBackgroundPaint(Color.white); jfreeChart.setBorderVisible(true); jfreeChart.getLegend().setPosition(RectangleEdge.LEFT); final GraphicsEnvironment graph = GraphicsEnvironment.getLocalGraphicsEnvironment(); final InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("hornet/framework/font/LiberationSans-Bold.ttf"); final Font font = Font.createFont(Font.TRUETYPE_FONT, inputStream); graph.registerFont(font); jfreeChart.getLegend().setItemFont(new Font("Liberation Sans", Font.BOLD, 11)); jfreeChart.getLegend().setHeight(400); jfreeChart.getLegend().setBorder(0, 0, 0, 0); jfreeChart.setTitle(new TextTitle(title, new Font("Liberation Sans", Font.BOLD, 16))); final PiePlot piePlot = (PiePlot) jfreeChart.getPlot(); final int nbData = dataset.getItemCount(); int cptColor = 0; for (int x = 0; x < nbData; x++) { if (cptColor >= listColor.size()) { cptColor = 0; } piePlot.setSectionPaint(dataset.getKey(x), listColor.get(cptColor)); cptColor++; } piePlot.setForegroundAlpha(0.5f); piePlot.setLabelFont(new Font("Liberation Sans", Font.BOLD, 12)); piePlot.setLabelOutlineStroke(null); piePlot.setLabelLinkStroke(new BasicStroke(0.4f)); piePlot.setLabelBackgroundPaint(Color.WHITE); piePlot.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); piePlot.setBackgroundAlpha(0); piePlot.setOutlineVisible(false); piePlot.setForegroundAlpha(1); // transparence piePlot.setInteriorGap(0); // le camembert occupe plus de place piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}")); piePlot.setStartAngle(70); piePlot.setCircular(true); // force pour avoir un cercle et pas un oval piePlot.setMaximumLabelWidth(0.20); piePlot.setBaseSectionOutlinePaint(Color.BLACK); // bordure du camembert return jfreeChart; }