Example usage for org.jfree.chart.axis CategoryAxis setLabelAngle

List of usage examples for org.jfree.chart.axis CategoryAxis setLabelAngle

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryAxis setLabelAngle.

Prototype

public void setLabelAngle(double angle) 

Source Link

Document

Sets the angle for the label and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:presentation.webgui.vitroappservlet.StyleCreator.java

private static JFreeChart createChart(CategoryDataset dataset, Vector<String> givCategColors,
        Model3dStylesEntry givStyleEntry) {
    String capSimpleName = givStyleEntry.getCorrCapability();
    capSimpleName = capSimpleName.replaceAll(Capability.dcaPrefix, "");
    JFreeChart chart = ChartFactory.createBarChart("Style Legend for " + capSimpleName, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, false, // include legend
            true, false);// ww  w.  ja  va 2s.com

    chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 14));
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white); // seen
    CategoryPlot plot = chart.getCategoryPlot();
    chart.setPadding(new RectangleInsets(0, 0, 0, 0)); //new

    plot.setNoDataMessage("NO DATA!");

    Paint[] tmpPaintCategories = { Color.white };
    if (givCategColors.size() > 0) {
        tmpPaintCategories = new Paint[givCategColors.size()];
        for (int i = 0; i < givCategColors.size(); i++) {
            tmpPaintCategories[i] = Color.decode(givCategColors.elementAt(i));
        }
    }

    CategoryItemRenderer renderer = new CustomRenderer(tmpPaintCategories);

    renderer.setSeriesPaint(0, new Color(255, 204, 51)); //new

    plot.setRenderer(renderer);

    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); //new
    plot.setForegroundAlpha(1f); //new
    plot.setBackgroundAlpha(1f); //new
    plot.setInsets(new RectangleInsets(5, 0, 5, 0)); //new was 5,0,5,0
    plot.setRangeGridlinesVisible(false); //new was true
    plot.setBackgroundPaint(Color.white);//new: was (Color.lightGray);
    plot.setOutlinePaint(Color.white);

    //plot.setOrientation(PlotOrientation.HORIZONTAL);

    CategoryAxis domainAxis = plot.getDomainAxis();

    domainAxis.setLowerMargin(0.04);
    domainAxis.setUpperMargin(0.04);
    domainAxis.setVisible(true);
    domainAxis.setLabelAngle(Math.PI / 2);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(0.0, 100.0); // new: was 100
    rangeAxis.setVisible(false);
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}