Search in sources :

Example 46 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project DevKits by qmjy.

the class FileStorePanel method configurePlot.

private static void configurePlot(JFreeChart chart) {
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint(USED, Color.red);
    plot.setSectionPaint(AVAILABLE, Color.green);
    plot.setExplodePercent(USED, 0.10);
    plot.setSimpleLabels(true);
    PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%"));
    plot.setLabelGenerator(labelGenerator);
}
Also used : StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) DecimalFormat(java.text.DecimalFormat) PiePlot(org.jfree.chart.plot.PiePlot) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator)

Example 47 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.

the class ExpenseBrowse method chartExpense.

public void chartExpense() {
    try {
        Connection con = DriverManager.getConnection(url + db, user, pass);
        Statement st = con.createStatement();
        ResultSet res = null;
        try {
            java.util.Date now = new java.util.Date();
            DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
            Calendar cal = new GregorianCalendar();
            cal.set(Calendar.DAY_OF_YEAR, 1);
            java.util.Date firstday = cal.getTime();
            res = st.executeQuery("select ap_vend, sum(ap_amt) as 'sum' from ap_mstr " + // " inner join vd_mstr on vd_addr = ap_vend " +
            " inner join vod_mstr on vod_id = ap_nbr " + " where ap_vend >= " + "'" + ddfromvend.getSelectedItem().toString() + "'" + " and ap_vend <= " + "'" + ddtovend.getSelectedItem().toString() + "'" + " and ap_effdate >= " + "'" + dfdate.format(dcFrom.getDate()) + "'" + " and ap_effdate <= " + "'" + dfdate.format(dcTo.getDate()) + "'" + " and ap_type = 'E' " + " and ap_status = 'c' " + " group by ap_vend " + ";");
            DefaultPieDataset dataset = new DefaultPieDataset();
            String vend = "";
            while (res.next()) {
                if (res.getString("ap_vend") == null || res.getString("ap_vend").isEmpty()) {
                    vend = "Unassigned";
                } else {
                    vend = res.getString("ap_vend");
                }
                Double amt = res.getDouble("sum");
                if (amt < 0) {
                    amt = amt * -1;
                }
                dataset.setValue(vend, amt);
            }
            JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5027), dataset, false, false, false);
            PiePlot plot = (PiePlot) chart.getPlot();
            // plot.setSectionPaint(KEY1, Color.green);
            // plot.setSectionPaint(KEY2, Color.red);
            // plot.setExplodePercent(KEY1, 0.10);
            // plot.setSimpleLabels(true);
            PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
            plot.setLabelGenerator(gen);
            try {
                ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, (int) (this.getWidth() / 2), (int) (this.getHeight() / 1.2));
            } catch (IOException e) {
                MainFrame.bslog(e);
            }
            ImageIcon myicon = new ImageIcon(chartfilepath);
            myicon.getImage().flush();
            this.pielabel.setIcon(myicon);
            this.repaint();
        // bsmf.MainFrame.show("your chart is complete...go to chartview");
        } catch (SQLException s) {
            MainFrame.bslog(s);
            bsmf.MainFrame.show(getMessageTag(1016, Thread.currentThread().getStackTrace()[1].getMethodName()));
        } finally {
            if (res != null) {
                res.close();
            }
            if (st != null) {
                st.close();
            }
            con.close();
        }
    } catch (Exception e) {
        MainFrame.bslog(e);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) SQLException(java.sql.SQLException) Statement(java.sql.Statement) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) DecimalFormat(java.text.DecimalFormat) Connection(java.sql.Connection) GregorianCalendar(java.util.GregorianCalendar) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) IOException(java.io.IOException) BlueSeerUtils.bsParseDouble(com.blueseer.utl.BlueSeerUtils.bsParseDouble) BlueSeerUtils.currformatDouble(com.blueseer.utl.BlueSeerUtils.currformatDouble) Date(java.sql.Date) JFreeChart(org.jfree.chart.JFreeChart) SQLException(java.sql.SQLException) IOException(java.io.IOException) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) ResultSet(java.sql.ResultSet) PiePlot(org.jfree.chart.plot.PiePlot) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Example 48 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.

the class GLAcctBalRpt3 method chartExpAndInc.

