Java Code Examples for org.jfree.chart.ChartFactory#createPieChart()
The following examples show how to use
org.jfree.chart.ChartFactory#createPieChart() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PiePlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Draws a pie chart where the label generator returns null. */ @Test public void testDrawWithNullLegendLabels() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("L1", 12.0); dataset.setValue("L2", 11.0); JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true, false, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLegendLabelGenerator(new NullLegendLabelGenerator()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 2
Source File: SWTPieChartDemo1.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
Example 3
Source File: PieChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a pie chart. * * @return The pie chart. */ private static JFreeChart createPieChart() { // create a dataset... DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Java", new Double(43.2)); data.setValue("Visual Basic", new Double(0.0)); data.setValue("C/C++", new Double(17.5)); // create the chart... return ChartFactory.createPieChart("Pie Chart", // chart title data, // data true, // include legend true, false ); }
Example 4
Source File: PieChartDemo1.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); plot.setNoDataMessage("No data available"); plot.setSimpleLabels(true); return chart; }
Example 5
Source File: SWTPieChartDemo1.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
Example 6
Source File: PiePlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Draws a pie chart where the label generator returns null. */ @Test public void testDrawWithNullLegendLabels() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("L1", 12.0); dataset.setValue("L2", 11.0); JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true, false, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLegendLabelGenerator(new NullLegendLabelGenerator()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 7
Source File: PiePlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Draws a pie chart where the label generator returns null. */ @Test public void testDrawWithNullLegendLabels() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("L1", 12.0); dataset.setValue("L2", 11.0); JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true, false, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLegendLabelGenerator(new NullLegendLabelGenerator()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 8
Source File: PieChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a pie chart. * * @return The pie chart. */ private static JFreeChart createPieChart() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Java", new Double(43.2)); dataset.setValue("Visual Basic", new Double(0.0)); dataset.setValue("C/C++", new Double(17.5)); return ChartFactory.createPieChart("Pie Chart", dataset, true); }
Example 9
Source File: JFreeChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Common test setup. */ protected void setUp() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Java", new Double(43.2)); dataset.setValue("Visual Basic", new Double(0.0)); dataset.setValue("C/C++", new Double(17.5)); this.pieChart = ChartFactory.createPieChart("Pie Chart", dataset, true); }
Example 10
Source File: JFreeChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the default legend firing change events. */ public void testLegendEvents() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true); chart.addChangeListener(this); this.lastChartChangeEvent = null; LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.TOP); assertNotNull(this.lastChartChangeEvent); }
Example 11
Source File: JFreeChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for title changes and event notification. */ public void testTitleChangeEvent() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true); chart.addChangeListener(this); this.lastChartChangeEvent = null; TextTitle t = chart.getTitle(); t.setFont(new Font("Dialog", Font.BOLD, 9)); assertNotNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; // now create a new title and replace the existing title, several // things should happen: // (1) Adding the new title should trigger an immediate // ChartChangeEvent; // (2) Modifying the new title should trigger a ChartChangeEvent; // (3) Modifying the old title should NOT trigger a ChartChangeEvent TextTitle t2 = new TextTitle("T2"); chart.setTitle(t2); assertNotNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; t2.setFont(new Font("Dialog", Font.BOLD, 9)); assertNotNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; t.setFont(new Font("Dialog", Font.BOLD, 9)); assertNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; }
Example 12
Source File: StatsGraphServlet.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * Generate disk statistics */ public JFreeChart diskStats() throws IOException, ServletException { String repHome = null; // Allow absolute repository path if ((new File(Config.REPOSITORY_HOME)).isAbsolute()) { repHome = Config.REPOSITORY_HOME; } else { repHome = Config.HOME_DIR + File.separator + Config.REPOSITORY_HOME; } File df = new File(repHome); long total = df.getTotalSpace(); long usable = df.getUsableSpace(); long used = total - usable; String title = "Disk: " + FormatUtil.formatSize(total); log.debug("Total space: {}", FormatUtil.formatSize(total)); log.debug("Usable space: {}", FormatUtil.formatSize(usable)); log.debug("Used space: {}", FormatUtil.formatSize(used)); DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Available (" + FormatUtil.formatSize(usable) + ")", usable * 100 / total); dataset.setValue("Used (" + FormatUtil.formatSize(used) + ")", used * 100 / total); return ChartFactory.createPieChart(title, dataset, true, false, false); }
Example 13
Source File: JFreeChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the getSubtitles() method. */ public void testGetSubtitles() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true); List subtitles = chart.getSubtitles(); assertEquals(1, chart.getSubtitleCount()); // adding something to the returned list should NOT change the chart subtitles.add(new TextTitle("T")); assertEquals(1, chart.getSubtitleCount()); }
Example 14
Source File: StatsGraphServlet.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * Generate memory statistics * http://casidiablo.net/capturar-informacion-sistema-operativo-java/ */ public JFreeChart osMemStats() throws IOException, ServletException { DefaultPieDataset dataset = new DefaultPieDataset(); Sigar sigar = new Sigar(); String title = null; try { Mem mem = sigar.getMem(); long max = mem.getRam(); long available = mem.getFree(); long total = mem.getTotal(); long used = mem.getUsed(); long free = mem.getFree(); title = "OS memory: " + FormatUtil.formatSize(total); log.debug("OS maximun memory: {}", FormatUtil.formatSize(max)); log.debug("OS available memory: {}", FormatUtil.formatSize(available)); log.debug("OS free memory: {}", FormatUtil.formatSize(free)); log.debug("OS used memory: {}", FormatUtil.formatSize(used)); log.debug("OS total memory: {}", FormatUtil.formatSize(total)); dataset.setValue("Available (" + FormatUtil.formatSize(free) + ")", free * 100 / total); dataset.setValue("Used (" + FormatUtil.formatSize(used) + ")", used * 100 / total); } catch (SigarException se) { title = "OS memory: " + se.getMessage(); } catch (UnsatisfiedLinkError ule) { title = "OS memory: (missing native libraries)"; } return ChartFactory.createPieChart(title, dataset, true, false, false); }
Example 15
Source File: PieChartFXDemo1.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", dataset); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setDefaultSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
Example 16
Source File: PieChartDemo1.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
Example 17
Source File: PieChartFXDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
Example 18
Source File: MinimapPanel.java From dsworkbench with Apache License 2.0 | 4 votes |
private void renderChartInfo() { HashMap<Object, Marker> marks = new HashMap<>(); DefaultPieDataset dataset = buildDataset(marks); JFreeChart chart = ChartFactory.createPieChart( null, // chart title dataset, // data true, // include legend true, false); chart.setBackgroundPaint(null); //chart.setBorderStroke(null); chart.setBorderVisible(false); final PiePlot plot = (PiePlot) chart.getPlot(); // plot.setBackgroundPaint(null); // plot.setShadowPaint(null); for(Object o: marks.keySet()) { if (iCurrentView == ID_ALLY_CHART) { Ally a = (Ally) o; plot.setSectionPaint(a.getTag(), marks.get(a).getMarkerColor()); } else { Tribe t = (Tribe) o; plot.setSectionPaint(t.getName(), marks.get(t).getMarkerColor()); } } //plot.setCircular(true); // plot.setMaximumLabelWidth(30.0); /* * plot.setLabelGenerator(new StandardPieSectionLabelGenerator( "{0} = {2}", NumberFormat.getNumberInstance(), * NumberFormat.getPercentInstance())); */ // chart.getLegend().setVerticalAlignment(VerticalAlignment.CENTER); // chart.getLegend().setPosition(RectangleEdge.RIGHT); // plot.setMaximumLabelWidth(20.0); plot.setLabelGenerator(null); plot.setBackgroundPaint(Constants.DS_BACK); /* * plot.setInteriorGap(0.0); plot.setLabelGap(0.0); */ plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( "{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); /* * plot.getL plot.setLabelFont(g2d.getFont().deriveFont(10.0f)); */ //plot.setLabelGenerator(null); //plot.setMaximumLabelWidth(30.0); //plot.getLabelDistributor().distributeLabels(10.0, 20.0); //chart.draw(g2d, new Rectangle2D.Float(20, 20, 100, 100)); // g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); plot.setOutlineVisible(false); mChartImage = chart.createBufferedImage(getWidth(), getHeight()); //chart.draw(g2d, new Rectangle2D.Float(50, 50, 400, 400)); //g2d.drawImage(bi, 30, 30, null); // g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); //bi = chart.createBufferedImage(240, 240); // g2d.drawImage(bi, 30, 30, null); }
Example 19
Source File: PieChartFXDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
Example 20
Source File: PieChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }