Example usage for org.jfree.chart JFreeChart addSubtitle

List of usage examples for org.jfree.chart JFreeChart addSubtitle

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart addSubtitle.

Prototype

public void addSubtitle(int index, Title subtitle) 

Source Link

Document

Adds a subtitle at a particular position in the subtitle list, and sends a ChartChangeEvent to all registered listeners.

Usage

From source file:agentlogfileanalyzer.gui.ComparisonFrame.java

/**
 * Creates a chart frame for comparing a selected classifier to a set of
 * other classifiers.//  www. j  a v a 2s .  c  o m
 * 
 * @param firstTitle
 *            the first line of the chart title
 * @param secondTitle
 *            the second line of the chart title
 * @param compDataForColumns
 *            the data the will be displayed in the chart
 */
public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) {

    super("Classifier comparison");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < compDataForColumns.size(); i++) {
        ComparisonDataSet mms = compDataForColumns.get(i);
        dataset.addValue(mms.getMax(), "max", mms.getColumnName());
        dataset.addValue(mms.getMin(), "min", mms.getColumnName());
        dataset.addValue(mms.getSelected(), "selected", mms.getColumnName());
    }

    JFreeChart jfreechart = ChartFactory.createBarChart("", // title
            "", // x-axis title
            "", // y-axis title
            dataset, PlotOrientation.VERTICAL, true, true, false);
    TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12));
    TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12));
    jfreechart.addSubtitle(0, subtitle1);
    jfreechart.addSubtitle(1, subtitle2);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer();
    categoryplot.setRenderer(minmaxcategoryrenderer);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}