Search in sources :

Example 6 with DefaultPieDataset

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;
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) Account(jgnash.engine.Account) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) HashMap(java.util.HashMap) PayeeMatcher(jgnash.engine.search.PayeeMatcher) BigDecimal(java.math.BigDecimal) Transaction(jgnash.engine.Transaction) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with DefaultPieDataset

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;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) ArrayList(java.util.ArrayList) JFreeChart(org.jfree.chart.JFreeChart)

Example 8 with DefaultPieDataset

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;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Example 9 with DefaultPieDataset

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;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardPieToolTipGenerator(org.jfree.chart.labels.StandardPieToolTipGenerator) Color(java.awt.Color) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) RectangleInsets(org.jfree.ui.RectangleInsets) PiePlot(org.jfree.chart.plot.PiePlot) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) JFreeChart(org.jfree.chart.JFreeChart) Paint(java.awt.Paint)

Example 10 with DefaultPieDataset

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;
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset)

Aggregations

DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)14 JFreeChart (org.jfree.chart.JFreeChart)4 PiePlot (org.jfree.chart.plot.PiePlot)4 StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)3 Font (java.awt.Font)2 BigDecimal (java.math.BigDecimal)2 Account (jgnash.engine.Account)2 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)2 Color (java.awt.Color)1 Paint (java.awt.Paint)1 TexturePaint (java.awt.TexturePaint)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1