public void chartExpAndInc() {
    try {
        Connection con = DriverManager.getConnection(url + db, user, pass);
        Statement st = con.createStatement();
        ResultSet res = null;
        try {
            java.util.Date now = new java.util.Date();
            DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
            Calendar cal = new GregorianCalendar();
            cal.set(Calendar.DAY_OF_YEAR, 1);
            java.util.Date firstday = cal.getTime();
            res = st.executeQuery("select ac_type, sum(glh_base_amt) as 'sum' from gl_hist inner join ac_mstr on ac_id = glh_acct " + " where glh_effdate >= " + "'" + dfdate.format(firstday) + "'" + " AND glh_effdate <= " + "'" + dfdate.format(now) + "'" + " AND glh_site = " + "'" + ddsite.getSelectedItem().toString() + "'" + " AND ( ac_type = 'E' or ac_type = 'I' ) " + " group by ac_type   ;");
            DefaultPieDataset dataset = new DefaultPieDataset();
            String acct = "";
            while (res.next()) {
                if (res.getString("ac_type") == null || res.getString("ac_type").isEmpty()) {
                    acct = "Unassigned";
                } else {
                    acct = res.getString("ac_type");
                }
                Double amt = res.getDouble("sum");
                if (amt < 0) {
                    amt = amt * -1;
                }
                dataset.setValue(acct, amt);
            }
            JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5026), dataset, true, true, false);
            PiePlot plot = (PiePlot) chart.getPlot();
            // plot.setSectionPaint(KEY1, Color.green);
            // plot.setSectionPaint(KEY2, Color.red);
            // plot.setExplodePercent(KEY1, 0.10);
            // plot.setSimpleLabels(true);
            PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
            plot.setLabelGenerator(gen);
            try {
                ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, (int) (this.getWidth() / 2.5), (int) (this.getHeight() / 2.5));
            } catch (IOException e) {
                MainFrame.bslog(e);
            }
            ImageIcon myicon = new ImageIcon(chartfilepath);
            myicon.getImage().flush();
            this.pielabel.setIcon(myicon);
            this.repaint();
        // bsmf.MainFrame.show("your chart is complete...go to chartview");
        } catch (SQLException s) {
            MainFrame.bslog(s);
            bsmf.MainFrame.show(getMessageTag(1016, Thread.currentThread().getStackTrace()[1].getMethodName()));
        } finally {
            if (res != null) {
                res.close();
            }
            if (st != null) {
                st.close();
            }
            con.close();
        }
    } catch (Exception e) {
        MainFrame.bslog(e);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) SQLException(java.sql.SQLException) Statement(java.sql.Statement) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) DecimalFormat(java.text.DecimalFormat) Connection(java.sql.Connection) GregorianCalendar(java.util.GregorianCalendar) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) IOException(java.io.IOException) BlueSeerUtils.bsParseDouble(com.blueseer.utl.BlueSeerUtils.bsParseDouble) BlueSeerUtils.currformatDouble(com.blueseer.utl.BlueSeerUtils.currformatDouble) Date(java.sql.Date) JFreeChart(org.jfree.chart.JFreeChart) SQLException(java.sql.SQLException) IOException(java.io.IOException) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) ResultSet(java.sql.ResultSet) PiePlot(org.jfree.chart.plot.PiePlot) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Example 49 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.

the class ChartView method piechart_expensebyaccount.

// finance
public void piechart_expensebyaccount() {
    try {
        cleanUpOldChartFile();
        Connection con = DriverManager.getConnection(url + db, user, pass);
        Statement st = con.createStatement();
        ResultSet res = null;
        try {
            DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
            res = st.executeQuery("select glh_acct, ac_desc, sum(glh_amt) as 'sum' from gl_hist inner join ac_mstr on ac_id = glh_acct " + " where glh_effdate >= " + "'" + dfdate.format(dcFrom.getDate()) + "'" + " AND glh_effdate <= " + "'" + dfdate.format(dcTo.getDate()) + "'" + " AND ac_type = 'E' " + " group by glh_acct, ac_desc order by sum desc limit 10  ;");
            DefaultPieDataset dataset = new DefaultPieDataset();
            String acct = "";
            while (res.next()) {
                if (res.getString("glh_acct") == null || res.getString("glh_acct").isEmpty()) {
                    acct = "Unassigned";
                } else {
                    acct = res.getString("ac_desc");
                }
                Double amt = res.getDouble("sum");
                dataset.setValue(acct, amt);
            }
            JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5000), dataset, true, true, false);
            PiePlot plot = (PiePlot) chart.getPlot();
            PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator(("{1} ({2})"), NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
            plot.setLabelGenerator(gen);
            try {
                ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, 900, this.getHeight() / 2);
            } catch (IOException e) {
                MainFrame.bslog(e);
            }
            ImageIcon myicon = new ImageIcon(chartfilepath);
            myicon.getImage().flush();
            this.chartlabel.setIcon(myicon);
            ChartPanel.setVisible(true);
            this.repaint();
        } catch (SQLException s) {
            MainFrame.bslog(s);
        } finally {
            if (res != null)
                res.close();
            if (st != null)
                st.close();
            con.close();
        }
    } catch (Exception e) {
        MainFrame.bslog(e);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) SQLException(java.sql.SQLException) Statement(java.sql.Statement) DecimalFormat(java.text.DecimalFormat) Connection(java.sql.Connection) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) IOException(java.io.IOException) BlueSeerUtils.currformatDouble(com.blueseer.utl.BlueSeerUtils.currformatDouble) JFreeChart(org.jfree.chart.JFreeChart) PrinterException(java.awt.print.PrinterException) SQLException(java.sql.SQLException) IOException(java.io.IOException) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) ResultSet(java.sql.ResultSet) PiePlot(org.jfree.chart.plot.PiePlot) MultiplePiePlot(org.jfree.chart.plot.MultiplePiePlot) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Example 50 with StandardPieSectionLabelGenerator

