Java Code Examples for org.jfree.chart.plot.PiePlot#setLabelBackgroundPaint()
The following examples show how to use
org.jfree.chart.plot.PiePlot#setLabelBackgroundPaint() .
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: GraphStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Crée le graphe JFreeChart. * * @param piedataset * : la source de données à afficher * @return le diagramme */ private JFreeChart createChart(GraphPieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false); jfreechart.setAntiAlias(true); jfreechart.setTextAntiAlias(true); PiePlot pieplot3d = (PiePlot) jfreechart.getPlot(); pieplot3d.setInsets(new RectangleInsets(0, 0, 0, 0)); final double angle = 290D; pieplot3d.setStartAngle(angle); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foreground = 0.5F; pieplot3d.setForegroundAlpha(foreground); pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay); pieplot3d.setCircular(true); pieplot3d.setOutlinePaint(null); pieplot3d.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); pieplot3d.setLabelGap(0.02); pieplot3d.setLabelOutlinePaint(null); pieplot3d.setLabelShadowPaint(null); pieplot3d.setLabelBackgroundPaint(Color.WHITE); pieplot3d.setBackgroundPaint(Color.WHITE); // avoid showing the percentage as an absolute number in the tooltip pieplot3d.setToolTipGenerator(new StandardPieToolTipGenerator("{0}: {2}")); pieplot3d.setInteriorGap(0.02); pieplot3d.setMaximumLabelWidth(0.20); return jfreechart; }
Example 2
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected JFreeChart createPieChart() throws JRException { JFreeChart jfreeChart = super.createPieChart(); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels && piePlot.getLabelGenerator() != null) { piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); } piePlot.setShadowXOffset(5); piePlot.setShadowYOffset(10); piePlot.setShadowPaint(new GradientPaint(0, getChart().getHeight() / 2, new Color(41, 120, 162), 0, getChart().getHeight(), Color.white)); PieDataset pieDataset = piePlot.getDataset(); if (pieDataset != null) { for (int i = 0; i < pieDataset.getItemCount(); i++) { piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT); //makes pie colors darker //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]); } } piePlot.setCircular(true); return jfreeChart; }
Example 3
Source File: AegeanChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected JFreeChart createPieChart() throws JRException { JFreeChart jfreeChart = super.createPieChart(); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if(isShowLabels && piePlot.getLabelGenerator() != null) { piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); } piePlot.setShadowXOffset(0); piePlot.setShadowYOffset(0); PieDataset pieDataset = piePlot.getDataset(); if(pieDataset != null) { for(int i = 0; i < pieDataset.getItemCount(); i++) { piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT); //makes pie colors darker //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]); } } piePlot.setCircular(true); return jfreeChart; }
Example 4
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; }
Example 5
Source File: PieChartFXDemo1.java From openstock 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 6
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 7
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; }
Example 8
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 9
Source File: PieChartDemo1.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 10
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 11
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 12
Source File: PieChartFXDemo1.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 13
Source File: SimpleChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected JFreeChart createPieChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset)getDataset(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular(); piePlot.setCircular(isCircular); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator(); JRItemLabel itemLabel = jrPiePlot.getItemLabel(); if (labelGenerator != null) { piePlot.setLabelGenerator(labelGenerator); } else if (jrPiePlot.getLabelFormat() != null) { piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())) ); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } if (itemLabel != null && itemLabel.getFont() != null) { piePlot.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale())); } else { piePlot.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale())); } if (itemLabel != null && itemLabel.getColor() != null) { piePlot.setLabelPaint(itemLabel.getColor()); } else { piePlot.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot.setLabelGenerator(null); } if (jrPiePlot.getLegendLabelFormat() != null) { piePlot.setLegendLabelGenerator( new StandardPieSectionLabelGenerator(((JRPiePlot)getPlot()).getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())) ); } return jfreeChart; }
Example 14
Source File: GenericChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected JFreeChart createPieChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset)getDataset(), isShowLegend(), true, false ); configureChart(jfreeChart, getPlot()); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular(); piePlot.setCircular(isCircular); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator(); JRItemLabel itemLabel = jrPiePlot.getItemLabel(); if (labelGenerator != null) { piePlot.setLabelGenerator(labelGenerator); } else if (jrPiePlot.getLabelFormat() != null) { piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())) ); } // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // // } Integer baseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null; piePlot.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize)); if (itemLabel != null && itemLabel.getColor() != null) { piePlot.setLabelPaint(itemLabel.getColor()); } else { piePlot.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot.setLabelGenerator(null); } if (jrPiePlot.getLegendLabelFormat() != null) { piePlot.setLegendLabelGenerator( new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())) ); } return jfreeChart; }
Example 15
Source File: DefaultChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected JFreeChart createPieChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createPieChart( evaluateTextExpression(getChart().getTitleExpression()), (PieDataset)getDataset(), isShowLegend(), true, false ); configureChart(jfreeChart); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); //plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); //plot.setNoDataMessage("No data to display"); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular(); piePlot.setCircular(isCircular); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels) { PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator(); JRItemLabel itemLabel = jrPiePlot.getItemLabel(); if (labelGenerator != null) { piePlot.setLabelGenerator(labelGenerator); } else if (jrPiePlot.getLabelFormat() != null) { piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())) ); }// the default section label is just the key, so there's no need to set localized number formats // else if (itemLabel != null && itemLabel.getMask() != null) // { // piePlot.setLabelGenerator( // new StandardPieSectionLabelGenerator(itemLabel.getMask()) // ); // } piePlot.setLabelFont( fontUtil.getAwtFont( getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale() ) ); if (itemLabel != null && itemLabel.getColor() != null) { piePlot.setLabelPaint(itemLabel.getColor()); } else { piePlot.setLabelPaint(getChart().getForecolor()); } if (itemLabel != null && itemLabel.getBackgroundColor() != null) { piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor()); } else { piePlot.setLabelBackgroundPaint(getChart().getBackcolor()); } } else { piePlot.setLabelGenerator(null); } if (jrPiePlot.getLegendLabelFormat() != null) { piePlot.setLegendLabelGenerator( new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())) ); }// the default legend label is just the key, so there's no need to set localized number formats return jfreeChart; }
Example 16
Source File: PieChartDemo1.java From ccu-historian 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 17
Source File: PieChartFXDemo1.java From ccu-historian 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: 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 19
Source File: PieChartDemo1.java From openstock 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; }