use of org.jfree.chart.plot.PiePlot in project MtgDesktopCompanion by nicho92.
the class ManaRepartitionPanel method refresh.
private void refresh() {
this.removeAll();
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
"Color repartition", // data
getManaRepartitionDataSet(), // include legend
false, true, true);
pane = new ChartPanel(chart);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("Black", Color.BLACK);
plot.setSectionPaint("White", Color.WHITE);
plot.setSectionPaint("Blue", Color.BLUE);
plot.setSectionPaint("Green", Color.GREEN);
plot.setSectionPaint("Red", Color.RED);
plot.setSectionPaint("Multi", Color.YELLOW);
plot.setSectionPaint("Uncolor", Color.GRAY);
plot.setSectionPaint("black", Color.BLACK);
plot.setSectionPaint("white", Color.WHITE);
plot.setSectionPaint("blue", Color.BLUE);
plot.setSectionPaint("green", Color.GREEN);
plot.setSectionPaint("red", Color.RED);
plot.setSectionPaint("multi", Color.YELLOW);
plot.setSectionPaint("uncolor", Color.GRAY);
plot.setSimpleLabels(true);
PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
plot.setLabelGenerator(generator);
this.add(pane, BorderLayout.CENTER);
this.revalidate();
this.repaint();
}
use of org.jfree.chart.plot.PiePlot in project tdq-studio-se by Talend.
the class ChartDecorator method decorate.
/**
* DOC bZhou Comment method "decorate".
*
* @param chart
*/
public static void decorate(JFreeChart chart, PlotOrientation orientation) {
if (chart != null) {
// TDQ-11522: Set white background on charts in the editors
chart.setBackgroundPaint(Color.white);
// TDQ-11522~
Plot plot = chart.getPlot();
if (plot instanceof CategoryPlot) {
decorateCategoryPlot(chart, orientation);
CategoryDataset dataset = chart.getCategoryPlot().getDataset();
int rowCount = dataset != null ? dataset.getRowCount() : 20;
for (int i = 0; i < rowCount; i++) {
// by zshen bug 14173 add the color in the colorList when chart need more the color than 8.
if (i >= COLOR_LIST.size()) {
COLOR_LIST.add(generateRandomColor(COLOR_LIST));
}
// ~14173
((CategoryPlot) plot).getRenderer().setSeriesPaint(i, COLOR_LIST.get(i));
}
} else if (plot instanceof XYPlot) {
decorateXYPlot(chart);
int count = chart.getXYPlot().getDataset().getSeriesCount();
for (int i = 0; i < count; i++) {
// by zshen bug 14173 add the color in the colorList when chart need the colors more than 8.
if (i >= COLOR_LIST.size()) {
COLOR_LIST.add(generateRandomColor(COLOR_LIST));
}
// ~14173
((XYPlot) plot).getRenderer().setSeriesPaint(i, COLOR_LIST.get(i));
}
} else if (plot instanceof PiePlot) {
decoratePiePlot(chart);
// ADD msjian TDQ-8046 2013-10-17: add the color's control for pie chart
PieDataset piedataset = ((PiePlot) plot).getDataset();
for (int i = 0; i < piedataset.getItemCount(); i++) {
if (i >= PIE_COLOR_LIST.size()) {
PIE_COLOR_LIST.add(generateRandomColor(PIE_COLOR_LIST));
}
Comparable<?> key = piedataset.getKey(i);
((PiePlot) plot).setSectionPaint(key, PIE_COLOR_LIST.get(i));
}
// TDQ-8046~
}
}
}
use of org.jfree.chart.plot.PiePlot in project tdq-studio-se by Talend.
the class ChartDecorator method decorateDuplicatePieChart.
public static void decorateDuplicatePieChart(JFreeChart chart) {
if (chart != null) {
Plot plot = chart.getPlot();
if (plot instanceof PiePlot) {
decoratePiePlot(chart);
// ADD msjian TDQ-8046 2013-10-17: add the color's control for pie chart
PieDataset piedataset = ((PiePlot) plot).getDataset();
for (int i = 0; i < piedataset.getItemCount(); i++) {
if (i >= DUPLICATE_PIE_COLOR_LIST.size()) {
DUPLICATE_PIE_COLOR_LIST.add(generateRandomColor(DUPLICATE_PIE_COLOR_LIST));
}
Comparable<?> key = piedataset.getKey(i);
((PiePlot) plot).setSectionPaint(key, DUPLICATE_PIE_COLOR_LIST.get(i));
}
// TDQ-8046~
}
}
}
use of org.jfree.chart.plot.PiePlot in project pdfbox-graphics2d by rototor.
the class MultiPageTest method createChartCategory.
/**
* Creates a sample chart for the given dataset.
*
* @param dataset
* the dataset.
*
* @return A sample chart.
*/
private JFreeChart createChartCategory(final CategoryDataset dataset) {
final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset, TableOrder.BY_COLUMN, false, true, false);
chart.setBackgroundPaint(new Color(216, 255, 216));
final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
final JFreeChart subchart = plot.getPieChart();
// final StandardLegend legend = new StandardLegend();
// legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8));
// legend.setAnchor(Legend.SOUTH);
// subchart.setLegend(legend);
plot.setLimit(0.10);
final PiePlot p = (PiePlot) subchart.getPlot();
// p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
p.setInteriorGap(0.30);
return chart;
}
use of org.jfree.chart.plot.PiePlot in project dhis2-core by dhis2.
the class DefaultChartService method getMultiplePieChart.
private JFreeChart getMultiplePieChart(PlotData plotData, CategoryDataset[] dataSets) {
JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart(plotData.getName(), dataSets[0], TableOrder.BY_ROW, !plotData.isHideLegend(), false, false);
setBasicConfig(multiplePieChart, plotData);
if (multiplePieChart.getLegend() != null) {
multiplePieChart.getLegend().setItemFont(SUB_TITLE_FONT);
}
MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot();
JFreeChart pieChart = multiplePiePlot.getPieChart();
pieChart.setBackgroundPaint(DEFAULT_BACKGROUND_COLOR);
pieChart.getTitle().setFont(SUB_TITLE_FONT);
PiePlot piePlot = (PiePlot) pieChart.getPlot();
piePlot.setBackgroundPaint(DEFAULT_BACKGROUND_COLOR);
piePlot.setOutlinePaint(DEFAULT_BACKGROUND_COLOR);
piePlot.setLabelFont(LABEL_FONT);
piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}"));
piePlot.setSimpleLabels(true);
piePlot.setIgnoreZeroValues(true);
piePlot.setIgnoreNullValues(true);
piePlot.setShadowXOffset(0d);
piePlot.setShadowYOffset(0d);
for (int i = 0; i < dataSets[0].getColumnCount(); i++) {
piePlot.setSectionPaint(dataSets[0].getColumnKey(i), COLORS[(i % COLORS.length)]);
}
return multiplePieChart;
}
Aggregations