Java Code Examples for org.jfree.chart.ChartFactory#setChartTheme()

The following examples show how to use org.jfree.chart.ChartFactory#setChartTheme() . 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: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected JFreeChart createXyAreaChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = 
		ChartFactory.createXYAreaChart(
			evaluateTextExpression(getChart().getTitleExpression() ),
			evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()),
			(XYDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false
			);

	configureChart(jfreeChart, getPlot());
	JRAreaPlot areaPlot = (JRAreaPlot)getPlot();

	// Handle the axis formating for the category axis
	configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
			areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
			areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(),
			areaPlot.getOwnCategoryAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
			areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
			areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(),
			areaPlot.getOwnValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 2
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected JFreeChart createBubbleChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = ChartFactory.createBubbleChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression()),
			evaluateTextExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression()),
			 (XYZDataset)getDataset(),
			 getPlot().getOrientationValue().getOrientation(),
			 isShowLegend(),
			 true,
			 false);

	configureChart(jfreeChart);

	XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
	JRBubblePlot bubblePlot = (JRBubblePlot)getPlot();
	int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue();
	XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer( scaleType );
	xyPlot.setRenderer( bubbleRenderer );

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(),
			bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(),
			bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(),
			bubblePlot.getXAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(),
			bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(),
			bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(),
			bubblePlot.getYAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 3
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
protected JFreeChart createCandlestickChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createCandlestickChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()),
			(DefaultHighLowDataset)getDataset(),
			isShowLegend()
			);

	configureChart(jfreeChart);

	XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
	JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
	CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
	boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume();
	candlestickRenderer.setDrawVolume(isShowVolume);

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
			candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
			candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(),
			candlestickPlot.getTimeAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(),
			candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(),
			candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisVerticalTickLabels(),
			candlestickPlot.getValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(candlestickPlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 4
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected JFreeChart createBubbleChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = 
		ChartFactory.createBubbleChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression()),
			evaluateTextExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression()),
			 (XYZDataset)getDataset(),
			 getPlot().getOrientationValue().getOrientation(),
			 isShowLegend(),
			 true,
			 false);

	configureChart(jfreeChart, getPlot());

	XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
	JRBubblePlot bubblePlot = (JRBubblePlot)getPlot();
	int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue();
	XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer( scaleType );
	xyPlot.setRenderer( bubbleRenderer );

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(),
			bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(),
			bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(),
			bubblePlot.getOwnXAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(),
			bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(),
			bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(),
			bubblePlot.getOwnYAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 5
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected JFreeChart createXyAreaChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = 
		ChartFactory.createXYAreaChart(
			evaluateTextExpression(getChart().getTitleExpression() ),
			evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()),
			(XYDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false
			);

	configureChart(jfreeChart, getPlot());
	JRAreaPlot areaPlot = (JRAreaPlot)getPlot();

	// Handle the axis formating for the category axis
	configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
			areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
			areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(),
			areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),
			(Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())
			);

	// Handle the axis formating for the value axis
	configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
			areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
			areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(),
			areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
			(Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())
			);

	return jfreeChart;
}
 
Example 6
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
protected JFreeChart createStackedAreaChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createStackedAreaChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression()),
			(CategoryDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false
			);

	configureChart(jfreeChart);
	JRAreaPlot areaPlot = (JRAreaPlot)getPlot();

	// Handle the axis formating for the category axis
	configureAxis(((CategoryPlot)jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
			areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
			areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(),
			areaPlot.getCategoryAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(((CategoryPlot)jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(),
			areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
			areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(),
			areaPlot.getValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

	((CategoryPlot)jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0);
	
	return jfreeChart;
}
 
Example 7
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createLineChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart freeChart = 
		ChartFactory.createLineChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression( ((JRLinePlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRLinePlot)getPlot()).getValueAxisLabelExpression()),
			(CategoryDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false);

	configureChart(freeChart, getPlot());

	CategoryPlot categoryPlot = (CategoryPlot)freeChart.getPlot();
	JRLinePlot linePlot = (JRLinePlot)getPlot();

	LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
	boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
	boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();
	
	lineRenderer.setBaseShapesVisible( isShowShapes );//FIXMECHART check this
	lineRenderer.setBaseLinesVisible( isShowLines );
	
	//FIXME labels?

	// Handle the axis formating for the category axis
	configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
			linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
			linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(),
			linePlot.getOwnCategoryAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(),
			linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
			linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(),
			linePlot.getOwnValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression()));

	return freeChart;
}
 
