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

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

Introduction

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

Prototype

public void setSectionPaint(int section, Paint paint) 

Source Link

Document

Sets the paint used to fill a section of the pie and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.gephi.desktop.context.ContextPieChart.java

public ContextPieChart() {
    data = new DefaultPieDataset();
    final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false);
    chart.setTitle(new TextTitle());
    chart.setBackgroundPaint(null);//from   w ww .jav a2  s  . c  o  m
    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setShadowPaint(null);
    plot.setSimpleLabels(true);
    plot.setLabelBackgroundPaint(null);
    plot.setLabelOutlineStroke(null);
    plot.setLabelShadowPaint(null);
    plot.setOutlineVisible(false);
    plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelGap(0.5);
    plot.setCircular(true);
    plot.setInteriorGap(0);
    plot.setBackgroundPaint(null);
    plot.setBackgroundAlpha(1f);
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222));
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD));
    chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false);
    ((FlowLayout) chartPanel.getLayout()).setHgap(0);
    ((FlowLayout) chartPanel.getLayout()).setVgap(0);
    chartPanel.setOpaque(false);
    chartPanel.setPopupMenu(null);
}

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);/*ww  w .  ja va2  s.co m*/
    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.pentaho.chart.plugin.jfreechart.chart.pie.JFreePieChartGenerator.java

private void setSeriesPaint(final PiePlot plot, final ChartElement[] seriesElements,
        final ChartTableModel data) {
    final int length = seriesElements.length;
    for (int i = 0; i < length; i++) {
        final ChartElement seriesElement = seriesElements[i];
        final Paint paint = getPaintFromSeries(seriesElement);
        if (paint != null) {
            final Comparable rowName = data.getRowName(i);
            if (rowName != null) {
                plot.setSectionPaint(rowName, paint);
            }//from www. j ava  2  s . c om
        }
    }
}

From source file:org.gephi.desktop.partition.PartitionPie.java

public void setup(Partition partition) {
    data = new DefaultPieDataset();
    for (Part p : partition.getParts()) {
        data.setValue(p.getDisplayName(), p.getPercentage());
    }/*from  w w  w .j a va2  s .  com*/
    final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false);
    chart.setTitle(new TextTitle());
    chart.setBackgroundPaint(null);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setShadowPaint(null);
    //plot.setSimpleLabels(true);
    plot.setLabelBackgroundPaint(Color.WHITE);
    plot.setLabelOutlineStroke(null);
    plot.setLabelShadowPaint(null);
    plot.setOutlineVisible(false);
    plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
    plot.setLabelPaint(Color.BLACK);
    //plot.setLabelGap(0.05);
    plot.setCircular(true);
    plot.setBackgroundPaint(null);
    plot.setBackgroundAlpha(1f);
    for (Part p : partition.getParts()) {
        plot.setSectionPaint(p.getDisplayName(), p.getColor());
    }
    chartPanel = new ChartPanel(chart, true);
    chartPanel.setOpaque(false);
    chartPanel.setPopupMenu(null);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param plot/*from  ww w .j a v a2  s  . com*/
 * @param dataset
 */
public void setColors(PiePlot plot, DefaultPieDataset dataset) {
    if (colors.size() == 0) {
        for (int i = 0; i < rgbs.length / 3; i++) {
            int inx = i * 3;
            colors.add(new Color(rgbs[inx], rgbs[inx + 1], rgbs[inx + 2]));
        }
    }
    List<?> keys = dataset.getKeys();
    for (int i = 0; i < keys.size(); i++) {
        int inx = i % this.colors.size();
        plot.setSectionPaint((Comparable<?>) keys.get(i), this.colors.get(inx));

        //System.out.println("Setting section paint " + keys.get(i).toString() + " " + 
        //  Colors.getColors()[aInt].toString());

    }
}

From source file:uk.ac.lkl.cram.ui.chart.LearningTypeChartMaker.java

/**
 * Create a chart from the provide pie dataset
 *
 * @return a Chart that can be rendered in a ChartPanel
 */// w w w .ja v a  2s .c o m
@Override
protected JFreeChart createChart() {
    //Create a pie chart from the chart factory with no title, a legend and tooltips
    JFreeChart chart = ChartFactory.createPieChart(null, (PieDataset) dataset, true, true, false);
    //Get the plot from the chart
    PiePlot plot = (PiePlot) chart.getPlot();
    //Set the tooltip generator, to be "Practice (12%)"
    plot.setToolTipGenerator(new StandardPieToolTipGenerator(
            "<html><center>{0} ({2})<br/>Double-click for more</center></html>"));
    //Remove shadows from the plot
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);
    //Remove the labels from the plot
    plot.setLabelGenerator(null);
    //Set the colours for the segments
    plot.setSectionPaint(ACQUISITION, ACQUISITION_COLOR);
    plot.setSectionPaint(COLLABORATION, COLLABORATION_COLOR);
    plot.setSectionPaint(DISCUSSION, DISCUSSION_COLOR);
    plot.setSectionPaint(INQUIRY, INQUIRY_COLOR);
    plot.setSectionPaint(PRACTICE, PRACTICE_COLOR);
    plot.setSectionPaint(PRODUCTION, PRODUCTION_COLOR);
    return chart;
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreePieChartData.java

