org.jfree.chart.labels.StandardPieSectionLabelGenerator Java Examples

The following examples show how to use org.jfree.chart.labels.StandardPieSectionLabelGenerator. 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: HomeAdmin.java    From StudentGradesManageSystem with Apache License 2.0 6 votes vote down vote up
public void makeChartByMap(Map<String, Object> map,String title) {
    DefaultPieDataset dpd = new DefaultPieDataset(); //建立一个默认的饼图
    System.out.println(map);

    dpd.setValue("优", Integer.parseInt(map.get("优").toString()));
    dpd.setValue("良", Integer.parseInt(map.get("良").toString()));
    dpd.setValue("中", Integer.parseInt(map.get("中").toString()));
    dpd.setValue("差", Integer.parseInt(map.get("差").toString()));
    dpd.setValue("不及格", Integer.parseInt(map.get("不及格").toString()));

    JFreeChart chart = ChartFactory.createPieChart(title, dpd, true, true, false);
    PiePlot piePlot = (PiePlot) chart.getPlot();
    piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(("{0}:({2})"), NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    //可以查具体的API文档,第一个参数是标题,第二个参数是一个数据集,第三个参数表示是否显示Legend,第四个参数表示是否显示提示,第五个参数表示图中是否存在URL
    ChartFrame chartFrame = new ChartFrame(title, chart);
    //chart要放在Java容器组件中,ChartFrame继承自java的Jframe类。该第一个参数的数据是放在窗口左上角的,不是正中间的标题。
    chartFrame.pack(); //以合适的大小展现图形
    chartFrame.setVisible(true);//图形是否可见
}
 
Example #2
Source File: PiePlotTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelGenerator field.
 */
@Test
public void testCloning_LegendLabelGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #3
Source File: PiePlotTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelToolTipGenerator field.
 */
@Test
public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelToolTipGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #4
Source File: PiePlotTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelGenerator field.
 */
@Test
public void testCloning_LegendLabelGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #5
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * 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 ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(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 #6
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 #7
Source File: PiePlotTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelToolTipGenerator field.
 */
@Test
public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelToolTipGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #8
Source File: ChartFactory.java    From ccu-historian 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 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 #10
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * 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 ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(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 #11
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 #12
Source File: RarityRepartitionPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JFreeChart initChart() {
	JFreeChart chart = ChartFactory.createPieChart3D("Rarity repartition", getDataSet(), false, true, true);
	PiePlot plot = (PiePlot) chart.getPlot();
	
	for(MTGRarity r : MTGRarity.values())
	{
		plot.setSectionPaint(r.toPrettyString(),r.toColor());
	}
	

	PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"),new DecimalFormat("0.00%"));
	plot.setLabelGenerator(generator);
	
	return chart;
}
 
Example #13
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 #14
Source File: OrdersChartPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JFreeChart initChart() {
	
	JFreeChart chart=null ;
	try {
		if(PropertyUtils.getProperty(new OrderEntry(), p) instanceof Date)
		{
			chart = ChartFactory.createTimeSeriesChart("Orders", "Date", "Value", getTimeDataSet(), true, true,false);

		}
		else
		{
			chart = ChartFactory.createPieChart3D("Orders", getPieDataSet(), false, true, true);
			PiePlot plot = (PiePlot) chart.getPlot();
			PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"),new DecimalFormat("0.00%"));
			plot.setLabelGenerator(generator);
				
		}
	} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
		logger.error(e);
	}
	return chart;
}
 
Example #15
Source File: ChartJFreeChartOutputPie.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initChart(final IScope scope, final String chartname) {
	super.initChart(scope, chartname);

	final PiePlot pp = (PiePlot) chart.getPlot();
	pp.setShadowXOffset(0);
	pp.setShadowYOffset(0);
	if (!this.series_label_position.equals("none")) {
		pp.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} ({2})"));
		if (axesColor != null) {
			pp.setLabelLinkPaint(axesColor);
		}
		pp.setLabelFont(getTickFont());
	}
	if (this.series_label_position.equals("none")) {
		pp.setLabelLinksVisible(false);
		pp.setLabelGenerator(null);

	}
	if (textColor != null) {
		// pp.setLabelPaint(textColor);
		// not for Pie since the label background is always yellow for
		// now...
	}

}
 
Example #16
Source File: PiePlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelToolTipGenerator field.
 */
@Test
public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelToolTipGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #17
Source File: PiePlotTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelGenerator field.
 */
@Test
public void testCloning_LegendLabelGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #18
Source File: PiePlotTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelToolTipGenerator field.
 */
@Test
public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelToolTipGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #19
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 #20
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * 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 ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(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 #21
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 #22
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot} 
 * 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 ring chart.
 */
public static JFreeChart createRingChart(String title,
                                         PieDataset dataset,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

    RingPlot plot = new RingPlot(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 #23
Source File: ChartFactory.java    From opensim-gui 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(
                StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #24
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot} 
 * 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 createRingChart(String title,
                                         PieDataset dataset,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

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

}
 
Example #25
Source File: PiePlotTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelGenerator field.
 */
@Test
public void testCloning_LegendLabelGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #26
Source File: PiePlotTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check cloning of the legendLabelToolTipGenerator field.
 */
@Test
public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException {
    StandardPieSectionLabelGenerator generator
            = new StandardPieSectionLabelGenerator();
    PiePlot p1 = new PiePlot();
    p1.setLegendLabelToolTipGenerator(generator);
    PiePlot p2 = (PiePlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    // change the generator and make sure it only affects p1
    generator.getNumberFormat().setMinimumFractionDigits(2);
    assertFalse(p1.equals(p2));
}
 
Example #27
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 #28
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * 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 ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(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 #29
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 #30
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * 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 ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(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;

}