Example usage for org.jfree.chart ChartFactory createPieChart

List of usage examples for org.jfree.chart ChartFactory createPieChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createPieChart.

Prototype

public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        boolean urls) 

Source Link

Document

Creates a pie chart with default settings.

Usage

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *//*ww w  . j a v  a 2  s.  com*/
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(
            (String) evaluateExpression(getChart().getTitleExpression()), (PieDataset) getDataset(),
            isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPlot.getCircular() == null ? true : jrPlot.getCircular().booleanValue();
    piePlot.setCircular(isCircular);

    PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
    JRItemLabel itemLabel = jrPlot.getItemLabel();
    if (labelGenerator != null) {
        piePlot.setLabelGenerator(labelGenerator);
    } else if (jrPlot.getLabelFormat() != null) {
        piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat()));
    }
    //      else if (itemLabel != null && itemLabel.getMask() != null)
    //      {
    //         piePlot.setLabelGenerator(
    //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
    //               );
    //      }

    if (jrPlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(
                new StandardPieSectionLabelGenerator(((JRPie3DPlot) getPlot()).getLegendLabelFormat()));
    }

    if (itemLabel != null && itemLabel.getFont() != null) {
        piePlot.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale()));
    } else {
        piePlot.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
    }

    if (itemLabel != null && itemLabel.getColor() != null) {
        piePlot.setLabelPaint(itemLabel.getColor());
    } else {
        piePlot.setLabelPaint(getChart().getForecolor());
    }

    if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
        piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
    } else {
        piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
    }

    return jfreeChart;
}

From source file:jhplot.HChart.java

/**
 * Update the chart/* w w w. j  a v  a  2s.  c  o m*/
 * 
 * @param N1
 *            location in X
 * @param N2
 *            location in Y
 */