Example 8
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createXyLineChart() throws JRException 
{
	JRLinePlot linePlot = (JRLinePlot) getPlot();

	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = 
		ChartFactory.createXYLineChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(linePlot.getCategoryAxisLabelExpression()),
			evaluateTextExpression(linePlot.getValueAxisLabelExpression()),
			(XYDataset)getDataset(),
			linePlot.getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false);

	configureChart(jfreeChart, getPlot());

	// Handle the axis formating for the category axis
	configureAxis(jfreeChart.getXYPlot().getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
			linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
			linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(),
			linePlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression())
			);


	// Handle the axis formating for the value axis
	configureAxis(jfreeChart.getXYPlot().getRangeAxis(), linePlot.getValueAxisLabelFont(),
			linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
			linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(),
			linePlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression())
			);

	XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) jfreeChart.getXYPlot().getRenderer();
	boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
	boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();
	lineRenderer.setBaseShapesVisible(isShowShapes);
	lineRenderer.setBaseLinesVisible(isShowLines);

	return jfreeChart;
}
 
Example 9
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createGanttChart() throws JRException
{
	//FIXMECHART legend/tooltip/url should come from plot?
	
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createGanttChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
			(GanttCategoryDataset)getDataset(),
			isShowLegend(),
			true,  //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
			false
			);

	configureChart(jfreeChart);
	
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	//plot.setNoDataMessage("No data to display");
	
	JRBarPlot barPlot = (JRBarPlot)getPlot();
	boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
	boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
	boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
	
	categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
	categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
	// Handle the axis formating for the category axis
	configureAxis(
		categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
		barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
		barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
		barPlot.getCategoryAxisLineColor(), false, null, null
		);
	((DateAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
	((DateAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
	// Handle the axis formating for the value axis
	configureAxis(
		categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
		barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
		barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
		barPlot.getValueAxisLineColor(), true,
		(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
		(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

	GanttRenderer categoryRenderer = (GanttRenderer)categoryPlot.getRenderer();
	categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
	categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
	categoryRenderer.setShadowVisible(false);

	return jfreeChart;
}
 
Example 10
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createTimeSeriesChart() throws JRException 
{
	String timeAxisLabel = evaluateTextExpression(((JRTimeSeriesPlot)getPlot()).getTimeAxisLabelExpression());
	String valueAxisLabel = evaluateTextExpression(((JRTimeSeriesPlot)getPlot()).getValueAxisLabelExpression());

	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = 
		ChartFactory.createTimeSeriesChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			timeAxisLabel,
			valueAxisLabel,
			(TimeSeriesCollection)getDataset(),
			isShowLegend(),
			true,
			false );

	configureChart(jfreeChart, getPlot());

	XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
	JRTimeSeriesPlot timeSeriesPlot = (JRTimeSeriesPlot)getPlot();
	
	XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer)xyPlot.getRenderer();
	
	boolean isShowShapes = timeSeriesPlot.getShowShapes() == null ? true : timeSeriesPlot.getShowShapes();
	boolean isShowLines = timeSeriesPlot.getShowLines() == null ? true : timeSeriesPlot.getShowLines();
	lineRenderer.setBaseLinesVisible(isShowLines);
	lineRenderer.setBaseShapesVisible(isShowShapes);
	
	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), timeSeriesPlot.getTimeAxisLabelFont(),
			timeSeriesPlot.getTimeAxisLabelColor(), timeSeriesPlot.getTimeAxisTickLabelFont(),
			timeSeriesPlot.getTimeAxisTickLabelColor(), timeSeriesPlot.getTimeAxisTickLabelMask(), timeSeriesPlot.getTimeAxisVerticalTickLabels(),
			timeSeriesPlot.getOwnTimeAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(xyPlot.getRangeAxis(), timeSeriesPlot.getValueAxisLabelFont(),
			timeSeriesPlot.getValueAxisLabelColor(), timeSeriesPlot.getValueAxisTickLabelFont(),
			timeSeriesPlot.getValueAxisTickLabelColor(), timeSeriesPlot.getValueAxisTickLabelMask(), timeSeriesPlot.getValueAxisVerticalTickLabels(),
			timeSeriesPlot.getOwnValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 11
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET ){
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart, getPlot());

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator());
		itemRenderer.setShadowVisible(false);

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), DateTickUnitType.DAY,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression())
				);


		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), DateTickUnitType.DAY,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())
				);

		return jfreeChart;
	}
 