use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.

the class ChartView method piechart_custAR.

public void piechart_custAR() {
    try {
        cleanUpOldChartFile();
        Connection con = DriverManager.getConnection(url + db, user, pass);
        Statement st = con.createStatement();
        ResultSet res = null;
        try {
            DecimalFormat df = new DecimalFormat("$ #,##0.00", new DecimalFormatSymbols(Locale.getDefault()));
            DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
            res = st.executeQuery("select ar_cust, sum(ar_amt) as 'sum' from ar_mstr " + " where ar_effdate >= " + "'" + dfdate.format(dcFrom.getDate()) + "'" + " AND ar_effdate <= " + "'" + dfdate.format(dcTo.getDate()) + "'" + " AND ar_type = 'I' " + " AND ar_status = 'o' " + " group by ar_cust order by sum desc limit 10  ;");
            DefaultPieDataset dataset = new DefaultPieDataset();
            String acct = "";
            double tot = 0.00;
            while (res.next()) {
                if (res.getString("ar_cust") == null || res.getString("ar_cust").isEmpty()) {
                    acct = "Unassigned";
                } else {
                    acct = res.getString("ar_cust");
                }
                double amt = res.getDouble("sum");
                tot += amt;
                dataset.setValue(acct, amt);
            }
            JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5010) + String.valueOf(currformatDouble(tot)), dataset, true, true, false);
            PiePlot plot = (PiePlot) chart.getPlot();
            PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator(("{1} ({2})"), NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
            plot.setLabelGenerator(gen);
            try {
                ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, 900, this.getHeight() / 2);
            } catch (IOException e) {
                MainFrame.bslog(e);
            }
            ImageIcon myicon = new ImageIcon(chartfilepath);
            myicon.getImage().flush();
            this.chartlabel.setIcon(myicon);
            ChartPanel.setVisible(true);
            this.repaint();
        } catch (SQLException s) {
            MainFrame.bslog(s);
        } finally {
            if (res != null)
                res.close();
            if (st != null)
                st.close();
            con.close();
        }
    } catch (Exception e) {
        MainFrame.bslog(e);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) PieSectionLabelGenerator(org.jfree.chart.labels.PieSectionLabelGenerator) DecimalFormatSymbols(java.text.DecimalFormatSymbols) SQLException(java.sql.SQLException) Statement(java.sql.Statement) DecimalFormat(java.text.DecimalFormat) Connection(java.sql.Connection) StandardPieSectionLabelGenerator(org.jfree.chart.labels.StandardPieSectionLabelGenerator) IOException(java.io.IOException) JFreeChart(org.jfree.chart.JFreeChart) PrinterException(java.awt.print.PrinterException) SQLException(java.sql.SQLException) IOException(java.io.IOException) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) ResultSet(java.sql.ResultSet) PiePlot(org.jfree.chart.plot.PiePlot) MultiplePiePlot(org.jfree.chart.plot.MultiplePiePlot) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Aggregations

StandardPieSectionLabelGenerator (org.jfree.chart.labels.StandardPieSectionLabelGenerator)72 PiePlot (org.jfree.chart.plot.PiePlot)47 JFreeChart (org.jfree.chart.JFreeChart)31 DecimalFormat (java.text.DecimalFormat)30 DefaultPieDataset (org.jfree.data.general.DefaultPieDataset)30 StandardPieToolTipGenerator (org.jfree.chart.labels.StandardPieToolTipGenerator)26 PieSectionLabelGenerator (org.jfree.chart.labels.PieSectionLabelGenerator)24 MultiplePiePlot (org.jfree.chart.plot.MultiplePiePlot)21 File (java.io.File)17 IOException (java.io.IOException)17 Connection (java.sql.Connection)16 ResultSet (java.sql.ResultSet)16 SQLException (java.sql.SQLException)16 Statement (java.sql.Statement)16 DateFormat (java.text.DateFormat)16 SimpleDateFormat (java.text.SimpleDateFormat)16 ImageIcon (javax.swing.ImageIcon)16 BlueSeerUtils.currformatDouble (com.blueseer.utl.BlueSeerUtils.currformatDouble)13 RectangleInsets (org.jfree.ui.RectangleInsets)13 Font (java.awt.Font)12