Java Code Examples for org.jfree.chart.plot.PiePlot3D#setLabelBackgroundPaint()

The following examples show how to use org.jfree.chart.plot.PiePlot3D#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: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
	protected JFreeChart createPie3DChart() throws JRException
	{
		JFreeChart jfreeChart = super.createPie3DChart();

		PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
		JRPie3DPlot jrPiePlot = (JRPie3DPlot)getPlot();
		boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();
		if (isShowLabels && piePlot3D.getLabelGenerator() != null)
		{
			piePlot3D.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
			piePlot3D.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
			piePlot3D.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
		}
		piePlot3D.setDarkerSides(true);
		piePlot3D.setDepthFactor(0.1);
// does not work for 3D
//		piePlot3D.setShadowXOffset(5);
//		piePlot3D.setShadowYOffset(10);
//		piePlot3D.setShadowPaint(new GradientPaint(
//				0,
//				getChart().getHeight() / 2,
//				new Color(41, 120, 162),
//				0,
//				getChart().getHeight(),
//				Color.white)
//		);

		PieDataset pieDataset = piePlot3D.getDataset();
		if (pieDataset != null)
		{
			for (int i = 0; i < pieDataset.getItemCount(); i++)
			{
				piePlot3D.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);
			}
		}

		piePlot3D.setCircular(true);
		return jfreeChart;
	}
 
Example 2
Source File: AegeanChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
	protected JFreeChart createPie3DChart() throws JRException
	{
		JFreeChart jfreeChart = super.createPie3DChart();

		PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
		JRPie3DPlot jrPiePlot = (JRPie3DPlot)getPlot();
		boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();
		if(isShowLabels && piePlot3D.getLabelGenerator() != null)
		{
			piePlot3D.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
			piePlot3D.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
			piePlot3D.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
		}
		piePlot3D.setDarkerSides(true);
		piePlot3D.setDepthFactor(0.07);
//does not work for 3D
//		piePlot3D.setShadowXOffset(5);
//		piePlot3D.setShadowYOffset(10);
//		piePlot3D.setShadowPaint(new GradientPaint(
//				0,
//				getChart().getHeight() / 2,
//				new Color(41, 120, 162),
//				0,
//				getChart().getHeight(),
//				Color.white)
//		);

		PieDataset pieDataset = piePlot3D.getDataset();
		if(pieDataset != null)
		{
			for(int i = 0; i < pieDataset.getItemCount(); i++)
			{
				piePlot3D.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);
			}
		}
		piePlot3D.setCircular(true);
		return jfreeChart;
	}
 