Example 12
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createGanttChart() throws JRException
{
	//FIXMECHART legend/tooltip/url should come from plot?
	
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createGanttChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
			(GanttCategoryDataset)getDataset(),
			isShowLegend(),
			true,  //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
			false
			);

	configureChart(jfreeChart, getPlot());
	
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	//plot.setNoDataMessage("No data to display");
	
	JRBarPlot barPlot = (JRBarPlot)getPlot();
	boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
	boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
	boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
	
	//FIXMETHEME these are useless if the theme settings apply after regardless of these; check all
	categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
	categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
	// Handle the axis formating for the category axis
	configureAxis(
		categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
		barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
		barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
		barPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), 
		(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), 
		(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression())
		);

	((DateAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
	((DateAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
	// Handle the axis formating for the value axis
	configureAxis(
		categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
		barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
		barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
		barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
		(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), 
		(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())
		);

	BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
	categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
	categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
	categoryRenderer.setShadowVisible(false);

	return jfreeChart;
}
 
Example 13
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createStackedBar3DChart() throws JRException
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createStackedBarChart3D(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
				evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
				(CategoryDataset)getDataset(),
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart);

		CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
		JRBar3DPlot bar3DPlot = (JRBar3DPlot)getPlot();

		StackedBarRenderer3D stackedBarRenderer3D =
			new StackedBarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);
		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels);
		if (isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();

			stackedBarRenderer3D.setBaseItemLabelFont(
				fontUtil.getAwtFont(
					getFont(itemLabel == null ? null : itemLabel.getFont()), 
					getLocale()
					)
				);
			
			if (itemLabel != null)
			{
				if (itemLabel.getColor() != null)
				{
					stackedBarRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if (itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
				stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}
		categoryPlot.setRenderer(stackedBarRenderer3D);

		// Handle the axis formating for the category axis
		configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
				bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
				bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(),
				bar3DPlot.getCategoryAxisLineColor(), false,
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression()));

		// Handle the axis formating for the value axis
		configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(),
				bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(),
				bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(),
				bar3DPlot.getValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression()));

		return jfreeChart;
	}
 
Example 14
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createScatterChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = ChartFactory.createScatterPlot(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRScatterPlot)getPlot()).getXAxisLabelExpression()),
			evaluateTextExpression(((JRScatterPlot)getPlot()).getYAxisLabelExpression() ),
			(XYDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false);

	configureChart(jfreeChart);
	XYLineAndShapeRenderer plotRenderer = (XYLineAndShapeRenderer) ((XYPlot)jfreeChart.getPlot()).getRenderer();

	JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
	boolean isShowLines = scatterPlot.getShowLines() == null ? true : scatterPlot.getShowLines();
	boolean isShowShapes = scatterPlot.getShowShapes() == null ? true : scatterPlot.getShowShapes();
	
	plotRenderer.setBaseLinesVisible(isShowLines);
	plotRenderer.setBaseShapesVisible(isShowShapes);

	// Handle the axis formating for the category axis
	configureAxis(jfreeChart.getXYPlot().getDomainAxis(), scatterPlot.getXAxisLabelFont(),
			scatterPlot.getXAxisLabelColor(), scatterPlot.getXAxisTickLabelFont(),
			scatterPlot.getXAxisTickLabelColor(), scatterPlot.getXAxisTickLabelMask(), scatterPlot.getXAxisVerticalTickLabels(),
			scatterPlot.getXAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(scatterPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(scatterPlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(jfreeChart.getXYPlot().getRangeAxis(), scatterPlot.getYAxisLabelFont(),
			scatterPlot.getYAxisLabelColor(), scatterPlot.getYAxisTickLabelFont(),
			scatterPlot.getYAxisTickLabelColor(), scatterPlot.getYAxisTickLabelMask(), scatterPlot.getYAxisVerticalTickLabels(),
			scatterPlot.getYAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 15
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createStackedBar3DChart() throws JRException
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createStackedBarChart3D(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
				evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
				(CategoryDataset)getDataset(),
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart, getPlot());

		CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
		JRBar3DPlot bar3DPlot = (JRBar3DPlot)getPlot();

		StackedBarRenderer3D stackedBarRenderer3D =
			new StackedBarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);

		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels);
		if(isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();

			stackedBarRenderer3D.setBaseItemLabelFont(
					getFontUtil().getAwtFont(
					getFont(itemLabel == null ? null : itemLabel.getFont()), 
					getLocale()
					)
				);
			
			if(itemLabel != null)
			{
				if(itemLabel.getColor() != null)
				{
					stackedBarRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if(itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
				stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}

		categoryPlot.setRenderer(stackedBarRenderer3D);

		// Handle the axis formating for the category axis
		configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
				bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
				bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(),
				bar3DPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())
				);


		// Handle the axis formating for the value axis
		configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(),
				bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(),
				bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(),
				bar3DPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())
				);

		return jfreeChart;
	}
 
