Search in sources :

Example 1 with DiscPlot

use of net.sourceforge.processdash.ui.lib.chart.DiscPlot in project processdash by dtuma.

the class DiscChart method createDiscChart.

public static JFreeChart createDiscChart(ResultSet data, Map parameters) {
    // data.sortBy(1, true);
    CategoryDataset catData = data.catDataSource();
    PieDataset pieData = null;
    if (catData.getColumnCount() == 1)
        pieData = DatasetUtilities.createPieDatasetForColumn(catData, 0);
    else
        pieData = DatasetUtilities.createPieDatasetForRow(catData, 0);
    DiscPlot plot = new DiscPlot(pieData);
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    plot.setDrawingSupplier(DRAWING_SUPPLIER_FACTORY.newDrawingSupplier());
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    if (parameters.get("skipItemLabels") != null || parameters.get("skipDiscLabels") != null)
        plot.setLabelGenerator(null);
    else if (parameters.get("discLabelFontSize") != null)
        try {
            float fontSize = Float.parseFloat((String) parameters.get("discLabelFontSize"));
            plot.setLabelFont(plot.getLabelFont().deriveFont(fontSize));
        } catch (Exception lfe) {
        }
    if (parameters.get("ellipse") != null)
        ((StandardDiscItemDistributor) plot.getDiscDistributor()).setCircular(false);
    String interiorGap = (String) parameters.get("interiorGap");
    if (interiorGap != null)
        try {
            plot.setInteriorGap(Integer.parseInt(interiorGap) / 100.0);
        } catch (NumberFormatException e) {
        }
    String interiorSpacing = (String) parameters.get("interiorSpacing");
    if (interiorSpacing != null)
        try {
            plot.setInteriorGap(Integer.parseInt(interiorSpacing) / 200.0);
        } catch (NumberFormatException e) {
        }
    return chart;
}
Also used : DiscPlot(net.sourceforge.processdash.ui.lib.chart.DiscPlot) PieDataset(org.jfree.data.general.PieDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

DiscPlot (net.sourceforge.processdash.ui.lib.chart.DiscPlot)1 JFreeChart (org.jfree.chart.JFreeChart)1 CategoryDataset (org.jfree.data.category.CategoryDataset)1 PieDataset (org.jfree.data.general.PieDataset)1 RectangleInsets (org.jfree.ui.RectangleInsets)1