Example usage for org.jfree.chart.plot PiePlot getDataset

List of usage examples for org.jfree.chart.plot PiePlot getDataset

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot getDataset.

Prototype

public PieDataset getDataset() 

Source Link

Document

Returns the dataset.

Usage

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void chartMouseMoved(ChartMouseEvent chartMouseEvent) {
    ChartEntity entity = chartMouseEvent.getEntity();

    //      System.out.println(entity.toString());
    if (entity != null) {
        if (entity instanceof PieSectionEntity) {
            PieSectionEntity pieSectionEntity = (PieSectionEntity) entity;
            int index = pieSectionEntity.getSectionIndex();

            PiePlot plot = (PiePlot) chart.getPlot();

            int sectionCount = plot.getDataset().getItemCount();

            for (int i = 0; i < sectionCount; ++i) {
                String key = (String) plot.getDataset().getKey(i);
                if (i == index) {
                    plot.setExplodePercent(key, 0.20);
                } else {
                    plot.setExplodePercent(key, 0.0);
                }//from ww  w .ja  v a2 s .com
            }
            lastSeries = index;
            lastCategory = -1;

            showQueryAction.setSeries(lastSeries);
            showQueryAction.setCategory(lastCategory);
            showQueriesMenuItem.setEnabled(true);
        }

        if (entity instanceof XYItemEntity) {
            XYItemEntity xyItemEntity = (XYItemEntity) entity;
            XYPlot plot = chart.getXYPlot();
            DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) plot.getRenderer();
            if (isTransactionSampleChart && xyItemEntity.getSeriesIndex() < maxTransactionSeries) {
                renderer.setLastSeriesAndCategory(xyItemEntity.getSeriesIndex(), xyItemEntity.getItem());
                lastSeries = xyItemEntity.getSeriesIndex();
                lastCategory = xyItemEntity.getItem();
                showQueryAction.setSeries(lastSeries);
                showQueryAction.setCategory(lastCategory);
                showQueriesMenuItem.setEnabled(true);
                this.setRefreshBuffer(true);
                this.repaint();
            }
        }
    }
}

From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloPieChart.java

protected JFreeChart createGraph() {

    JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, true, false);
    chart.setBackgroundPaint(Color.white);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDataset(dataset);/* w ww  .j  a  v a 2s  . c om*/
    plot.setOutlinePaint(null);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No Klocwork data found.");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));

    // Set colours
    //plot.setOutlinePaint("New", new Color(200, 0, 0));
    int i = 0;
    if (kloConfig.getBuildGraph().isNeww() && kloReport.getNeww() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(200, 0, 0));
        i++;
    }
    if (kloConfig.getBuildGraph().isExisting() && kloReport.getExisting() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 0, 200));
        i++;
    }
    if (kloConfig.getBuildGraph().isFixed() && kloReport.getFixed() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 200, 0));
    }

    //plot.setOutlinePaint("Existing", new Color(0, 0, 200));
    //plot.setOutlinePaint("Fixed", new Color(0, 200, 0));

    return chart;

}

From source file:org.jfree.eastwood.ChartEngine.java

private static void applyColorsToPiePlot(PiePlot plot, Color[] colors) {
    if (colors.length == 1) {
        Color c = colors[0];//ww  w.j a  va 2  s. c  om
        colors = new Color[2];
        colors[0] = c;
        colors[1] = new Color(255 - ((255 - c.getRed()) / 5), 255 - ((255 - c.getGreen()) / 5),
                255 - ((255 - c.getBlue()) / 5));
    }
    PieDataset dataset = plot.getDataset();
    int sectionCount = dataset.getItemCount();
    if (colors.length < sectionCount) { // we need to interpolate some
                                        // colors
        for (int i = 0; i < colors.length - 1; i++) {
            Color c1 = colors[i];
            Color c2 = colors[i + 1];
            int s1 = sectionIndexForColor(i, colors.length, sectionCount);
            int s2 = sectionIndexForColor(i + 1, colors.length, sectionCount);
            for (int s = s1; s <= s2; s++) {
                Color c = interpolatedColor(c1, c2, s - s1, s2 - s1);
                plot.setSectionPaint(dataset.getKey(s), c);
            }
        }
    } else {
        for (int i = 0; i < sectionCount; i++) {
            plot.setSectionPaint(dataset.getKey(i), colors[i]);
        }
    }
}

From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *//*from  www  .j  ava  2 s .co m*/
protected JFreeChart createPieChart() throws JRException {
    JFreeChart jfreeChart = super.createPieChart();

    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
    piePlot.setShadowXOffset(0);
    piePlot.setShadowYOffset(0);
    PieDataset pieDataset = piePlot.getDataset();
    if (pieDataset != null) {
        for (int i = 0; i < pieDataset.getItemCount(); i++) {
            piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);

            //makes pie colors darker
            //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]);
        }
    }
    piePlot.setCircular(true);
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java

@Override
protected JFreeChart createPieChart() throws JRException {
    JFreeChart jfreeChart = super.createPieChart();

    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels && piePlot.getLabelGenerator() != null) {
        piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
    }//  w w w .j  a va2 s.c o m
    piePlot.setShadowXOffset(0);
    piePlot.setShadowYOffset(0);
    PieDataset pieDataset = piePlot.getDataset();
    if (pieDataset != null) {
        for (int i = 0; i < pieDataset.getItemCount(); i++) {
            piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);

            //makes pie colors darker
            //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]);
        }
    }
    piePlot.setCircular(true);
    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

/**
 *
 *//*from  ww  w.j  a v  a2 s.  c om*/
protected JFreeChart createPieChart() throws JRException {
    JFreeChart jfreeChart = super.createPieChart();

    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
    piePlot.setShadowXOffset(5);
    piePlot.setShadowYOffset(10);
    piePlot.setShadowPaint(new GradientPaint(0, getChart().getHeight() / 2, new Color(41, 120, 162), 0,
            getChart().getHeight(), Color.white));
    PieDataset pieDataset = piePlot.getDataset();
    if (pieDataset != null) {
        for (int i = 0; i < pieDataset.getItemCount(); i++) {
            piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);
            //makes pie colors darker
            //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]);
        }
    }

    piePlot.setCircular(true);
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createPieChart() throws JRException {
    JFreeChart jfreeChart = super.createPieChart();
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels && piePlot.getLabelGenerator() != null) {
        piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
    }//from ww w.  j a v a2  s . com
    piePlot.setShadowXOffset(5);
    piePlot.setShadowYOffset(10);
    piePlot.setShadowPaint(new GradientPaint(0, getChart().getHeight() / 2, new Color(41, 120, 162), 0,
            getChart().getHeight(), Color.white));
    PieDataset pieDataset = piePlot.getDataset();
    if (pieDataset != null) {
        for (int i = 0; i < pieDataset.getItemCount(); i++) {
            piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);
            //makes pie colors darker
            //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]);
        }
    }

    piePlot.setCircular(true);
    return jfreeChart;
}