use of org.jfree.data.general.DefaultPieDataset in project jgnash by ccavanaugh.
the class PayeePieChart method createPieDataSet.
private PieDataset[] createPieDataSet(final Account a) {
final DefaultPieDataset[] returnValue = new DefaultPieDataset[2];
returnValue[CREDIT] = new DefaultPieDataset();
returnValue[DEBIT] = new DefaultPieDataset();
if (a != null) {
//System.out.print("Account = "); System.out.println(a);
Map<String, BigDecimal> names = new HashMap<>();
List<TranTuple> list = getTransactions(a, new ArrayList<>(), startField.getLocalDate(), endField.getLocalDate());
CurrencyNode currency = a.getCurrencyNode();
for (final TranTuple tranTuple : list) {
Transaction tran = tranTuple.transaction;
Account account = tranTuple.account;
String payee = tran.getPayee();
BigDecimal sum = tran.getAmount(account);
sum = sum.multiply(account.getCurrencyNode().getExchangeRate(currency));
if (useFilters.isSelected()) {
for (String aFilterList : filterList) {
PayeeMatcher pm = new PayeeMatcher(aFilterList, false);
if (pm.matches(tran)) {
payee = aFilterList;
//System.out.println(filterList.get(i));
break;
}
}
}
if (names.containsKey(payee)) {
sum = sum.add(names.get(payee));
}
names.put(payee, sum);
}
for (final Map.Entry<String, BigDecimal> entry : names.entrySet()) {
BigDecimal value = entry.getValue();
if (value.compareTo(BigDecimal.ZERO) == -1) {
value = value.negate();
returnValue[DEBIT].setValue(entry.getKey(), value);
} else {
returnValue[CREDIT].setValue(entry.getKey(), value);
}
}
}
return returnValue;
}
use of org.jfree.data.general.DefaultPieDataset in project gephi by gephi.
the class ColumnValuesFrequency method buildPieChart.
public JFreeChart buildPieChart(final Map<Object, Integer> valuesFrequencies) {
final ArrayList<Object> values = new ArrayList<>(valuesFrequencies.keySet());
DefaultPieDataset pieDataset = new DefaultPieDataset();
for (Object value : values) {
pieDataset.setValue(value != null ? "'" + AttributeUtils.print(value) + "'" : "null", valuesFrequencies.get(value));
}
JFreeChart chart = ChartFactory.createPieChart(NbBundle.getMessage(ColumnValuesFrequency.class, "ColumnValuesFrequency.report.piechart.title"), pieDataset, false, true, false);
return chart;
}
use of org.jfree.data.general.DefaultPieDataset in project Openfire by igniterealtime.
the class GraphEngine method getPieChart.
/**
* Creates a Pie Chart based on map.
*
* @return the Pie Chart generated.
*/
public JFreeChart getPieChart(Map<String, Double> pieValues) {
DefaultPieDataset dataset = new DefaultPieDataset();
for (String key : pieValues.keySet()) {
dataset.setValue(key, pieValues.get(key));
}
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
null, // data
dataset, // include legend
true, true, false);
chart.setBackgroundPaint(Color.white);
chart.setBorderVisible(false);
chart.setBorderPaint(null);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionOutlinesVisible(false);
plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(true);
plot.setLabelGap(0.02);
plot.setOutlinePaint(null);
plot.setLabelLinksVisible(false);
plot.setLabelGenerator(null);
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
plot.setStartAngle(270);
plot.setDirection(Rotation.ANTICLOCKWISE);
plot.setForegroundAlpha(0.60f);
plot.setInteriorGap(0.33);
return chart;
}
use of org.jfree.data.general.DefaultPieDataset in project EnrichmentMapApp by BaderLab.
the class ChartUtil method createRadialHeatMapLegend.
public static JFreeChart createRadialHeatMapLegend(List<EMDataSet> dataSets, ChartOptions options) {
// All the slices must have the same size
final DefaultPieDataset pieDataset = new DefaultPieDataset();
for (EMDataSet ds : dataSets) pieDataset.setValue(ds.getName(), 1);
JFreeChart chart = ChartFactory.createPieChart(// chart title
null, // data
pieDataset, // include legend
false, // tooltips
true, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(UIManager.getColor("Table.background"));
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
final PiePlot plot = (PiePlot) chart.getPlot();
plot.setCircular(true);
plot.setOutlineVisible(false);
plot.setBackgroundPaint(UIManager.getColor("Table.background"));
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setShadowPaint(TRANSPARENT_COLOR);
plot.setShadowXOffset(0.0);
plot.setShadowYOffset(0.0);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
plot.setLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
plot.setLabelPaint(UIManager.getColor("Label.foreground"));
plot.setLabelBackgroundPaint(TRANSPARENT_COLOR);
plot.setLabelOutlinePaint(TRANSPARENT_COLOR);
plot.setLabelShadowPaint(TRANSPARENT_COLOR);
plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0}"));
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
if (// UP, ZERO, DOWN:
colors == null || colors.size() < 3)
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
int total = dataSets.size();
int v = total / -2;
for (EMDataSet ds : dataSets) {
plot.setSectionPaint(ds.getName(), ColorUtil.getColor(v, -total, total, colors.get(2), colors.get(1), colors.get(0)));
v++;
}
return chart;
}
use of org.jfree.data.general.DefaultPieDataset in project cubrid-manager by CUBRID.
the class VolumeFolderInfoEditor method createDataset.
/**
* create the dataset
*
* @param dbSpaceInfo DbSpaceInfo
* @return dataset
*/
private DefaultPieDataset createDataset(DbSpaceInfo dbSpaceInfo) {
int freeSize = dbSpaceInfo.getFreepage();
int totalSize = dbSpaceInfo.getTotalpage();
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue(Messages.chartMsgUsedSize, new Double(totalSize - freeSize));
dataset.setValue(Messages.chartMsgFreeSize, new Double(freeSize));
return dataset;
}
Aggregations