Example 16
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createGanttChart() throws JRException
{
	//FIXMECHART legend/tooltip/url should come from plot?
	
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createGanttChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
			(GanttCategoryDataset)getDataset(),
			isShowLegend(),
			true,  //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
			false
			);

	configureChart(jfreeChart, getPlot());
	
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	//plot.setNoDataMessage("No data to display");
	
	JRBarPlot barPlot = (JRBarPlot)getPlot();
	boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
	boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
	boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
	
	categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
	categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
	// Handle the axis formating for the category axis
	configureAxis(
		categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
		barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
		barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
		barPlot.getOwnCategoryAxisLineColor(), false, null, null
		);
	((DateAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
	((DateAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
	// Handle the axis formating for the value axis
	configureAxis(
		categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
		barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
		barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
		barPlot.getOwnValueAxisLineColor(), true,
		(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
		(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

	BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer();
	categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
	categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
	categoryRenderer.setShadowVisible(false);

	return jfreeChart;
}
 
Example 17
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createLineChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = ChartFactory.createLineChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression( ((JRLinePlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRLinePlot)getPlot()).getValueAxisLabelExpression()),
			(CategoryDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false);

	configureChart(jfreeChart);

	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	JRLinePlot linePlot = (JRLinePlot)getPlot();

	LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
	boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
	boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();
	
	lineRenderer.setBaseShapesVisible( isShowShapes );//FIXMECHART check this
	lineRenderer.setBaseLinesVisible( isShowLines );
	
	//FIXME labels?

	// Handle the axis formating for the category axis
	configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
			linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
			linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(),
			linePlot.getCategoryAxisLineColor(),  false,
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(),
			linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
			linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(),
			linePlot.getValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 18
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createHighLowChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createHighLowChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()),
			evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()),
			(DefaultHighLowDataset)getDataset(),
			isShowLegend()
			);

	configureChart(jfreeChart, getPlot());
	XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
	JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot();
	HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer();
	boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks();
	boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks();
	
	hlRenderer.setDrawOpenTicks(isShowOpenTicks);
	hlRenderer.setDrawCloseTicks(isShowCloseTicks);

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(),
			highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(),
			highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(),
			highLowPlot.getOwnTimeAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(),
			highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(),
			highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(),
			highLowPlot.getOwnValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression()));
	
	return jfreeChart;
}
 
Example 19
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 20
Source File: ChartUtils.java    From PDV with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set theme
 */
private static void setChartTheme() {
    StandardChartTheme chartTheme = new StandardChartTheme("US");
    chartTheme.setExtraLargeFont(new Font("Arial", Font.BOLD, 14));
    chartTheme.setRegularFont(new Font("Arial", Font.PLAIN, 13));
    chartTheme.setLargeFont(new Font("Arial", Font.PLAIN, 14));
    chartTheme.setSmallFont(new Font("Arial", Font.PLAIN, 12));
    chartTheme.setTitlePaint(new Color(51, 51, 51));
    chartTheme.setSubtitlePaint(new Color(85, 85, 85));

    chartTheme.setLegendBackgroundPaint(Color.WHITE);
    chartTheme.setLegendItemPaint(Color.BLACK);
    chartTheme.setChartBackgroundPaint(Color.WHITE);

    Paint[] OUTLINE_PAINT_SEQUENCE = new Paint[] { Color.WHITE };
    DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(CHART_COLORS, CHART_COLORS, OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chartTheme.setDrawingSupplier(drawingSupplier);

    chartTheme.setPlotBackgroundPaint(Color.WHITE);
    chartTheme.setPlotOutlinePaint(Color.WHITE);
    chartTheme.setLabelLinkPaint(new Color(8, 55, 114));
    chartTheme.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE);

    chartTheme.setAxisOffset(new RectangleInsets(5, 12, 5, 12));
    chartTheme.setDomainGridlinePaint(new Color(192, 208, 224));
    chartTheme.setRangeGridlinePaint(new Color(192, 192, 192));

    chartTheme.setBaselinePaint(Color.WHITE);
    chartTheme.setCrosshairPaint(Color.BLUE);
    chartTheme.setAxisLabelPaint(new Color(51, 51, 51));
    chartTheme.setTickLabelPaint(new Color(67, 67, 72));
    chartTheme.setBarPainter(new StandardBarPainter());
    chartTheme.setXYBarPainter(new StandardXYBarPainter());

    chartTheme.setItemLabelPaint(Color.black);
    chartTheme.setThermometerPaint(Color.white);

    ChartFactory.setChartTheme(chartTheme);
}