org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator Java Examples

The following examples show how to use org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #2
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #3
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #4
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #5
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #6
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis 
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 * 
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {
    
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
       
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
            renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);
}
 
Example #7
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis 
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 * 
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {
    
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
       
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
            renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);
}
 
Example #8
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #9
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value 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.
 *
 * @return A box and whisker chart.
 *
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #10
Source File: BoxAndWhiskerToolTipGeneratorTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Simple check that hashCode is implemented.
 */
public void testHashCode() {
    BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
    BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator();
    assertTrue(g1.equals(g2));
    assertTrue(g1.hashCode() == g2.hashCode());
}
 
Example #11
Source File: CategoryBoxplot.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public JFreeChart getChart() {
    if (chart == null) {
        createDataset();
        chart = ChartFactory.createBarChart(getTitle(),
                // chart title
                "Category",
                // domain axis label
                "Value",
                // range axis label
                dataset,
                // data
                PlotOrientation.VERTICAL,
                // orientation
                false,
                // include legend
                true,
                // tooltips?
                false
        // URLs?
        );
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        CategoryAxis rangeAxis = plot.getDomainAxis();
        rangeAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        renderer.setFillBox(true);
        renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        // TODO reactivate if newer jfree is used
        // renderer.setMeanVisible(isMeanVisible);
        plot.setRenderer(renderer);
    }

    return chart;
}
 
Example #12
Source File: ResultsProccessor.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
    //calcMeans();
    
    // Create JFreeChart Dataset
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset( );
    
    
    HashMap<String, ArrayList<Double> > measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, ArrayList<Double> > measure : measuresFirst.entrySet())
    {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();
        
        for (Map.Entry<String, HashMap<String, ArrayList<Double> >> entry : algorithmMeasures.entrySet())
        {
            String alg = entry.getKey();
            ArrayList<Double> measureValues = entry.getValue().get(measureName);
            
            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length()-1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);
            
            dataset.add(measureValues, aName, measureName);
        }
        
        // Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
        final CategoryAxis xAxis = new CategoryAxis("Algorithm");
        final NumberAxis yAxis = new NumberAxis("Value");
        yAxis.setAutoRangeIncludesZero(false);
        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        
        // Black and White
        int numItems = algorithmMeasures.size();
        for(int i=0;i<numItems;i++)
        {
            Color color = Color.DARK_GRAY;
            if(i%2 == 1)
            {
                color = Color.LIGHT_GRAY;
            }
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesOutlinePaint(i, Color.BLACK);
        }
        
        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

        Font font = new Font("SansSerif", Font.BOLD, 10);
        //ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
        JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
        //StandardChartTheme.createLegacyTheme().apply(jchart);
     
        int width = 640 * 2; /* Width of the image */
        int height = 480 * 2; /* Height of the image */ 

        // JPEG
        File chart = new File( outName + "_" + measureName + "_boxplot.jpg" );
        ChartUtilities.saveChartAsJPEG( chart , jchart , width , height );

        // SVG
        SVGGraphics2D g2 = new SVGGraphics2D(width, height);
        Rectangle r = new Rectangle(0, 0, width, height);
        jchart.draw(g2, r);
        File BarChartSVG = new File( outName + "_" + measureName + "_boxplot.svg" );
        SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
    }
    
}
 
Example #13
Source File: BoxAndWhiskerToolTipGeneratorTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check to ensure that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
    assertTrue(g1 instanceof PublicCloneable);
}