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

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

Introduction

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

Prototype

public void setOutlineStroke(Stroke stroke) 

Source Link

Document

Sets the stroke used to outline the plot area and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java

/**
 * /* w ww . java2 s. co  m*/
 *
 * @param title 
 * @param titleFont 
 * @param data ??
 * @param order
 * @param legend 
 * @param tooltips ????
 * @param urls ??URL
 * @param urlGenerator
 *
 * @return 
 */
public static JFreeChart createPieChart(String title, java.awt.Font titleFont, CategoryDataset data,
        TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) {
    MultiplePiePlot plot = new MultiplePiePlot(data);
    plot.setDataExtractOrder(order);

    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
    // pp.setInsets(new Insets(0, 5, 5, 5));
    pp.setBackgroundPaint(null);
    pp.setOutlineStroke(null);
    // plot.setOutlineStroke(null);
    PieToolTipGenerator tooltipGenerator = null;
    if (tooltips) {
        tooltipGenerator = new StandardPieToolTipGenerator();
    }

    // PieURLGenerator urlGenerator = null;
    if (!urls) {
        urlGenerator = null;
    }

    pp.setToolTipGenerator(tooltipGenerator);
    pp.setLabelGenerator(null);
    pp.setURLGenerator(urlGenerator);

    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

From source file:com.tonbeller.jpivot.chart.ChartFactory.java

/**
 * Creates a chart containing multiple pie charts, from a TableDataset.
 *
 * @param title  the chart title./*from  ww  w . ja  v a2 s.c  o m*/
 * @param data  the dataset for the chart.
 * @param extractType  <code>PER_ROW</code> or <code>PER_COLUMN</code> (defined in 
 *                     {@link PiePlot}).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return a pie chart.
 */
public static JFreeChart createPieChart(String title, java.awt.Font titleFont, CategoryDataset data,
        TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) {

    MultiplePiePlot plot = new MultiplePiePlot(data);
    plot.setDataExtractOrder(order);

    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
    //pp.setInsets(new Insets(0, 5, 5, 5));
    pp.setBackgroundPaint(null);
    // no outline around each piechart
    pp.setOutlineStroke(null);
    //plot.setOutlineStroke(null);
    PieToolTipGenerator tooltipGenerator = null;
    if (tooltips) {
        tooltipGenerator = new StandardPieToolTipGenerator();
    }

    //PieURLGenerator urlGenerator = null;
    if (!urls) {
        urlGenerator = null;
    }

    pp.setToolTipGenerator(tooltipGenerator);
    pp.setLabelGenerator(null);
    pp.setURLGenerator(urlGenerator);

    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

From source file:org.jfree.chart.demo.MultiplePieChartDemo2.java

/**
 * Creates a sample chart with the given dataset.
 * //from   w  w w  .  j  av  a  2  s . c  om
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_COLUMN, true, // include legend
            true, false);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineStroke(new BasicStroke(1.0f));
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setBackgroundPaint(null);
    p.setOutlineStroke(null);
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0} ({2})", NumberFormat.getNumberInstance(),
            NumberFormat.getPercentInstance()));
    p.setMaximumLabelWidth(0.35);
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 9));
    p.setInteriorGap(0.30);
    return chart;
}

From source file:edu.monash.merc.struts2.action.TLSumChartAction.java

@SuppressWarnings("unchecked")
public String piechart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Green", l4);
    dataset.setValue("Yellow", l3);
    dataset.setValue("Red", l2);
    dataset.setValue("Black", l1);

    chart = ChartFactory.createPieChart(dt, dataset, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();

    plot.setBackgroundPaint(Color.WHITE);
    //no border//from ww w. j av a  2 s  .  c om
    plot.setOutlineStroke(null);
    //no label
    plot.setLabelGenerator(null);

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(2);
    plot.setLegendLabelGenerator(
            new StandardPieSectionLabelGenerator("{0}={2}", NumberFormat.getNumberInstance(), percentFormat));
    //set specific colors  green, yellow, red and black
    Color[] colors = { new Color(0, 140, 0), new Color(254, 172, 0), new Color(226, 0, 40),
            new Color(0, 0, 0) };
    setColor(plot, dataset, colors);

    chart.setBackgroundPaint(Color.WHITE);
    chart.getTitle().setFont(chart.getTitle().getFont().deriveFont(11.0f));
    return SUCCESS;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

/**
 * Create a simple pie chart without title, legend, label etc.
 * // w  w  w  .j  av a  2  s .c om
 * @param dataset
 *            the dataset to be renderer
 * @param colors
 *            an color array specify each item's color. The order of the
 *            array correspond to the item order in dataset
 * @return a pie chart
 */
public static JFreeChart createPlainPieChart(PieDataset dataset, Color[] colors) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }
    if (colors != null && colors.length != dataset.getItemCount()) {
        throw new IllegalArgumentException("Data have " + dataset.getItemCount() + " values, while we have "
                + colors.length + " colors for them.");
    }

    JFreeChart jfreechart = ChartFactory.createPieChart(null, dataset, false, true, false);
    PiePlot pieplot = (PiePlot) jfreechart.getPlot();
    if (colors != null) {
        for (int i = 0; i < colors.length; i++) {
            pieplot.setSectionPaint(dataset.getKey(i), colors[i]);
        }
    }
    pieplot.setBackgroundPaint(null);
    pieplot.setOutlineStroke(null);
    pieplot.setLabelGenerator(null);
    pieplot.setNoDataMessage(UILabels.STL40001_ERROR_No_DATA.getDescription());
    pieplot.setCircular(true);
    pieplot.setInteriorGap(0.000001);
    return jfreechart;
}

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++;//from  ww w.  j a  va 2s. c  o m
        }
    }
    piePlot.setOutlineVisible(true);
    piePlot.setOutlinePaint(outlinePaint);
    piePlot.setOutlineStroke(outlineStroke);
    piePlot.setSectionOutlinesVisible(true);
    piePlot.setBaseSectionOutlinePaint(outlinePaint);
    piePlot.setBaseSectionOutlineStroke(outlineStroke);
}