Example usage for org.jfree.chart.labels IntervalCategoryToolTipGenerator IntervalCategoryToolTipGenerator

List of usage examples for org.jfree.chart.labels IntervalCategoryToolTipGenerator IntervalCategoryToolTipGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.labels IntervalCategoryToolTipGenerator IntervalCategoryToolTipGenerator.

Prototype

public IntervalCategoryToolTipGenerator(String labelFormat, DateFormat formatter) 

Source Link

Document

Creates a new generator with the specified date formatter.

Usage

From source file:com.googlecode.logVisualizer.chart.turnrundownGantt.GanttChartBuilder.java

private JFreeChart createChart(final SlidingGanttCategoryDataset dataset) {
    this.dataset = dataset;
    final JFreeChart chart = ChartFactory.createGanttChart(getTitle(), null, null, dataset, false, true, false);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    final CategoryItemRenderer renderer = plot.getRenderer();

    plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.15f);
    plot.setRangeAxis(new FixedZoomNumberAxis());
    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.getRangeAxis().setAutoRange(false);
    plot.setRangeGridlinePaint(Color.black);
    setBarShadowVisible(chart, false);/*  www .  ja v  a2s . c  om*/

    for (final AreaInterval ai : ((TurnRundownDataset) dataset.getUnderlyingDataset()).getDataset())
        if (lastTurnNumber < ai.getEndTurn())
            lastTurnNumber = ai.getEndTurn();
    addDayMarkers(plot);
    addLevelMarkers(plot);
    addFamiliarMarkers(plot);

    plot.getRangeAxis().setUpperBound(lastTurnNumber + 10);

    renderer.setSeriesPaint(0, Color.red);
    renderer.setBaseToolTipGenerator(
            new IntervalCategoryToolTipGenerator("{1}, {3} - {4}", NumberFormat.getInstance()));

    return chart;
}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createGanttChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    DateAxis dateAxis = new DateAxis(valueAxisLabel);

    CategoryItemRenderer renderer = new GanttRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance()));
    }/*  w ww.  j  av  a 2s  .  com*/
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart chart = new JFreeChart("Gantt Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;

}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
 * 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.    
 *    /*www  .ja  va 2 s.  com*/
 * @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);

    return chart;

}

From source file:KIDLYFactory.java

/**
 * 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.//from www. j  a va  2  s  .  c  om
 */
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;

}

From source file:org.jfree.chart.ChartFactory.java

/**
 * 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} permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           ({@code null} permitted).
 * @param dateAxisLabel  the label for the date axis
 *                       ({@code null} permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 *
 * @return A Gantt chart.//  www  .ja  v  a2s .co m
 */
public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel,
        IntervalCategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    DateAxis dateAxis = new DateAxis(dateAxisLabel);

    CategoryItemRenderer renderer = new GanttRenderer();
    renderer.setDefaultToolTipGenerator(
            new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance()));

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart chart = new JFreeChart(title, plot);
    currentTheme.apply(chart);
    return chart;

}