public void update(int N1, int N2) {

    if (cdatPie[N1][N2] != null || cdatPie3D[N1][N2] != null || cdatBar[N1][N2] != null
            || cdatBar3D[N1][N2] != null || cdatLine[N1][N2] != null || cdatArea[N1][N2] != null
            || cdatPolar[N1][N2] != null) {

        if (cdatPie[N1][N2] != null) {
            chart[N1][N2] = ChartFactory.createPieChart(title[N1][N2], (PieDataset) cdatPie[N1][N2], true, true,
                    true);

        } else if (cdatPie3D[N1][N2] != null) {
            chart[N1][N2] = ChartFactory.createPieChart3D(title[N1][N2], (PieDataset) cdatPie3D[N1][N2], true,
                    true, true);
            PiePlot3D pieplot3d = (PiePlot3D) chart[N1][N2].getPlot();
            // pieplot3d.setStartAngle(290D);
            // pieplot3d.setDirection(Rotation.CLOCKWISE);
            // pieplot3d.setForegroundAlpha(0.5F);
            pieplot3d.setBackgroundPaint(DEFAULT_BG_COLOR);

        } else if (cdatBar[N1][N2] != null) {
            chart[N1][N2] = ChartFactory.createBarChart(title[N1][N2], titleX[N1][N2], titleY[N1][N2],
                    (CategoryDataset) cdatBar[N1][N2], PlotOrientation.VERTICAL, true, true, true);
            CategoryPlot lineplot = (CategoryPlot) chart[N1][N2].getPlot();

            CategoryAxis yy = lineplot.getDomainAxis();
            yy.setTickLabelPaint(tickColor);
            yy.setTickLabelFont(tickFont);
            yy.setLabelPaint(labelColor);
            yy.setLabelFont(labelFont);
            yy.setAxisLineStroke(new BasicStroke(axisPenwidth));
            yy.setAxisLinePaint(Color.black);
            ValueAxis xx = lineplot.getRangeAxis();
            xx.setTickLabelPaint(tickColor);
            xx.setTickLabelFont(tickFont);
            xx.setLabelPaint(labelColor);
            xx.setLabelFont(labelFont);
            xx.setAxisLineStroke(new BasicStroke(axisPenwidth));
            xx.setAxisLinePaint(Color.black);

        } else if (cdatBar3D[N1][N2] != null) {
            chart[N1][N2] = ChartFactory.createBarChart3D(title[N1][N2], titleX[N1][N2], titleY[N1][N2],
                    (CategoryDataset) cdatBar3D[N1][N2], PlotOrientation.VERTICAL, true, true, true);
        } else if (cdatLine[N1][N2] != null) {
            chart[N1][N2] = ChartFactory.createLineChart(title[N1][N2], titleX[N1][N2], titleY[N1][N2],
                    (CategoryDataset) cdatLine[N1][N2], PlotOrientation.VERTICAL, true, true, true);
            CategoryPlot lineplot = (CategoryPlot) chart[N1][N2].getPlot();
            lineplot.setOutlineStroke(new BasicStroke(axisPenwidth));
            CategoryAxis yy = lineplot.getDomainAxis();
            yy.setTickLabelPaint(tickColor);
            yy.setTickLabelFont(tickFont);
            yy.setLabelPaint(labelColor);
            yy.setLabelFont(labelFont);
            yy.setAxisLineStroke(new BasicStroke(axisPenwidth));
            yy.setAxisLinePaint(Color.black);
            ValueAxis xx = lineplot.getRangeAxis();
            xx.setTickLabelPaint(tickColor);
            xx.setTickLabelFont(tickFont);
            xx.setLabelPaint(labelColor);
            xx.setLabelFont(labelFont);
            xx.setAxisLineStroke(new BasicStroke(axisPenwidth));
            xx.setAxisLinePaint(Color.black);

            LineAndShapeRenderer renderer = (LineAndShapeRenderer) lineplot.getRenderer();
            renderer.setBaseStroke(new BasicStroke(linestroke));
            for (int m = 0; m < cdatLine[N1][N2].getColumnCount() + 1; m++)
                renderer.setSeriesStroke(m, new BasicStroke(linestroke));

        } else if (cdatPolar[N1][N2] != null) {
            chart[N1][N2] = ChartFactory.createPolarChart(title[N1][N2], (XYSeriesCollection) cdatPolar[N1][N2],
                    true, true, true);
            PolarPlot lineplot = (PolarPlot) chart[N1][N2].getPlot();
            ValueAxis yy = lineplot.getAxis();
            yy.setTickLabelPaint(tickColor);
            yy.setTickLabelFont(tickFont);
            yy.setLabelPaint(labelColor);
            yy.setLabelFont(labelFont);
            yy.setAxisLineStroke(new BasicStroke(axisPenwidth));
            yy.setAxisLinePaint(Color.black);

        } else if (cdatArea[N1][N2] != null) {

            chart[N1][N2] = ChartFactory.createAreaChart(title[N1][N2], titleX[N1][N2], titleY[N1][N2],
                    (CategoryDataset) cdatArea[N1][N2], PlotOrientation.VERTICAL, true, true, true);
            CategoryPlot lineplot = (CategoryPlot) chart[N1][N2].getPlot();

            CategoryAxis yy = lineplot.getDomainAxis();
            yy.setTickLabelPaint(tickColor);
            yy.setTickLabelFont(tickFont);
            yy.setLabelPaint(labelColor);
            yy.setLabelFont(labelFont);
            yy.setAxisLineStroke(new BasicStroke(axisPenwidth));
            yy.setAxisLinePaint(Color.black);
            ValueAxis xx = lineplot.getRangeAxis();
            xx.setTickLabelPaint(tickColor);
            xx.setTickLabelFont(tickFont);
            xx.setLabelPaint(labelColor);
            xx.setLabelFont(labelFont);
            xx.setAxisLineStroke(new BasicStroke(axisPenwidth));
            xx.setAxisLinePaint(Color.black);

        }

        chart[N1][N2].setAntiAlias(antiAlias);
        chart[N1][N2].setBorderPaint(DEFAULT_BG_COLOR);
        chart[N1][N2].setBackgroundPaint(DEFAULT_BG_COLOR);
        chart[N1][N2].setBorderVisible(false);
        cp[N1][N2].setChart(chart[N1][N2]);
        return;
    }

    for (int i = 0; i < indexdat[N1][N2]; i++) {

        if (type[N1][N2].get(i) == "array")
            xyplot[N1][N2].setRenderer(i, (StandardXYItemRenderer) (rdat[N1][N2].get(i)));
        else if (type[N1][N2].get(i) == "f")
            xyplot[N1][N2].setRenderer(i, (XYLineAndShapeRenderer) (rdat[N1][N2].get(i)));
        else if (type[N1][N2].get(i) == "h")
            xyplot[N1][N2].setRenderer(i, (XYBarRenderer) (rdat[N1][N2].get(i)));
        else if (type[N1][N2].get(i) == "p")
            xyplot[N1][N2].setRenderer(i, (XYLineAndShapeRenderer) (rdat[N1][N2].get(i)));
        else if (type[N1][N2].get(i) == "pe")
            xyplot[N1][N2].setRenderer(i, (XYErrorRenderer) (rdat[N1][N2].get(i)));

        // System.out.println(i);

    }

    chart[N1][N2] = new JFreeChart(title[N1][N2], JFreeChart.DEFAULT_TITLE_FONT, xyplot[N1][N2], true);
    chart[N1][N2].setAntiAlias(antiAlias);
    chart[N1][N2].setBorderPaint(DEFAULT_BG_COLOR);
    chart[N1][N2].setBackgroundPaint(DEFAULT_BG_COLOR);
    chart[N1][N2].setBorderVisible(false);

    cp[N1][N2].setChart(chart[N1][N2]);

}

From source file:ui.Analyze.java

