Java Code Examples for org.jfree.chart.plot.CategoryPlot#setRangeGridlineStroke()

The following examples show how to use org.jfree.chart.plot.CategoryPlot#setRangeGridlineStroke() . 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 4 votes vote down vote up
@Override
protected void configurePlot(Plot plot, JRChartPlot jrPlot)
{
	super.configurePlot(plot, jrPlot);
	if (plot instanceof CategoryPlot)
	{
		CategoryPlot categoryPlot = (CategoryPlot)plot;
		CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
		CategoryDataset categoryDataset = categoryPlot.getDataset();
		if (categoryDataset != null)
		{
			for (int i = 0; i < categoryDataset.getRowCount(); i++)
			{
				categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
			}
		}
		categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);
		categoryPlot.setRangeGridlineStroke(new BasicStroke(1f));
		categoryPlot.setDomainGridlinesVisible(false);
		
	}
	else if (plot instanceof XYPlot)
	{
		XYPlot xyPlot = (XYPlot)plot;
		XYDataset xyDataset = xyPlot.getDataset();
		if (xyDataset != null)
		{
			XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
			for (int i = 0; i < xyDataset.getSeriesCount(); i++)
			{
				xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
			}
		}
		xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);
		xyPlot.setRangeGridlineStroke(new BasicStroke(1f));
		xyPlot.setDomainGridlinesVisible(false);
		
		xyPlot.setRangeZeroBaselineVisible(true);

	}
}
 
Example 2
Source File: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected JFreeChart createGanttChart() throws JRException
{

	JFreeChart jfreeChart = super.createGanttChart();
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
	categoryPlot.setDomainGridlinesVisible(true);
	categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);
	categoryPlot.setDomainGridlineStroke(new BasicStroke(
			0.5f,
			BasicStroke.CAP_BUTT,
			BasicStroke.JOIN_MITER,
			50,
			new float[] {1},
			0
			)
	);

	categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);

	categoryPlot.setRangeGridlinesVisible(true);
	categoryPlot.setRangeGridlineStroke(new BasicStroke(
			0.5f,
			BasicStroke.CAP_BUTT,
			BasicStroke.JOIN_MITER,
			50,
			new float[] {1},
			0
			)
	);

	categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);
	categoryPlot.getDomainAxis().setTickLabelsVisible(
			//barPlot.isShowTickLabels()
			true
			);
	CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
	categoryRenderer.setBaseItemLabelsVisible(true);
	BarRenderer barRenderer = (BarRenderer)categoryRenderer;
	barRenderer.setSeriesPaint(0, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3));
	barRenderer.setSeriesPaint(1, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0));
	CategoryDataset categoryDataset = categoryPlot.getDataset();
	if (categoryDataset != null)
	{
		for (int i = 0; i < categoryDataset.getRowCount(); i++)
		{
			barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont());
			barRenderer.setSeriesItemLabelsVisible(i, true);
		}
	}
	categoryPlot.setOutlinePaint(Color.DARK_GRAY);
	categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
	categoryPlot.setOutlineVisible(true);
	return jfreeChart;
}
 
Example 3
Source File: AegeanChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void configurePlot(Plot plot, JRChartPlot jrPlot)
{

	super.configurePlot(plot, jrPlot);

	if(plot instanceof CategoryPlot)
	{
		CategoryPlot categoryPlot = (CategoryPlot)plot;
		CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
		CategoryDataset categoryDataset = categoryPlot.getDataset();
		if(categoryDataset != null)
		{
			for(int i = 0; i < categoryDataset.getRowCount(); i++)
			{
				categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
			}
		}
		categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
		categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
		categoryPlot.setDomainGridlinesVisible(false);
		categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
	}
	else if(plot instanceof XYPlot)
	{
		XYPlot xyPlot = (XYPlot)plot;
		XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
		XYDataset xyDataset = xyPlot.getDataset();
		if(xyDataset != null)
		{
			for(int i = 0; i < xyDataset.getSeriesCount(); i++)
			{
				xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
			}
		}
		xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
		xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
		xyPlot.setDomainGridlinesVisible(false);
		xyPlot.setRangeZeroBaselineVisible(true);
	}
}
 
