Java Code Examples for org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setBaseLinesVisible()

The following examples show how to use org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setBaseLinesVisible() . 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 createScatterChart() throws JRException
{
	JFreeChart jfreeChart = super.createScatterChart();
	XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
	
	xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR);
	xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f));
	xyPlot.setDomainGridlinesVisible(true);
	xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR);
	xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f));
	xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134);

	XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer)xyPlot.getRenderer();
	lineRenderer.setUseFillPaint(true);
	JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
	boolean isShowLines = scatterPlot.getShowLines() == null ? false : scatterPlot.getShowLines();
	lineRenderer.setBaseLinesVisible(isShowLines);
	XYDataset xyDataset = xyPlot.getDataset();
	if (xyDataset != null)
	{
		for (int i = 0; i < xyDataset.getSeriesCount(); i++)
		{
			lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
			lineRenderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
			lineRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
			//lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
		}
	}
	return jfreeChart;
}
 
Example 2
Source File: PlotUtil.java    From dl4j-tutorials with MIT License 4 votes vote down vote up
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {
    NumberAxis xAxis = new NumberAxis("X");
    xAxis.setRange(mins[0],maxs[0]);


    NumberAxis yAxis = new NumberAxis("Y");
    yAxis.setRange(mins[1], maxs[1]);

    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth((maxs[0]-mins[0])/(nPoints-1));
    renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1));
    PaintScale scale = new GrayPaintScale(0, 1.0);
    renderer.setPaintScale(scale);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    JFreeChart chart = new JFreeChart("", plot);
    chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false);


    NumberAxis scaleAxis = new NumberAxis("Probability (class 0)");
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7));
    PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(),
            scaleAxis);
    legend.setStripOutlineVisible(false);
    legend.setSubdivisionCount(20);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5.0);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setFrame(new BlockBorder(Color.red));
    legend.setPadding(new RectangleInsets(10, 10, 10, 10));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.LEFT);
    chart.addSubtitle(legend);

    ChartUtilities.applyCurrentTheme(chart);

    plot.setDataset(1, xyData);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setBaseLinesVisible(false);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}
 
Example 3
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 4
Source File: DefaultChartTheme.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);

	// 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.getCategoryAxisLineColor(), false,
			(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.getValueAxisLineColor(), true,
			(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 5
Source File: DefaultChartTheme.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);

	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.getTimeAxisLineColor(), 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.getValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMaxValueExpression()));
	return jfreeChart;
}
 
Example 6
Source File: GenericChartTheme.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, getPlot());
	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.getOwnXAxisLineColor(), 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.getOwnYAxisLineColor(), true, 
			(Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMaxValueExpression()));

	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 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(), false,
			(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(), true,
			(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 8
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 9
Source File: SimpleChartTheme.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, getPlot());
	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.getOwnXAxisLineColor(), getDomainAxisSettings(),
			(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.getOwnYAxisLineColor(), getRangeAxisSettings(),
			(Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(scatterPlot.getRangeAxisMaxValueExpression()));


	return jfreeChart;
}
 
Example 10
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 11
Source File: SimpleChartTheme.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(), getDomainAxisSettings(), DateTickUnitType.DAY,
			(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(), getRangeAxisSettings(), DateTickUnitType.DAY,
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(timeSeriesPlot.getRangeAxisMaxValueExpression())
			);

	return jfreeChart;
}
 
Example 12
Source File: XYLineAndShapeRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {

    XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
    XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer();
    assertEquals(r1, r2);
    assertEquals(r2, r1);

    r1.setSeriesLinesVisible(3, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesLinesVisible(3, true);
    assertTrue(r1.equals(r2));

    r1.setBaseLinesVisible(false);
    assertFalse(r1.equals(r2));
    r2.setBaseLinesVisible(false);
    assertTrue(r1.equals(r2));

    r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(r1.equals(r2));
    r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(r1.equals(r2));

    r1.setSeriesShapesVisible(3, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesShapesVisible(3, true);
    assertTrue(r1.equals(r2));

    r1.setBaseShapesVisible(false);
    assertFalse(r1.equals(r2));
    r2.setBaseShapesVisible(false);
    assertTrue(r1.equals(r2));

    r1.setSeriesShapesFilled(3, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesShapesFilled(3, true);
    assertTrue(r1.equals(r2));

    r1.setBaseShapesFilled(false);
    assertFalse(r1.equals(r2));
    r2.setBaseShapesFilled(false);
    assertTrue(r1.equals(r2));

    r1.setDrawOutlines(!r1.getDrawOutlines());
    assertFalse(r1.equals(r2));
    r2.setDrawOutlines(r1.getDrawOutlines());
    assertTrue(r1.equals(r2));

    r1.setUseOutlinePaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseOutlinePaint(true);
    assertTrue(r1.equals(r2));

    r1.setUseFillPaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseFillPaint(true);
    assertTrue(r1.equals(r2));

    r1.setDrawSeriesLineAsPath(true);
    assertFalse(r1.equals(r2));
    r2.setDrawSeriesLineAsPath(true);
    assertTrue(r1.equals(r2));
}
 
Example 13
Source File: XYLineAndShapeRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    
    XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
    XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer();
    assertEquals(r1, r2);
    assertEquals(r2, r1);
    
    r1.setSeriesLinesVisible(3, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesLinesVisible(3, true);
    assertTrue(r1.equals(r2));
    
    r1.setBaseLinesVisible(false);
    assertFalse(r1.equals(r2));
    r2.setBaseLinesVisible(false);
    assertTrue(r1.equals(r2));
    
    r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(r1.equals(r2));
    r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(r1.equals(r2));
    
    r1.setSeriesShapesVisible(3, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesShapesVisible(3, true);
    assertTrue(r1.equals(r2));
    
    r1.setBaseShapesVisible(false);
    assertFalse(r1.equals(r2));
    r2.setBaseShapesVisible(false);
    assertTrue(r1.equals(r2));
    
    r1.setSeriesShapesFilled(3, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesShapesFilled(3, true);
    assertTrue(r1.equals(r2));
    
    r1.setBaseShapesFilled(false);
    assertFalse(r1.equals(r2));
    r2.setBaseShapesFilled(false);
    assertTrue(r1.equals(r2));

    r1.setDrawOutlines(!r1.getDrawOutlines());
    assertFalse(r1.equals(r2));
    r2.setDrawOutlines(r1.getDrawOutlines());
    assertTrue(r1.equals(r2));

    r1.setUseOutlinePaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseOutlinePaint(true);
    assertTrue(r1.equals(r2));
    
    r1.setUseFillPaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseFillPaint(true);
    assertTrue(r1.equals(r2));
    
    r1.setDrawSeriesLineAsPath(true);
    assertFalse(r1.equals(r2));
    r2.setDrawSeriesLineAsPath(true);
    assertTrue(r1.equals(r2));
}