Search in sources :

Example 1 with IntervalCategoryToolTipGenerator

use of org.jfree.chart.labels.IntervalCategoryToolTipGenerator in project SIMVA-SoS by SESoS.

the class ChartFactory method createGanttChart.

/**
 * Creates a Gantt chart using the supplied attributes plus default values
 * where required.  The chart object returned by this method uses a
 * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
 * for the domain axis, a {@link DateAxis} as the range axis, and a
 * {@link GanttRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param dateAxisLabel  the label for the date axis
 *                       (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A Gantt chart.
 */
public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) {
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    DateAxis dateAxis = new DateAxis(dateAxisLabel);
    CategoryItemRenderer renderer = new GanttRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance()));
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) IntervalCategoryToolTipGenerator(org.jfree.chart.labels.IntervalCategoryToolTipGenerator) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) GanttRenderer(org.jfree.chart.renderer.category.GanttRenderer) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Aggregations

CategoryAxis (org.jfree.chart.axis.CategoryAxis)1 DateAxis (org.jfree.chart.axis.DateAxis)1 IntervalCategoryToolTipGenerator (org.jfree.chart.labels.IntervalCategoryToolTipGenerator)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)1 GanttRenderer (org.jfree.chart.renderer.category.GanttRenderer)1 StandardCategoryURLGenerator (org.jfree.chart.urls.StandardCategoryURLGenerator)1