org.jfree.chart.plot.PiePlot Java Examples

The following examples show how to use org.jfree.chart.plot.PiePlot. 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: MouseWheelHandler.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #2
Source File: MouseWheelHandler.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #3
Source File: ScrollHandlerFX.java    From jfreechart-fx with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}
 
Example #4
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a chart that displays multiple pie plots.  The chart object
 * returned by this method uses a {@link MultiplePiePlot} instance as the
 * plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param order  the order that the data is extracted (by row or by column)
 *               (<code>null</code> not permitted).
 * @param legend  include a legend?
 *
 * @return A chart.
 */
public static JFreeChart createMultiplePieChart(String title,
        CategoryDataset dataset, TableOrder order, boolean legend) {

    if (order == null) {
        throw new IllegalArgumentException("Null 'order' argument.");
    }
    MultiplePiePlot plot = new MultiplePiePlot(dataset);
    plot.setDataExtractOrder(order);
    plot.setBackgroundPaint(null);
    plot.setOutlineStroke(null);
    PieToolTipGenerator tooltipGenerator
            = new StandardPieToolTipGenerator();
    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
    pp.setToolTipGenerator(tooltipGenerator);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #5
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Applies the attributes of this theme to a {@link PiePlot} instance.
 * This method also clears any set values for the section paint, outline
 * etc, so that the theme's {@link DrawingSupplier} will be used.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToPiePlot(PiePlot plot) {
    plot.setLabelLinkPaint(this.labelLinkPaint);
    plot.setLabelLinkStyle(this.labelLinkStyle);
    plot.setLabelFont(this.regularFont);
    plot.setShadowGenerator(this.shadowGenerator);

    // clear the section attributes so that the theme's DrawingSupplier
    // will be used
    if (plot.getAutoPopulateSectionPaint()) {
        plot.clearSectionPaints(false);
    }
    if (plot.getAutoPopulateSectionOutlinePaint()) {
        plot.clearSectionOutlinePaints(false);
    }
    if (plot.getAutoPopulateSectionOutlineStroke()) {
        plot.clearSectionOutlineStrokes(false);
    }
}
 
Example #6
Source File: SWTPieChartDemo1.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
    
}
 
Example #7
Source File: MouseWheelHandler.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #8
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<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.
 * @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, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #9
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<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.
 * @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, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #10
Source File: SWTPieChartDemo1.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;        
}
 
Example #11
Source File: JFreeChartTest.java    From testarea-itext5 with GNU Affero General Public License v3.0 6 votes vote down vote up
public static JFreeChart generatePieChart()
{
    DefaultPieDataset dataSet = new DefaultPieDataset();
    dataSet.setValue("China", 30);
    dataSet.setValue("India", 30);
    dataSet.setValue("United States", 40);

    JFreeChart chart = ChartFactory.createPieChart("", dataSet, false, true, false);
    PiePlot piePlot = (PiePlot) chart.getPlot();
    piePlot.setBackgroundPaint(Color.WHITE); // set background color white
    piePlot.setOutlineVisible(false); // remove background border
    piePlot.setLabelGenerator(null); // remove pie section labels
    piePlot.setSectionPaint("China", Color.GRAY);
    piePlot.setSectionPaint("India", Color.GREEN);
    piePlot.setSectionPaint("United States", Color.BLUE);
    piePlot.setShadowPaint(Color.WHITE);

    return chart;
}
 
Example #12
Source File: MouseWheelHandler.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #13
Source File: ChartJFreeChartOutputPie.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void createNewSerie(final IScope scope, final String serieid) {
	// final ChartDataSeries dataserie = chartdataset.getDataSeries(scope,
	// serieid);
	if(!IdPosition.containsKey(serieid)) {
		final PiePlot plot = (PiePlot) this.chart.getPlot();

		// final DefaultPieDataset firstdataset = (DefaultPieDataset)
		// plot.getDataset();

		nbseries++;
		IdPosition.put(serieid, nbseries - 1);
		if (getStyle().equals(IKeyword.EXPLODED)) {
			plot.setExplodePercent(serieid, 0.20);
		}
	}
	// DEBUG.LOG("new serie"+serieid+" at
	// "+IdPosition.get(serieid)+" jfds "+jfreedataset.size()+" datasc "+"
	// nbse "+nbseries);
}
 