Example 3
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createPie3DChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createPieChart3D(
			evaluateTextExpression(getChart().getTitleExpression()),
			(PieDataset)getDataset(),
			isShowLegend(),
			true,
			false
			);

	configureChart(jfreeChart);

	PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
	//plot.setStartAngle(290);
	//plot.setDirection(Rotation.CLOCKWISE);
	//plot.setNoDataMessage("No data to display");
	JRPie3DPlot jrPie3DPlot = (JRPie3DPlot)getPlot();
	double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPie3DPlot.getDepthFactorDouble();
	boolean isCircular =  jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
	piePlot3D.setDepthFactor(depthFactor);
	piePlot3D.setCircular(isCircular);
	
	boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();

	if (isShowLabels)
	{
		PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator();
		JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
		if (labelGenerator != null)
		{
			piePlot3D.setLabelGenerator(labelGenerator);
		}
		else if (jrPie3DPlot.getLabelFormat() != null)
		{ 
			piePlot3D.setLabelGenerator(
				new StandardPieSectionLabelGenerator(jrPie3DPlot.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)
//		{
//			piePlot3D.setLabelGenerator(
//					new StandardPieSectionLabelGenerator(itemLabel.getMask())
//					);
//		}
		
		piePlot3D.setLabelFont(
			fontUtil.getAwtFont(
				getFont(itemLabel == null ? null : itemLabel.getFont()), 
				getLocale()
				)
			);

		if (itemLabel != null && itemLabel.getColor() != null)
		{
			piePlot3D.setLabelPaint(itemLabel.getColor());
		}
		else
		{
			piePlot3D.setLabelPaint(getChart().getForecolor());
		}

		if (itemLabel != null && itemLabel.getBackgroundColor() != null)
		{
			piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
		}
		else
		{
			piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
		}
	}
	else
	{
		piePlot3D.setLabelGenerator(null);
	}
	
	if (jrPie3DPlot.getLegendLabelFormat() != null)
	{ 
		piePlot3D.setLegendLabelGenerator(
			new StandardPieSectionLabelGenerator(jrPie3DPlot.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 4
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createPie3DChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createPieChart3D(
			evaluateTextExpression(getChart().getTitleExpression()),
			(PieDataset)getDataset(),
			isShowLegend(),
			true,
			false
			);

	configureChart(jfreeChart, getPlot());

	PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
	//plot.setStartAngle(290);
	//plot.setDirection(Rotation.CLOCKWISE);
	//plot.setNoDataMessage("No data to display");
	JRPie3DPlot jrPie3DPlot = (JRPie3DPlot)getPlot();
	double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPie3DPlot.getDepthFactorDouble();
	boolean isCircular =  jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
	piePlot3D.setDepthFactor(depthFactor);
	piePlot3D.setCircular(isCircular);

	boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();
	
	if (isShowLabels)
	{
		PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator();
		JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
		if (labelGenerator != null)
		{
			piePlot3D.setLabelGenerator(labelGenerator);
		}
		else if (jrPie3DPlot.getLabelFormat() != null)
		{
			piePlot3D.setLabelGenerator(
				new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(), 
						NumberFormat.getNumberInstance(getLocale()),
		                NumberFormat.getPercentInstance(getLocale()))
				);
		}
//		else if (itemLabel != null && itemLabel.getMask() != null)
//		{
//			piePlot3D.setLabelGenerator(
//				new StandardPieSectionLabelGenerator(itemLabel.getMask())
//				);
//		}
		else
		{
			piePlot3D.setLabelGenerator(
					new StandardPieSectionLabelGenerator()
					);
		}

		Integer baseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
		JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
		piePlot3D.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

		if (itemLabel != null && itemLabel.getColor() != null)
		{
			piePlot3D.setLabelPaint(itemLabel.getColor());
		}
		else
		{
			piePlot3D.setLabelPaint(getChart().getForecolor());
		}

		if (itemLabel != null && itemLabel.getBackgroundColor() != null)
		{
			piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
		}
		else
		{
			piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
		}
	}
	else
	{
		piePlot3D.setLabelGenerator(null);
	}
	
	if (jrPie3DPlot.getLegendLabelFormat() != null)
	{
		piePlot3D.setLegendLabelGenerator(
			new StandardPieSectionLabelGenerator(jrPie3DPlot.getLegendLabelFormat(), 
					NumberFormat.getNumberInstance(getLocale()),
	                NumberFormat.getPercentInstance(getLocale()))
			);
	}
	
	return jfreeChart;
}
 
Example 5
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createPie3DChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createPieChart3D(
			evaluateTextExpression(getChart().getTitleExpression()),
			(PieDataset)getDataset(),
			isShowLegend(),
			true,
			false
			);

	configureChart(jfreeChart, getPlot());

	PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
	//plot.setStartAngle(290);
	//plot.setDirection(Rotation.CLOCKWISE);
	//plot.setNoDataMessage("No data to display");
	JRPie3DPlot jrPie3DPlot = (JRPie3DPlot)getPlot();
	double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT : jrPie3DPlot.getDepthFactorDouble();
	boolean isCircular =  jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
	piePlot3D.setDepthFactor(depthFactor);
	piePlot3D.setCircular(isCircular);

	boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();
	
	if (isShowLabels)
	{
		PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator();
		JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
		if (labelGenerator != null)
		{
			piePlot3D.setLabelGenerator(labelGenerator);
		}
		else if (jrPie3DPlot.getLabelFormat() != null)
		{
			piePlot3D.setLabelGenerator(
				new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(), 
						NumberFormat.getNumberInstance(getLocale()),
		                NumberFormat.getPercentInstance(getLocale()))
				);
		}
//		else if (itemLabel != null && itemLabel.getMask() != null)
//		{
//			piePlot3D.setLabelGenerator(
//					new StandardPieSectionLabelGenerator(itemLabel.getMask())
//					);
//		}
		
		if (itemLabel != null && itemLabel.getFont() != null)
		{
			piePlot3D.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale()));
		}
		else
		{
			piePlot3D.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
		}

		if (itemLabel != null && itemLabel.getColor() != null)
		{
			piePlot3D.setLabelPaint(itemLabel.getColor());
		}
		else
		{
			piePlot3D.setLabelPaint(getChart().getForecolor());
		}

		if (itemLabel != null && itemLabel.getBackgroundColor() != null)
		{
			piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
		}
		else
		{
			piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
		}
	}
	else
	{
		piePlot3D.setLabelGenerator(null);
	}

	if (jrPie3DPlot.getLegendLabelFormat() != null)
	{
		piePlot3D.setLegendLabelGenerator(
			new StandardPieSectionLabelGenerator(jrPie3DPlot.getLegendLabelFormat(), 
					NumberFormat.getNumberInstance(getLocale()),
	                NumberFormat.getPercentInstance(getLocale()))
			);
	}
	
	return jfreeChart;
}