private void genaratePermintaan(LocalDate awal, LocalDate akhir) throws SQLException {
    org.jfree.data.general.DefaultPieDataset data = new org.jfree.data.general.DefaultPieDataset();
    javax.swing.table.DefaultTableModel m = new javax.swing.table.DefaultTableModel(
            new String[] { "Nama Barang", "Jumlah" }, 0) {
        @Override/*from   w w  w  . jav  a  2  s  .  co  m*/
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    tblMinta.setModel(m);
    java.sql.PreparedStatement p = d.getPS(
            "select detjual.brg,sum(detjual.jum)as qty from jual left join detjual on jual.nota=detjual.nota "
                    + "where jual.tgl>=? and " + "jual.tgl<=? group by detjual.brg");
    p.setDate(1, Date.valueOf(awal));
    p.setDate(2, Date.valueOf(akhir));
    java.sql.ResultSet r = p.executeQuery();
    while (r.next()) {
        String brg = r.getString("brg");
        double qty = r.getDouble("qty");
        data.setValue(brg, qty);
        m.addRow(new String[] { brg, "" + qty });
    }
    r.close();
    p.close();
    org.jfree.chart.ChartPanel cp = new org.jfree.chart.ChartPanel(
            ChartFactory.createPieChart("Permintaan", data, true, true, false));
    cp.setSize(pnlMinta.getSize());
    if (0 < pnlMinta.getComponentCount())
        pnlMinta.removeAll();
    pnlMinta.add(cp);
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

/**
 *
 *//* w  w w .j  a v a  2  s. c  o  m*/
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()),
            (PieDataset) getDataset(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPiePlot.getItemLabel();

        if (labelGenerator != null) {
            piePlot.setLabelGenerator(labelGenerator);
        } else if (jrPiePlot.getLabelFormat() != null) {
            piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //
        //      }

        Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
                ChartThemesConstants.BASEFONT_SIZE);
        JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;

        piePlot.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot.setLabelGenerator(null);
    }

    if (jrPiePlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(),
                NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

From source file:fr.inria.soctrace.framesoc.ui.piechart.view.StatisticsPieChartView.java

/**
 * Creates the chart.//from   ww w .  j  a v a  2  s  .co  m
 * 
 * @param dataset
 *            the dataset.
 * @param loader
 *            the pie chart loader
 * @param dataRequested
 *            flag indicating if the data have been requested for the current loader and the
 *            current interval
 * @return the pie chart
 */
private JFreeChart createChart(PieDataset dataset, String title, IPieChartLoader loader,
        boolean dataRequested) {

    JFreeChart chart = ChartFactory.createPieChart(title, dataset, HAS_LEGEND, HAS_TOOLTIPS, HAS_URLS);

    // legend
    if (HAS_LEGEND) {
        LegendTitle legend = chart.getLegend();
        legend.setPosition(RectangleEdge.LEFT);
    }

    // plot
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage(
            "No data available " + (dataRequested ? "in this time interval" : "yet. Press the Load button."));
    plot.setCircular(true);
    plot.setLabelGenerator(null); // hide labels
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlineVisible(false);
    plot.setShadowPaint(Color.WHITE);
    plot.setBaseSectionPaint(Color.WHITE);
    StandardPieToolTipGenerator g = (StandardPieToolTipGenerator) plot.getToolTipGenerator();
    NumberFormat format = ValueLabelProvider.getActualFormat(loader.getFormat(), getTimeUnit());
    StandardPieToolTipGenerator sg = new StandardPieToolTipGenerator(g.getLabelFormat(), format,
            g.getPercentFormat());
    plot.setToolTipGenerator(sg);

    for (Object o : dataset.getKeys()) {
        String key = (String) o;
        plot.setSectionPaint(key, loader.getColor(key).getAwtColor());
    }
    return chart;
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *///from  w ww . j  a v  a2 s. c o m
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()),
            (PieDataset) getDataset(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPiePlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot.setLabelGenerator(labelGenerator);
        } else if (jrPiePlot.getLabelFormat() != null) {
            piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        if (itemLabel != null && itemLabel.getFont() != null) {
            piePlot.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale()));
        } else {
            piePlot.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
        }

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot.setLabelGenerator(null);
    }

    if (jrPiePlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                ((JRPiePlot) getPlot()).getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

From source file:ECallCenter21.java

/**
 *
 * @throws SQLException/*from   ww w .  jav a  2s  .  co  m*/
 * @throws ClassNotFoundException
 * @throws InstantiationException
 * @throws IllegalAccessException
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 * @throws Exception
 */
@SuppressWarnings({ "static-access", "static-access", "static-access" })
public ECallCenter21() throws SQLException, ClassNotFoundException, InstantiationException,
        IllegalAccessException, NoSuchMethodException, InvocationTargetException, Exception {
    eCallCenterReference = this; // A thread doesn't inherit local varables, but it does local finals / constants

    String[] status = new String[2];

    //        sipstateUpdateThreadPool = Executors.newCachedThreadPool();
    //        responseUpdateThreadPool = Executors.newCachedThreadPool();

    platform = System.getProperty("os.name").toLowerCase();
    if (platform.indexOf("windows") != -1) {
        fileSeparator = "\\";
        lineTerminator = "\r\n";
    } else {
        fileSeparator = "/";
        lineTerminator = "\r\n";
    }

    plaf = new String[4];
    plafSelected = new String();
    plaf[0] = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    plaf[1] = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    plaf[2] = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
    plaf[3] = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";

    setLookAndFeel(PLAF_NIMBUS);

    setMinimumSize(new Dimension(710, 598));
    setMaximumSize(new Dimension(710, 830));
    setPreferredSize(getMaximumSize());
    setResizable(false);
    setVisible(false);
    setVisible(true);
    initComponents();

    Thread defaultConstructorThread = new Thread(allThreadsGroup, new Runnable() {
        @Override
        public void run() {
            String[] status = new String[2];
            String imgName = "/images/voipstormboxicon.jpg";
            URL imgURL = getClass().getResource(imgName);
            Image image = Toolkit.getDefaultToolkit().getImage(imgURL);
            setIconImage(image);
            setImagePanelVisible(true);
            initSlidersSmooth();

            sysMonitor = new SysMonitor();

            dataDir = "data" + fileSeparator;
            soundsDir = dataDir + "sounds" + fileSeparator;
            vergunningDir = dataDir + "license" + fileSeparator;
            databasesDir = dataDir + "databases" + fileSeparator;
            configDir = dataDir + "config" + fileSeparator;
            binDir = dataDir + "bin" + fileSeparator;
            logDir = dataDir + "log" + fileSeparator;

            currentTimeCalendar = Calendar.getInstance();
            logDateString = "" + String.format("%04d", currentTimeCalendar.get(Calendar.YEAR))
                    + String.format("%02d", currentTimeCalendar.get(Calendar.MONTH) + 1)
                    + String.format("%02d", currentTimeCalendar.get(Calendar.DAY_OF_MONTH)) + "_"
                    + String.format("%02d", currentTimeCalendar.get(Calendar.HOUR_OF_DAY))
                    + String.format("%02d", currentTimeCalendar.get(Calendar.MINUTE))
                    + String.format("%02d", currentTimeCalendar.get(Calendar.SECOND));
            logFileString = logDir + logDateString + "_" + THISPRODUCT + ".log";

            //        System.out.println("\r\nChecking Directories...");
            showStatus(Vergunning.PRODUCT + "Checking Directories...", true, false);
            boolean missingDirsDetected = false;
            boolean missingCriticalDirsDetected = false;
            file = new File(logDir);
            if (!file.exists()) {
                if (new File(logDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Info:     Creating missing directory: " + logDir, true, false);
                }
            }
            file = new File(dataDir);
            if (!file.exists()) {
                if (new File(dataDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Warning:  Creating missing directory: " + dataDir, true, true);
                }
            }
            file = new File(soundsDir);
            if (!file.exists()) {
                if (new File(soundsDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Critical: Creating missing directory: " + soundsDir, true, true);
                    missingCriticalDirsDetected = true;
                }
            }
            file = new File(vergunningDir);
            if (!file.exists()) {
                if (new File(vergunningDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Info:     Creating missing directory: " + vergunningDir, true, true);
                }
            }
            file = new File(databasesDir);
            if (!file.exists()) {
                if (new File(databasesDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Info:     Creating missing directory: " + databasesDir, true, true);
                }
            }
            file = new File(configDir);
            if (!file.exists()) {
                if (new File(configDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Info:     Creating missing directory: " + configDir, true, true);
                }
            }
            file = new File(binDir);
            if (!file.exists()) {
                if (new File(binDir).mkdir()) {
                    missingDirsDetected = true;
                    showStatus("Critical: Creating missing directory: " + binDir, true, true);
                    missingCriticalDirsDetected = true;
                }
            }
            if (missingCriticalDirsDetected) {
                showStatus(
                        "Critical directories were missing!!! Please download the entire VoipStorm package at: "
                                + Vergunning.WEBLINK,
                        true, true);
                try {
                    Thread.sleep(4000);
                } catch (InterruptedException ex) {
                }
            }
            if (missingDirsDetected) {
                showStatus("VoipStorm directory structure built", true, true);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ex) {
                }
            }

            try {
                weblog = new WebLog();
            } catch (Exception ex) {
            }

            Thread webLogThread = new Thread(new Runnable() {
                @Override
                @SuppressWarnings({ "static-access" })
                public void run() {
                    try {
                        weblog.send(THISPRODUCT + " Starting");
                    } catch (Exception ex) {
                    }
                }
            });
            webLogThread.setName("webLogThread");
            webLogThread.setDaemon(runThreadsAsDaemons);
            webLogThread.start();

            registerSpeedValue.setText(Integer.toString(registrationBurstDelay));
            registrationBurstDelay = registerSpeedSlider.getValue();
            inboundRingingResponseDelayValue
                    .setText(Integer.toString(inboundRingingResponseDelaySlider.getValue()));
            inboundRingingResponseBusyRatioValue
                    .setText(Integer.toString(inboundRingingResponseBusyRatioSlider.getValue()));
            inboundEndDelayValue.setText(Integer.toString(inboundEndDelaySlider.getValue()));

            vmUsagePauseValue.setText(Integer.toString(vmUsageThresholdSlider.getValue()));
            vmUsagePauseThreashold = vmUsageThresholdSlider.getValue();
            memFreeThresholdValue.setText(Integer.toString(memFreeThresholdSlider.getValue()));
            memFreeThreshold = memFreeThresholdSlider.getValue();
            heapMemFreeThresholdValue.setText(Integer.toString(heapMemFreeThresholdSlider.getValue()));
            heapMemFreeThreshold = heapMemFreeThresholdSlider.getValue();
            connectingTallyLimitValue.setText(Integer.toString(connectingTallyLimitSlider.getValue()));
            connectingTallyLimit = connectingTallyLimitSlider.getValue();
            callingTallyLimitValue.setText(Integer.toString(callingTallyLimitSlider.getValue()));
            callingTallyLimit = callingTallyLimitSlider.getValue();
            establishedTallyLimitValue.setText(Integer.toString(establishedTallyLimitSlider.getValue()));
            establishedTallyLimit = establishedTallyLimitSlider.getValue();
            callSpeedValue.setText(Integer.toString(callSpeedSlider.getValue()));
            outboundBurstDelay = callSpeedSlider.getValue();

            status = new String[2];
            status[0] = "0";
            status[1] = "";

            nlLocale = new Locale("nl");
            boundMode = "Outbound";
            callCenterStatus = POWEREDOFF;

            //        status = shell.getPID(); if (status[0].equals("0"))
            //        {
            //            pid = Integer.parseInt(status[1]);
            //            outboundCallsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "In/Outbound Campaign Controls " + Integer.toString(pid), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("STHeiti", 0, 14), new java.awt.Color(255, 255, 255))); // NOI18N
            //        }
            //        else { pid = 0; }

            softphonesQuantity = 0;

            setTitle(getWindowTitle());
            //   mainPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, getBrand() + " " + getProduct() + " " + getVersion(), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("STHeiti", 0, 12), new java.awt.Color(102, 102, 102))); // NOI18N
            //   configurationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Proxy Configuration", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("STHeiti", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N

            // Starting the Database Server

            ultraShortMessagePeriod = 0;
            smoothMovementPeriod = 40;
            //   eyeBlinkMessagePeriod = 250;
            //           shortMessagePeriod = 1000;
            mediumMessagePeriod = 2000;
            myCoordinate = new Coordinate();

            brandLabel.setText(Vergunning.BRAND);
            brandDescriptionLabel.setText(Vergunning.BRAND_DESCRIPTION);
            productLabel.setText(Vergunning.PRODUCT);
            productDescriptionLabel.setText(Vergunning.PRODUCT_DESCRIPTION);
            copyrightLabel.setText(getWarning() + " " + getCopyright() + " " + getBrand() + " " + getBusiness()
                    + " - Author: " + getAuthor());

            debugging = false;
            allThreadsGroup = new ThreadGroup("AllThreads");
            vmUsageStatus = new String[2];
            memFreeStatus = new String[2];

            localDisplayData = new DisplayData();
            //   localSpeakerData    = new SpeakerData();

            vmUsageStatus[0] = "0";
            vmUsageStatus[1] = "";
            memFreeStatus[0] = "0";
            memFreeStatus[1] = "";

            //   inboundSoftPhonesAvailableCounter = 0;
            inboundInstanceCounter = 0;
            outboundInstanceCounter = 0;
            //        outboundPowerToggleButton.setEnabled(false);

            //        myClickOnSoundTool          = new SoundTool(SoundTool.CLICKONTONE);
            //        myClickOffSoundTool         = new SoundTool(SoundTool.CLICKOFFTONE);
            //        mySuccessSoundTool          = new SoundTool(SoundTool.SUCCESSTONE);
            //        myPowerSuccessSoundTool     = new SoundTool(SoundTool.POWERSUCCESSTONE);
            //        myFailureSoundTool          = new SoundTool(SoundTool.FAILURETONE);
            //        myTickSoundTool             = new SoundTool(SoundTool.TICKTONE);
            //        myRegisterEnabledSoundTool  = new SoundTool(SoundTool.REGISTERENABLEDTONE);
            //        myRegisterDisabledSoundTool = new SoundTool(SoundTool.REGISTERDISABLEDTONE);
            //        myAnswerEnabledSoundTool    = new SoundTool(SoundTool.ANSWERENABLEDTONE);
            //        myAnswerDisabledSoundTool   = new SoundTool(SoundTool.ANSWERDISABLEDTONE);
            //        myCancelEnabledSoundTool    = new SoundTool(SoundTool.CANCELENABLEDTONE);
            //        myCancelDisabledSoundTool   = new SoundTool(SoundTool.CANCELDISABLEDTONE);
            //        myMuteEnabledSoundTool      = new SoundTool(SoundTool.MUTEENABLEDTONE);
            //        myMuteDisabledSoundTool     = new SoundTool(SoundTool.MUTEDISABLEDTONE);
            //
            //        myRingToneSoundTool         = new SoundTool(SoundTool.RINGTONE);
            //        myDialToneSoundTool         = new SoundTool(SoundTool.DEADTONE);
            //        myCallToneSoundTool         = new SoundTool(SoundTool.CALLTONE);
            //        myBusyToneSoundTool         = new SoundTool(SoundTool.BUSYTONE);
            //        myDeadToneSoundTool         = new SoundTool(SoundTool.DEADTONE);
            //        myErrorToneSoundTool        = new SoundTool(SoundTool.ERRORTONE);

            configurationCallCenter = new Configuration();
            showStatus("Loading CallCenter Configuration...", true,
                    true); /* true = logToApplic, true = logToFile */
            status = configurationCallCenter.loadConfiguration("3");
            if (status[0].equals("1")) // loadConfig failed
            {
                logToApplication("Loading CallCenter Configuration Failed: " + status[1]);
                showStatus("Loading CallCenter Configuration Failed, creating new Inbound Config", true,
                        true); /* true = logToApplic, true = logToFile */
                configurationCallCenter.createConfiguration();
                clientIPField.setText(configurationCallCenter.getClientIP());
                pubIPField.setText(configurationCallCenter.getPublicIP());
                clientPortField.setText(configurationCallCenter.getClientPort());
                domainField.setText(configurationCallCenter.getDomain());
                serverIPField.setText(configurationCallCenter.getServerIP());
                serverPortField.setText(configurationCallCenter.getServerPort());
                prefPhoneLinesSlider.setMaximum(vergunning.getPhoneLines());
                prefPhoneLinesSlider.setValue(vergunning.getPhoneLines());
                usernameField.setText(configurationCallCenter.getUsername());
                toegangField.setText(configurationCallCenter.getToegang());
                if (configurationCallCenter.getRegister().equals("1")) {
                    registerCheckBox.setSelected(true);
                } else {
                    registerCheckBox.setSelected(false);
                }
                if (configurationCallCenter.getIcons().equals("1")) {
                    iconsCheckBox.setSelected(true);
                } else {
                    iconsCheckBox.setSelected(false);
                }
                showStatus("Saving new CallCenter Configuration...", true,
                        true); /* true = logToApplic, true = logToFile */
                configurationCallCenter.saveConfiguration("3");
                //            myFailureSoundTool.play();
            } else // loadConfig Succeeded
            {
                //            myPowerSuccessSoundTool.play();
                clientIPField.setText(configurationCallCenter.getClientIP());
                pubIPField.setText(configurationCallCenter.getPublicIP());
                clientPortField.setText(configurationCallCenter.getClientPort());
                domainField.setText(configurationCallCenter.getDomain());
                serverIPField.setText(configurationCallCenter.getServerIP());
                serverPortField.setText(configurationCallCenter.getServerPort());

                prefPhoneLinesSlider.setMaximum(Integer.parseInt(configurationCallCenter.getPrefPhoneLines()));
                prefPhoneLinesSlider.setValue(Integer.parseInt(configurationCallCenter.getPrefPhoneLines()));

                usernameField.setText(configurationCallCenter.getUsername());
                toegangField.setText(configurationCallCenter.getToegang());
                if (configurationCallCenter.getRegister().equals("1")) {
                    registerCheckBox.setSelected(true);
                } else {
                    registerCheckBox.setSelected(false);
                }
                if (configurationCallCenter.getIcons().equals("1")) {
                    iconsCheckBox.setSelected(true);
                } else {
                    iconsCheckBox.setSelected(false);
                }
                showStatus("CallCenter Configuration Loaded Successfully", true,
                        true); /* true = logToApplic, true = logToFile */
            }

            icons = new Icons(PHONESPOOLTABLECOLUMNWIDTH, PHONESPOOLTABLECOLUMNHEIGHT,
                    iconsCheckBox.isSelected());

            lastTimeDashboardCalendar = Calendar.getInstance();
            currentTimeDashboardCalendar = Calendar.getInstance(); // Prevent nullpointer in dashboard timer

            updateSystemStatsTimer = new Timer();
            updateSystemStatsTimer.scheduleAtFixedRate(new UpdateSystemStatsTimer(eCallCenterReference),
                    (long) (0), updateSystemStatsTimerFastInterval);
            showStatus(
                    "updateSystemStatsTimer Scheduled immediate at "
                            + Math.round(updateSystemStatsTimerFastInterval / 1000) + " Sec Interval",
                    true, true); /* true = logToApplic, true = logToFile */
            updateStallerTimer = new Timer();
            updateStallerTimer.scheduleAtFixedRate(new UpdateStallerDetectorTimer(eCallCenterReference),
                    (long) (0), updateStallerTimerInterval);
            showStatus(
                    "updateStallerTimer     Scheduled immediate at "
                            + Math.round(updateStallerTimerInterval / 1000) + " Sec Interval",
                    true, true); /* true = logToApplic, true = logToFile */
            updateVergunningTimer = new Timer();
            updateVergunningTimer.scheduleAtFixedRate(new UpdateVergunningTimer(eCallCenterReference),
                    (long) (0), updateVergunningTimerInterval);
            showStatus(
                    "updateLicenseTimer     Scheduled immediate at "
                            + Math.round(updateVergunningTimerInterval / 1000) + " Sec Interval",
                    true, true); /* true = logToApplic, true = logToFile */
            updateDashboardTimer = new Timer();
            updateDashboardTimer.scheduleAtFixedRate(new UpdateDashboardTimer(eCallCenterReference), (long) (0),
                    updateDashboardTimerInterval);
            showStatus(
                    "updateDashboardTimer   Scheduled immediate at "
                            + Math.round(updateDashboardTimerInterval / 1000) + " Sec Interval",
                    true, true); /* true = logToApplic, true = logToFile */
            updateAutoSpeedTimer = new Timer();
            updateAutoSpeedTimer.scheduleAtFixedRate(new UpdateAutoSpeedTimer(eCallCenterReference), (long) (0),
                    updateAutoSpeedTimerInterval);
            showStatus(
                    "updateAutoSpeedTimer   Scheduled immediate at "
                            + Math.round(updateAutoSpeedTimerInterval / 1000) + " Sec Interval",
                    true, true); /* true = logToApplic, true = logToFile */

            shell = new Shell();
            platform = shell.getPlatform().toLowerCase();
            if (platform.indexOf("mac os x") != -1) {
                systemStatsTable.setValueAt("RealMemFree", 2, 0);
            } else if (platform.indexOf("linux") != -1) {
                systemStatsTable.setValueAt("TotMemFree", 2, 0);
            } //phonesPoolTable.setFont(new java.awt.Font("STHeiti", 0, 12));
            else if (platform.indexOf("sunos") != -1) {
                systemStatsTable.setValueAt("TotMemFree", 2, 0);
            } else if (platform.indexOf("hpux") != -1) {
                systemStatsTable.setValueAt("TotMemFree", 2, 0);
            } else if (platform.indexOf("aix") != -1) {
                systemStatsTable.setValueAt("TotMemFree", 2, 0);
            } else if (platform.indexOf("bsd") != -1) {
                systemStatsTable.setValueAt("TotMemFree", 2, 0);
            } else if (platform.indexOf("windows") != -1) {
                systemStatsTable.setValueAt("TotMemFree", 2, 0);
            } else {
                systemStatsTable.setValueAt(platform + "?", 2, 0);
                setAutoSpeed(false);
            }

            //   if (snmpCheckBox.isSelected())
            //   {
            //       mySNMP = new SNMPClient();
            //       showStatus("Checking your SNMP server...", true, true); status = mySNMP.getStat(mySNMP.CPUIDLEOID);
            //       if (status[0].equals("1")) { showStatus("Is your SNMP server running?", true, true); System.exit(1);}
            //
            //       // Setup the infrequent SystemStats Timer
            //       updateSystemStatsTimer.cancel(); updateSystemStatsTimer.purge();
            //            showStatus("updateSystemStatsTimer Canceled!", true, true); /* true = logToApplic, true = logToFile */
            //       updateSystemStatsTimer = new Timer(); updateSystemStatsTimer.scheduleAtFixedRate(new UpdateSystemStatsTimer(this), (long)(0), (updateSystemStatsTimerFastInterval));
            //            showStatus("updateSystemStatsTimer Scheduled immediate at " + Math.round(updateSystemStatsTimerFastInterval / 1000) + " Sec Interval", true, true); /* true = logToApplic, true = logToFile */
            //   }

            //   captionTable.setValueAt(onSymbol                    + " ON", 0, 0);
            //   captionTable.setValueAt("IDL/REG", 0, 1);
            //   captionTable.setValueAt(connectingSymbol            + " CON", 0, 2);
            //   captionTable.setValueAt(callingSymbol               + " CLL", 0, 3);
            //   captionTable.setValueAt(ringingSymbol               + " RNG", 0, 4);
            //   captionTable.setValueAt(acceptingSymbol             + " ACC", 0, 5);
            //   captionTable.setValueAt(talkingSymbol               + " TLK" , 0, 6);
            //   captionTable.setValueAt(localcancelSymbol           + " CAN", 0, 7);
            //   captionTable.setValueAt(localbusySymbol             + " BSY", 0, 8);
            //   captionTable.setValueAt(localbyeSymbol              + " " + remotebyeSymbol  + " BYE", 0, 9);

            captionTable.setValueAt("ON", 0, 0);
            captionTable.setValueAt("IDL/REG", 0, 1);
            captionTable.setValueAt("CON", 0, 2);
            captionTable.setValueAt("TRY", 0, 3);
            captionTable.setValueAt("CLL", 0, 4);
            captionTable.setValueAt("RNG", 0, 5);
            captionTable.setValueAt("ACC", 0, 6);
            captionTable.setValueAt("TLK", 0, 7);
            captionTable.setValueAt("CAN", 0, 8);
            captionTable.setValueAt("BSY", 0, 9);
            captionTable.setValueAt("BYE", 0, 10);

            // Set the CallRatio Pie Chart
            callRatioChartData = new DefaultPieDataset(); // callRatioChartData.setValue("Slack", 0); callRatioChartData.setValue("Busy", 0); callRatioChartData.setValue("Success", 0);
            callRatioChart = ChartFactory.createPieChart("Waiting for Campaign...", callRatioChartData, true,
                    true, false); // legend? // tooltips? // URLs?
            chartPanel = new ChartPanel(callRatioChart);

            org.jdesktop.layout.GroupLayout graphInnerPanelLayout = new org.jdesktop.layout.GroupLayout(
                    graphInnerPanel);
            graphInnerPanel.setLayout(graphInnerPanelLayout);
            graphInnerPanelLayout.setHorizontalGroup(
                    graphInnerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                            chartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE));
            graphInnerPanelLayout.setVerticalGroup(
                    graphInnerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                            chartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE));
            chartPanel.setFont(new java.awt.Font("STHeiti", 0, 10)); // NOI18N
            graphInnerPanel.setVisible(false);
            chartPanel.setVisible(false);
            chartPanel.setDoubleBuffered(true);

            // Set the PerformanceMeter Dial
            performanceMeter = new PerformanceMeter("Performance", vmUsageDecelerationThreashold,
                    (Vergunning.CALLSPERHOUR_ENTERPRISE / 100));
            performanceChartPanel = new ChartPanel(performanceMeter.chart1);

            org.jdesktop.layout.GroupLayout graphInnerPanelLayout2 = new org.jdesktop.layout.GroupLayout(
                    performanceMeterPanel);
            performanceMeterPanel.setLayout(graphInnerPanelLayout2);
            graphInnerPanelLayout2.setHorizontalGroup(
                    graphInnerPanelLayout2.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                            performanceChartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            performanceDialSize, Short.MAX_VALUE));
            graphInnerPanelLayout2.setVerticalGroup(
                    graphInnerPanelLayout2.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                            performanceChartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            performanceDialSize, Short.MAX_VALUE));
            performanceChartPanel.setFont(new java.awt.Font("STHeiti", 0, 10)); // NOI18N
            performanceMeterPanel.setVisible(true);
            performanceChartPanel.setVisible(true);
            performanceMeter.setCallPerHourNeedle(0);

            destination = new Destination();
            //                destinationElement = new Destination();
            campaignStat = new CampaignStat();
            lastStallerCampaignStat = new CampaignStat();
            lastTimeDashboardCampaignStat = new CampaignStat();

            // Last but not least, loading the Database Client
            try {
                dbClient = new JavaDBClient(eCallCenterReference, DATABASE);
            } catch (SQLException ex) {
            } catch (ClassNotFoundException ex) {
            } catch (InstantiationException ex) {
            } catch (IllegalAccessException ex) {
            } catch (NoSuchMethodException ex) {
            } catch (InvocationTargetException ex) {
            } catch (Exception ex) {
            }

            // Check for Open Campaigns
            String[] openCampaigns = dbClient.getOpenCampaigns();
            if ((openCampaigns != null) && (openCampaigns.length > 0)) {
                campaignComboBox.setModel(new javax.swing.DefaultComboBoxModel(openCampaigns));
                campaignComboBox.setEnabled(true);
            } else {
                campaignComboBox.setEnabled(false);
                runCampaignToggleButton.setEnabled(false);
                stopCampaignButton.setEnabled(false);
            }

            callCenterIsNetManaged = false;

            vergunningStartCalendar = Calendar.getInstance();
            vergunningEndCalendar = Calendar.getInstance();
            vergunningStartCalendar.set(Calendar.HOUR_OF_DAY, (int) 0);
            vergunningStartCalendar.set(Calendar.MINUTE, (int) 0);
            vergunningStartCalendar.set(Calendar.SECOND, (int) 0);

            vergunning = new Vergunning();
            executeVergunning();
            if (!vergunning.isValid()) {
                vergunningCodeField.setText("");
            } else {
                performanceMeter.setCallPerHourScale(0, (vergunning.getCallsPerHour() / 100),
                        (vergunning.getCallsPerHour() / 1000));
            }

            timeTool = new TimeTool();
            defaultConstructorIsReady = true;
        }
    });
    defaultConstructorThread.setName("defaultConstructorThread");
    defaultConstructorThread.setDaemon(runThreadsAsDaemons);
    defaultConstructorThread.setPriority(5);
    defaultConstructorThread.start();
}

From source file:gskproject.Analyze.java

private void ddGraphPersonWiseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ddGraphPersonWiseActionPerformed
    Object obj = evt.getSource();
    if (obj == ddGraphPersonWise) {

        if (ddGraphPersonWise.getSelectedItem().toString().equals("Spread of all Cases among Persons")) {
            DefaultPieDataset pieDataSet = new DefaultPieDataset();

            for (Vector row : tablePersonWise) {
                pieDataSet.setValue(row.get(0).toString(), Double.parseDouble(row.get(1).toString()));
            }/*from w  w  w  . j  av  a2 s  .  co  m*/
            JFreeChart chart = ChartFactory.createPieChart("Spread of all Cases among Persons", pieDataSet,
                    true, true, true);

            PiePlot p = (PiePlot) chart.getPlot();
            //p.setForegroundAlpha(TOP_ALIGNMENT);
            ChartFrame frame = new ChartFrame("Pie Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
            //System.out.println("aaa");
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of Cases(As Resposible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {//select the personwise for analysing
                barDataSet.setValue((Double.parseDouble(row.get(2).toString()) / (int) row.get(1)) * 100,
                        "Percentage of Cases(As Resposible Parties)", row.get(0).toString());
            }

            JFreeChart chart = ChartFactory.createBarChart("Percentage of Cases(As Resposible Parties)",
                    "Person", "Percentage of Cases(As Resposible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);

        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of opened cases out of No: of Cases(As Responsible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(3).toString()) / (int) row.get(2)) * 100,
                        "Percentage of opened cases out of No: of Cases(As Responsible Parties)",
                        row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of opened cases out of No: of Cases(As Responsible Parties)", "Person",
                    "Percentage of opened cases out of No: of Cases(As Responsible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of closed cases out of No: of Cases(As Responsible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue(
                        (Double.parseDouble(row.get(2).toString())
                                - (Double.parseDouble(row.get(3).toString())) / (int) row.get(2)) * 100,
                        "Percentage of closed cases out of No: of Cases(As Responsible Parties)",
                        row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of closed cases out of No: of Cases(As Responsible Parties)", "Person",
                    "Percentage of closed cases out of No: of Cases(As Responsible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString().equals("Percentage of Cases(As Observer)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(5).toString()) / (int) row.get(1)) * 100,
                        "Percentage of Cases(As Observer)", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart("Percentage of Cases(As Observer)", "Person",
                    "Percentage of Cases(As Observer)", barDataSet, PlotOrientation.VERTICAL, false, true,
                    false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of opened cases out of No: of Cases(As Observer)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(6).toString()) / (int) row.get(5)) * 100,
                        "Percentage of Closed cases", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of opened cases out of No: of Cases(As Observer)", "Person",
                    "Percentage of opened cases out of No: of Cases(As Observer)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue(
                        ((Double.parseDouble(row.get(5).toString())
                                - (Double.parseDouble(row.get(6).toString()))) / (int) row.get(5)) * 100,
                        "Percentage of closed cases out of No: of Cases(As Observer)", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of closed cases out of No: of Cases(As Observer)", "Person",
                    "Percentage of closed cases out of No: of Cases(As Observer)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        }
    }
}

From source file:kolacer.Kolacer.java

public JFreeChart makePieChart(String nazevGrafu) {
    JFreeChart graf;//from   ww w . j a  va 2 s  .c  om
    DefaultPieDataset ds = new DefaultPieDataset();
    for (Udaj u : udaje) {
        if (jCHB_nuloveVyskyty.isSelected() || u.pocet > 0)
            ds.setValue(u.hodnota, u.pocet);
    }
    graf = ChartFactory.createPieChart(nazevGrafu, (PieDataset) ds, false, false, false); // legends, tooltips, urls
    PiePlot plot = (PiePlot) graf.getPlot();
    upravPlot(plot);

    graf.setBackgroundPaint(Barvy.barvaPozadi);
    graf.setBorderVisible(false);
    return graf;
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *///from   www. j  a v  a2 s . c  o  m
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()),
            (PieDataset) getDataset(), isShowLegend(), true, false);

    configureChart(jfreeChart);
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPiePlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot.setLabelGenerator(labelGenerator);
        } else if (jrPiePlot.getLabelFormat() != null) {
            piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        } // the default section label is just the key, so there's no need to set localized number formats
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        piePlot.setLabelFont(
                fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale()));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot.setLabelGenerator(null);
    }

    if (jrPiePlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(),
                NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
    } // the default legend label is just the key, so there's no need to set localized number formats

    return jfreeChart;
}