Example usage for org.jfree.chart.renderer.category BoxAndWhiskerRenderer setBaseFillPaint

List of usage examples for org.jfree.chart.renderer.category BoxAndWhiskerRenderer setBaseFillPaint

Introduction

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

Prototype

public void setBaseFillPaint(Paint paint) 

Source Link

Document

Sets the base fill paint and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java

private void updateChart(SimpleFeatureCollection features, String[] fields) {
    // Setup Box plot
    int fontStyle = java.awt.Font.BOLD;
    FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0];

    CategoryAxis xPlotAxis = new CategoryAxis(EMPTY); // Type
    xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 12));

    NumberAxis yPlotAxis = new NumberAxis("Value"); // Value //$NON-NLS-1$
    yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));
    yPlotAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setMedianVisible(true);//from  w w w.j  ava2 s . com
    renderer.setMeanVisible(false);
    renderer.setFillBox(true);
    renderer.setSeriesFillPaint(0, java.awt.Color.CYAN);
    renderer.setBaseFillPaint(java.awt.Color.CYAN);
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    // Set the scatter data, renderer, and axis into plot
    CategoryDataset dataset = getDataset(features, fields);
    CategoryPlot plot = new CategoryPlot(dataset, xPlotAxis, yPlotAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setRangePannable(false);

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setForegroundAlpha(0.85f);

    // Map the scatter to the first Domain and first Range
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    // 3. Setup Selection
    /*****************************************************************************************
     * CategoryAxis xSelectionAxis = new CategoryAxis(EMPTY);
     * xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false);
     * 
     * NumberAxis ySelectionAxis = new NumberAxis(EMPTY);
     * ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false);
     * 
     * BoxAndWhiskerRenderer selectionRenderer = new BoxAndWhiskerRenderer();
     * selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6));
     * selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot
     * 
     * plot.setDataset(2, new DefaultBoxAndWhiskerCategoryDataset()); plot.setRenderer(2,
     * selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2,
     * ySelectionAxis);
     * 
     * // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2,
     * 0); plot.mapDatasetToRangeAxis(2, 0);
     *****************************************************************************************/

    // 5. Finally, Create the chart with the plot and a legend
    java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20);
    JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite.setChart(chart);
    chartComposite.forceRedraw();
}