Example 4
Source File: AegeanChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
	protected JFreeChart createGanttChart() throws JRException
	{

		JFreeChart jfreeChart = super.createGanttChart();
		CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
		categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
		categoryPlot.setDomainGridlinesVisible(true);
		categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);
		categoryPlot.setDomainGridlineStroke(new BasicStroke(
				0.5f,
				BasicStroke.CAP_BUTT,
				BasicStroke.JOIN_MITER,
				50,
				new float[] {1},
				0
				)
		);

		categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);

		categoryPlot.setRangeGridlinesVisible(true);
		categoryPlot.setRangeGridlineStroke(new BasicStroke(
				0.5f,
				BasicStroke.CAP_BUTT,
				BasicStroke.JOIN_MITER,
				50,
				new float[] {1},
				0
				)
		);

		categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
//		JRBarPlot barPlot = (BarPlot)categoryPlot;
//		categoryPlot.getDomainAxis().setTickLabelsVisible(
//				categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().
//				true
//				);
		CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
		categoryRenderer.setBaseItemLabelsVisible(true);
		BarRenderer barRenderer = (BarRenderer)categoryRenderer;
		@SuppressWarnings("unchecked")
		List<Paint> seriesPaints = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
		barRenderer.setSeriesPaint(0, seriesPaints.get(3));
		barRenderer.setSeriesPaint(1, seriesPaints.get(0));
		CategoryDataset categoryDataset = categoryPlot.getDataset();
		if(categoryDataset != null)
		{
			for(int i = 0; i < categoryDataset.getRowCount(); i++)
			{
				barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont());
				barRenderer.setSeriesItemLabelsVisible(i, true);
	//			barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]);
	//			CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f));
	//			categoryMarker.setAlpha(0.5f);
	//			categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND);
			}
		}
		categoryPlot.setOutlinePaint(Color.DARK_GRAY);
		categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
		categoryPlot.setOutlineVisible(true);
		return jfreeChart;
	}
 
Example 5
Source File: ChartFormatter.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
void formatChart(JFreeChart chart) {
    chart.getTitle().setFont(TITLE_FONT);
    ((TextTitle) chart.getSubtitle(0)).setFont(SUBTITLE_FONT);
    ((TextTitle) chart.getSubtitle(0)).setPadding(new RectangleInsets(0, 0, 0, 0));

    chart.getTitle().setPaint(textColor);
    ((TextTitle) chart.getSubtitle(0)).setPaint(textColor);

    Plot plot = chart.getPlot();

    // chart has no outline but a little padding
    plot.setOutlineStroke(null);
    chart.setPadding(new RectangleInsets(5, 5, 5, 5));

    chart.getPlot().setDrawingSupplier(new DefaultDrawingSupplier(seriesColors,
            DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    chart.setBackgroundPaint(background);
    chart.getPlot().setBackgroundPaint(plotBackground);

    if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;

        for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) {
            formatAxis(xyPlot.getRangeAxis(i));
        }

        formatAxis(xyPlot.getDomainAxis());

        xyPlot.setRangeGridlinePaint(gridLineColor);
        xyPlot.setDomainGridlinePaint(gridLineColor);
        xyPlot.setRangeGridlineStroke(GRID_LINES);
    }
    else if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;

        for (int i = 0; i < categoryPlot.getRangeAxisCount(); i++) {
            formatAxis(categoryPlot.getRangeAxis(i));
        }

        formatAxis(categoryPlot.getDomainAxis());

        categoryPlot.setRangeGridlinePaint(gridLineColor);
        categoryPlot.setDomainGridlinePaint(gridLineColor);
        categoryPlot.setRangeGridlineStroke(GRID_LINES);
    }
}