@Override
public JFreeChart getJFreeChart() {
    DefaultPieDataset pieDataset = makeDataSet();

    JFreeChart chart = ChartFactory.createPieChart(title, // Title
            pieDataset, // Dataset
            true // Show legend
            , false, false);/*from   w  w  w.  ja  va 2s  .  c o  m*/
    PiePlot plot = (PiePlot) chart.getPlot();

    StandardPieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0} ({2})");

    plot.setLabelGenerator(gen);
    plot.setMaximumLabelWidth(0.07);
    plot.setLabelFont(plot.getLabelFont().deriveFont(9.0F));

    LegendTitle leg = chart.getLegend();

    leg.setPosition(RectangleEdge.RIGHT);
    if (!colours.isEmpty()) {
        String legends[] = ds.getLegends();

        for (int i = 0; i < ds.getNumSets(); i++) {
            if (legends != null && legends.length > i && colours.size() > i) {
                Color c = colours.get(i);
                plot.setSectionPaint(legends[i], c);
            }
        }
    }

    return chart;

}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.PieChartRenderer.java

public void createChart() {

    PieDataset dataset = (PieDataset) this.datasetStrategy.getDataset();
    report = ChartFactory.createPieChart(this.datasetStrategy.getTitle(), dataset, true, true, false);
    PiePlot plot = (PiePlot) report.getPlot();
    //        plot.setCircular( false );
    plot.setDirection(Rotation.ANTICLOCKWISE);
    /*/*from   ww w.  j  ava  2s  . c  om*/
     * plot.setExplodePercent(0, 0.15D); plot.setExplodePercent(1, 0.15D);
     */
    //        plot.setInteriorGap( PieChartRenderer.INTERIOR_GAP );
    plot.setLabelFont(new Font("Lucida", 0, PieChartRenderer.FONT_SIZE));
    plot.setLabelGap(PieChartRenderer.LABEL_GAP);
    plot.setNoDataMessage("No data available");
    plot.setStartAngle(PieChartRenderer.START_ANGLE);
    Paint[] paints = this.datasetStrategy.getPaintColor();

    for (int i = 0; i < dataset.getItemCount() && i < paints.length; i++) {
        plot.setSectionPaint(dataset.getKey(i), paints[i]);
    }
}

From source file:net.sqs2.omr.result.export.chart.ChartImageWriter.java

private void setSectionPaint(PieDataset dataSet, PiePlot piePlot) {
    Paint outlinePaint = Color.BLACK;
    Stroke outlineStroke = new BasicStroke(1.0f);

    if (this.itemBackgroundImages != null && 0 < this.itemBackgroundImages.length) {
        int index = 0;
        for (Object key : dataSet.getKeys()) {
            int imageIndex = index % this.itemBackgroundImages.length;
            BufferedImage texture = this.itemBackgroundImages[imageIndex];
            Rectangle2D anchor = new Rectangle2D.Double(0, 0, texture.getWidth(), texture.getHeight());
            TexturePaint fillPaint = new TexturePaint(texture, anchor);
            piePlot.setSectionPaint((Comparable<?>) key, fillPaint);
            piePlot.setSectionOutlinePaint((Comparable<?>) key, outlinePaint);
            piePlot.setSectionOutlineStroke((Comparable<?>) key, outlineStroke);
            index++;/*www . j av  a  2s . c  o  m*/
        }
    }
    piePlot.setOutlineVisible(true);
    piePlot.setOutlinePaint(outlinePaint);
    piePlot.setOutlineStroke(outlineStroke);
    piePlot.setSectionOutlinesVisible(true);
    piePlot.setBaseSectionOutlinePaint(outlinePaint);
    piePlot.setBaseSectionOutlineStroke(outlineStroke);
}

From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart.//from  w  ww.  j  a  v  a 2 s .c om
 * 
 * @param dataset
 * @param title
 * @return
 */
protected JFreeChart createPieChart(final PieDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setNoDataMessage(App.getGuiProp("report.nodata.msg"));
    plot.setCircular(true);
    // plot.set
    plot.setLabelGap(0.02);
    plot.setBackgroundPaint(Color.white);
    chart.removeLegend();
    plot.setBackgroundPaint(Color.white);
    Iterator<?> it = dataset.getKeys().iterator();
    int color = 0;
    while (it.hasNext()) {
        plot.setSectionPaint((String) it.next(), COLORS[color]);
        color++;
        if (COLORS.length == color) {
            color = 0;
        }
    }
    plot.setLabelBackgroundPaint(Color.white);
    StandardPieSectionLabelGenerator slbl = new StandardPieSectionLabelGenerator("{0} {2} ({1})",
            new DecimalFormat("#,##0"), new DecimalFormat("0%"));
    plot.setLabelGenerator(slbl);
    plot.setLabelFont(new Font("Helvetica", Font.PLAIN, 14));
    plot.setLabelOutlinePaint(Color.white);
    plot.setLabelShadowPaint(Color.white);
    plot.setShadowPaint(Color.white);
    plot.setIgnoreZeroValues(true);
    return chart;
}