Example #14
Source File: TypeRepartitionPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JFreeChart initChart() {
	
	JFreeChart chart = ChartFactory.createPieChart3D("Type repartition", getDataSet(), false,true, true);

	PiePlot plot = (PiePlot) chart.getPlot();
	plot.setSectionPaint("B", Color.BLACK);
	plot.setSectionPaint("W", Color.WHITE);
	plot.setSectionPaint("U", Color.BLUE);
	plot.setSectionPaint("G", Color.GREEN);
	plot.setSectionPaint("R", Color.RED);
	plot.setSectionPaint("multi", Color.YELLOW);
	plot.setSectionPaint("uncolor", Color.GRAY);

	PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"),
			new DecimalFormat("0.00%"));
	plot.setLabelGenerator(generator);
	
	return chart;
}
 
Example #15
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<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.
 * @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, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #16
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the attributes of this theme to a {@link PiePlot} instance.
 * This method also clears any set values for the section paint, outline
 * etc, so that the theme's {@link DrawingSupplier} will be used.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToPiePlot(PiePlot plot) {
    plot.setLabelLinkPaint(this.labelLinkPaint);
    plot.setLabelLinkStyle(this.labelLinkStyle);
    plot.setLabelFont(this.regularFont);

    // clear the section attributes so that the theme's DrawingSupplier
    // will be used
    if (plot.getAutoPopulateSectionPaint()) {
        plot.clearSectionPaints(false);
    }
    if (plot.getAutoPopulateSectionOutlinePaint()) {
        plot.clearSectionOutlinePaints(false);
    }
    if (plot.getAutoPopulateSectionOutlineStroke()) {
        plot.clearSectionOutlineStrokes(false);
    }
}
 
Example #17
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<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.
 * @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, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #18
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Applies the attributes of this theme to a {@link PiePlot} instance.
 * This method also clears any set values for the section paint, outline
 * etc, so that the theme's {@link DrawingSupplier} will be used.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToPiePlot(PiePlot plot) {
    plot.setLabelLinkPaint(this.labelLinkPaint);
    plot.setLabelLinkStyle(this.labelLinkStyle);
    plot.setLabelFont(this.regularFont);
    plot.setShadowGenerator(this.shadowGenerator);

    // clear the section attributes so that the theme's DrawingSupplier
    // will be used
    if (plot.getAutoPopulateSectionPaint()) {
        plot.clearSectionPaints(false);
    }
    if (plot.getAutoPopulateSectionOutlinePaint()) {
        plot.clearSectionOutlinePaints(false);
    }
    if (plot.getAutoPopulateSectionOutlineStroke()) {
        plot.clearSectionOutlineStrokes(false);
    }
}
 
Example #19
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Applies the attributes of this theme to a {@link PiePlot} instance.
 * This method also clears any set values for the section paint, outline
 * etc, so that the theme's {@link DrawingSupplier} will be used.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToPiePlot(PiePlot plot) {
    plot.setLabelLinkPaint(this.labelLinkPaint);
    plot.setLabelLinkStyle(this.labelLinkStyle);
    plot.setLabelFont(this.regularFont);
    plot.setShadowGenerator(this.shadowGenerator);

    // clear the section attributes so that the theme's DrawingSupplier
    // will be used
    if (plot.getAutoPopulateSectionPaint()) {
        plot.clearSectionPaints(false);
    }
    if (plot.getAutoPopulateSectionOutlinePaint()) {
        plot.clearSectionOutlinePaints(false);
    }
    if (plot.getAutoPopulateSectionOutlineStroke()) {
        plot.clearSectionOutlineStrokes(false);
    }
}
 
