Java Code Examples for org.jfree.chart.renderer.category.CategoryItemRenderer#setSeriesOutlinePaint()

The following examples show how to use org.jfree.chart.renderer.category.CategoryItemRenderer#setSeriesOutlinePaint() . 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: 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 3
Source File: ResultsProccessor.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
    calcMeans();
    calcAvgRulesBySeed();
    
    // Create JFreeChart Dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
    
    
    HashMap<String, Double> measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, Double> measure : measuresFirst.entrySet())
    {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();
        
        for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
        {
            String alg = entry.getKey();
            Double measureValue = entry.getValue().get(measureName);
            
            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length()-1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);
            
            dataset.addValue(measureValue, aName, measureName);
            
            ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
            JFreeChart barChart = ChartFactory.createBarChart("Assotiation Rules Measures", measureName, measureName, dataset, PlotOrientation.VERTICAL, true, true, false);
            StandardChartTheme.createLegacyTheme().apply(barChart);
            
            CategoryItemRenderer renderer = barChart.getCategoryPlot().getRenderer();
            
            // Black and White
            int numItems = algorithmMeasures.size();
            for(int i=0;i<numItems;i++)
            {
                Color color = Color.DARK_GRAY;
                if(i%2 == 1)
                {
                    color = Color.LIGHT_GRAY;
                }
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesOutlinePaint(i, Color.BLACK);
            }
            
            
            int width = 640 * 2; /* Width of the image */
            int height = 480 * 2; /* Height of the image */ 
            
            // JPEG
            File BarChart = new File( outName + "_" + measureName + "_barchart.jpg" );
            ChartUtilities.saveChartAsJPEG( BarChart , barChart , width , height );
            
            // SVG
            SVGGraphics2D g2 = new SVGGraphics2D(width, height);
            Rectangle r = new Rectangle(0, 0, width, height);
            barChart.draw(g2, r);
            File BarChartSVG = new File( outName + "_" + measureName + "_barchart.svg" );
            SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
        }
    }
    /*
    for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
    {
        String alg = entry.getKey();
        HashMap<String, Double> measures = entry.getValue();
        
        for (Map.Entry<String, Double> entry1 : measures.entrySet())
        {
            String measureName = entry1.getKey();
            Double measureValue = entry1.getValue();
            
            dataset.addValue(measureValue, alg, measureName);
        }
    }
            */
    
}