Example usage for org.jfree.chart.renderer.category CategoryItemRenderer setBaseToolTipGenerator

List of usage examples for org.jfree.chart.renderer.category CategoryItemRenderer setBaseToolTipGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category CategoryItemRenderer setBaseToolTipGenerator.

Prototype

public void setBaseToolTipGenerator(CategoryToolTipGenerator generator);

Source Link

Document

Sets the base tool tip generator and sends a org.jfree.chart.event.RendererChangeEvent to all registered listeners.

Usage

From source file:org.fhaes.fhrecorder.view.GraphSummaryOverlay.java

/**
 * This method creates the JFreeChart based on all of the incoming data sets.
 * /* w  w w  .  j  a v a2s . c o  m*/
 * @param eventsDataset This is the data set corresponding to the events bar chart graph.
 * @param recordersDataset This is the data set corresponding to the recorders line graph.
 * @param samplesDataset This is the data set corresponding to the samples line graph.
 * @return This returns a JFreeChart with all 3 of the graphs described.
 */
private static JFreeChart createChart(final CategoryDataset eventsDataset,
        final CategoryDataset recordersDataset, final CategoryDataset samplesDataset) {

    final CategoryItemRenderer eventsRenderer = new BarRenderer();
    ((BarRenderer) eventsRenderer).setBarPainter(new StandardBarPainter()); // Remove shine
    ((BarRenderer) eventsRenderer).setShadowVisible(false);
    eventsRenderer.setSeriesPaint(0, new Color(224, 0, 51));
    eventsRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    final CategoryPlot plot = new CategoryPlot();
    plot.setDataset(eventsDataset);
    plot.setRenderer(eventsRenderer);

    plot.setDomainAxis(new CategoryAxis(""));
    plot.setRangeAxis(new NumberAxis(""));

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    plot.setDomainAxis(new NumericCategoryAxis());

    plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    final CategoryItemRenderer recorderRenderer = new LineAndShapeRenderer(true, false);
    recorderRenderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    recorderRenderer.setSeriesPaint(0, new Color(102, 102, 255));
    recorderRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    // Temporarily removing recorders dataset
    // plot.setDataset(1, recordersDataset);
    // plot.setRenderer(1, recorderRenderer);

    final CategoryItemRenderer samplesRenderer = new LineAndShapeRenderer(true, false);
    samplesRenderer.setSeriesStroke(0, new BasicStroke(2.0f));
    samplesRenderer.setSeriesPaint(0, new Color(0, 153, 0));
    samplesRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setDataset(2, samplesDataset);
    plot.setRenderer(2, samplesRenderer);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    plot.getDomainAxis().setLowerMargin(0.025);
    plot.getDomainAxis().setUpperMargin(0.025);

    final JFreeChart chart = new JFreeChart(plot);

    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()));
    }/*from  ww w .ja  va2 s  . co  m*/
    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:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createStackedBarChart3D(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }// w w  w. java 2  s.  c  om
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }

    // create the chart...
    JFreeChart chart = new JFreeChart("StackedBar Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot,
            legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    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:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java

/**
 * ??3D//from   w  ww  . j a va  2 s .c o m
 *
 * @param title 
 * @param titleFont 
 * @param categoryAxisLabel 
 * @param valueAxisLabel 
 * @param data ??
 * @param orientation ?
 * @param legend 
 * @param tooltips ????
 * @param urls ??URL
 * @param urlGenerator
 *
 * @return ??3D
 */
public static JFreeChart createStackedBarChart3D(String title, java.awt.Font titleFont,
        String categoryAxisLabel, String valueAxisLabel, CategoryDataset data, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls, CategoryURLGenerator urlGenerator) {
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    CategoryToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardCategoryToolTipGenerator();
    }
    if (urls) {
        //            renderer.setItemURLGenerator(urlGenerator);
        renderer.setBaseItemURLGenerator(urlGenerator);
    }
    //        renderer.setToolTipGenerator(toolTipGenerator);
    renderer.setBaseToolTipGenerator(toolTipGenerator);

    CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

From source file:org.owasp.jbrofuzz.graph.canvas.ResponseSizeChart.java

public ChartPanel getPlotCanvas() {

    final JFreeChart chart = ChartFactory.createBarChart("JBroFuzz Response Size Bar Chart", // chart title
            "File Name", // domain axis label
            "Response Size (bytes)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            true // URLs?
    );/*w w w.  ja  v  a  2  s  .c o m*/

    final Plot plot = chart.getPlot();
    plot.setBackgroundImage(ImageCreator.IMG_OWASP_MED.getImage());
    plot.setBackgroundImageAlignment(Align.TOP_RIGHT);

    final CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    return new ChartPanel(chart);

}

From source file:org.owasp.jbrofuzz.graph.canvas.ResponseTimeChart.java

public ChartPanel getPlotCanvas() {

    final JFreeChart chart = ChartFactory.createBarChart("JBroFuzz Response Time Bar Chart", // chart title
            "File Name", // domain axis label
            "Response Time (ms)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            true // URLs?
    );/*from  ww w .ja  va  2s.  c o m*/

    final Plot plot = chart.getPlot();
    plot.setBackgroundImage(ImageCreator.IMG_OWASP_MED.getImage());
    plot.setBackgroundImageAlignment(Align.TOP_RIGHT);

    final CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    return new ChartPanel(chart);

}

From source file:org.owasp.jbrofuzz.graph.canvas.ResponseHeaderSizeChart.java

public ChartPanel getPlotCanvas() {

    final JFreeChart chart = ChartFactory.createBarChart("JBroFuzz Response Header Size Bar Chart", // chart title
            "File Name", // domain axis label
            "Response Header Size (bytes)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            true // URLs?
    );// ww  w .  ja  v a 2 s. co  m

    final Plot plot = chart.getPlot();
    plot.setBackgroundImage(ImageCreator.IMG_OWASP_MED.getImage());
    plot.setBackgroundImageAlignment(Align.TOP_RIGHT);

    final CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    return new ChartPanel(chart);

}

From source file:org.amanzi.awe.distribution.ui.widgets.DistributionChartWidget.java

private CategoryItemRenderer getRenderer(final DistributionChartDataset dataset) {
    final CategoryItemRenderer renderer = new DistributionBarRenderer(dataset);

    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    return renderer;
}

From source file:org.owasp.jbrofuzz.graph.canvas.JaccardIndexChart.java

public ChartPanel getPlotCanvas() {

    final JFreeChart chart = ChartFactory.createBarChart("JBroFuzz Jaccard Index Bar Chart", // chart title
            "File Name", // domain axis label
            "Jaccard Similarity Coefficient", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            true // URLs?
    );//from   ww  w. j a  v a  2 s .c  om

    final Plot plot = chart.getPlot();
    plot.setBackgroundImage(ImageCreator.IMG_OWASP_MED.getImage());
    plot.setBackgroundImageAlignment(Align.TOP_RIGHT);

    final CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    return new ChartPanel(chart);

}

From source file:org.owasp.jbrofuzz.graph.canvas.HammingDistanceChart.java

public ChartPanel getPlotCanvas() {

    final JFreeChart chart = ChartFactory.createBarChart("JBroFuzz Hamming Distance Bar Chart", // chart title
            "File Name", // domain axis label
            "Hamming Distance", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            true // URLs?
    );/*from w w  w  .  j  a v  a 2  s  .c o m*/

    final Plot plot = chart.getPlot();
    plot.setBackgroundImage(ImageCreator.IMG_OWASP_MED.getImage());
    plot.setBackgroundImageAlignment(Align.TOP_RIGHT);

    final CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    return new ChartPanel(chart);
}