Example #20
Source File: MouseWheelHandler.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #21
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Applies the attributes of this theme to a {@link PiePlot} instance.
 * This method also clears any set values for the section paint, outline
 * etc, so that the theme's {@link DrawingSupplier} will be used.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToPiePlot(PiePlot plot) {
    plot.setLabelLinkPaint(this.labelLinkPaint);
    plot.setLabelLinkStyle(this.labelLinkStyle);
    plot.setLabelFont(this.regularFont);
    plot.setShadowGenerator(this.shadowGenerator);

    // clear the section attributes so that the theme's DrawingSupplier
    // will be used
    if (plot.getAutoPopulateSectionPaint()) {
        plot.clearSectionPaints(false);
    }
    if (plot.getAutoPopulateSectionOutlinePaint()) {
        plot.clearSectionOutlinePaints(false);
    }
    if (plot.getAutoPopulateSectionOutlineStroke()) {
        plot.clearSectionOutlineStrokes(false);
    }
}
 
Example #22
Source File: SWTPieChartDemo1.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
    
}
 
Example #23
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance 
 * as the plot.
 *
 * @param title  the chart title (<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.
 * @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,
                                        PieDataset dataset,
                                        boolean legend,
                                        boolean tooltips,
                                        boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #24
Source File: ManaRepartitionPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JFreeChart initChart() {
	
	JFreeChart chart = ChartFactory.createPieChart3D("Color repartition", // chart title
			getDataSet(), // data
			false, // include legend
			true, true);
	
	PiePlot plot = (PiePlot) chart.getPlot();
	
	for(MTGColor c : MTGColor.values())
	{
		plot.setSectionPaint(c,c.toColor());
		
	}
	plot.setSectionPaint("Multi", Color.YELLOW);
	plot.setSectionPaint("multi", Color.YELLOW);
	
	plot.setSimpleLabels(true);

	PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{1}", new DecimalFormat("0"),
			new DecimalFormat("0.00%"));
	plot.setLabelGenerator(generator);

	return chart;
}
 
Example #25
Source File: PieChartDemo1.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    plot.setNoDataMessage("No data available");
    plot.setSimpleLabels(true);
    return chart;
    
}
 
Example #26
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a pie chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<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.
 * @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, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #27
Source File: PieChart3DTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Using a regular pie chart, we replace the dataset with null.  Expect to
 * receive notification of a chart change event, and (of course) the
 * dataset should be null.
 */
public void testReplaceDatasetOnPieChart() {
    LocalListener l = new LocalListener();
    this.pieChart.addChangeListener(l);
    PiePlot plot = (PiePlot) this.pieChart.getPlot();
    plot.setDataset(null);
    assertEquals(true, l.flag);
    assertNull(plot.getDataset());
}
 
Example #28
Source File: PieChartTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Using a regular pie chart, we replace the dataset with null.  Expect to
 * receive notification of a chart change event, and (of course) the
 * dataset should be null.
 */
@Test
public void testReplaceDatasetOnPieChart() {
    LocalListener l = new LocalListener();
    this.pieChart.addChangeListener(l);
    PiePlot plot = (PiePlot) this.pieChart.getPlot();
    plot.setDataset(null);
    assertEquals(true, l.flag);
    assertNull(plot.getDataset());
}
 
Example #29
Source File: PiePlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the default base section paint is not null, and that you
 * can never set it to null.
 */
public void testGetBaseSectionPaint() {
    PiePlot plot = new PiePlot();
    assertNotNull(plot.getBaseSectionPaint());

    boolean pass = false;
    try {
        plot.setBaseSectionPaint(null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #30
Source File: PieChart3DTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Using a regular pie chart, we replace the dataset with null.  Expect to
 * receive notification of a chart change event, and (of course) the
 * dataset should be null.
 */
@Test
public void testReplaceDatasetOnPieChart() {
    LocalListener l = new LocalListener();
    this.pieChart.addChangeListener(l);
    PiePlot plot = (PiePlot) this.pieChart.getPlot();
    plot.setDataset(null);
    assertEquals(true, l.flag);
    assertNull(plot.getDataset());
}