Example usage for org.jfree.data.general DefaultPieDataset setValue

List of usage examples for org.jfree.data.general DefaultPieDataset setValue

Introduction

In this page you can find the example usage for org.jfree.data.general DefaultPieDataset setValue.

Prototype

public void setValue(Comparable key, double value) 

Source Link

Document

Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:UserInterfaces.HAdministration.MedicationJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:

    int timeofem = 0;
    int timeofpha = 0;
    int timeofward = 0;
    int timeofor = 0;
    int timeoflab = 0;
    int timeofoutpatient = 0;

    int i;//from w  w w.j  a va  2s.c  om
    int max = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.MEDICATION_OR_OTHER)) {
            if (workRequest.getLocation().equals(Location.EMERGENCY)) {
                timeofem = timeofem + 1;
            }
            if (workRequest.getLocation().equals(Location.LABORATORY)) {
                timeoflab = timeoflab + 1;
            }
            if (workRequest.getLocation().equals(Location.OR)) {
                timeofor = timeofor + 1;
            }
            if (workRequest.getLocation().equals(Location.OUTPATIEN)) {
                timeofoutpatient = timeofoutpatient + 1;
            }
            if (workRequest.getLocation().equals(Location.PHARMACY)) {
                timeofpha = timeofpha + 1;
            }
            if (workRequest.getLocation().equals(Location.WARD)) {
                timeofward = timeofward + 1;
            }

        }
    }

    int[] numbs;
    numbs = new int[6];
    numbs[0] = timeofem;
    numbs[1] = timeoflab;
    numbs[2] = timeofor;
    numbs[3] = timeofoutpatient;
    numbs[4] = timeofpha;
    numbs[5] = timeofward;

    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(Location.EMERGENCY, timeofem);
    dataset.setValue(Location.LABORATORY, timeoflab);
    dataset.setValue(Location.OR, timeofor);
    dataset.setValue(Location.OUTPATIEN, timeofoutpatient);
    dataset.setValue(Location.PHARMACY, timeofpha);
    dataset.setValue(Location.WARD, timeofward);

    JFreeChart chart = ChartFactory.createPieChart(" Chart", dataset, true, true, true);

    PiePlot p = (PiePlot) chart.getPlot();

    ChartFrame chartFrame = new ChartFrame("Location of events", chart);
    chartFrame.setSize(450, 550);
    chartFrame.setVisible(true);
}

From source file:UserInterfaces.HAdministration.DeviceReportJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:

    int timeofem = 0;
    int timeofpha = 0;
    int timeofward = 0;
    int timeofor = 0;
    int timeoflab = 0;
    int timeofoutpatient = 0;

    int i;//w  ww  . j  av  a  2s.  c  o m
    int max = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.DEVICE_OR_MEDICAL)) {
            if (workRequest.getLocation().equals(Location.EMERGENCY)) {
                timeofem = timeofem + 1;
            }
            if (workRequest.getLocation().equals(Location.LABORATORY)) {
                timeoflab = timeoflab + 1;
            }
            if (workRequest.getLocation().equals(Location.OR)) {
                timeofor = timeofor + 1;
            }
            if (workRequest.getLocation().equals(Location.OUTPATIEN)) {
                timeofoutpatient = timeofoutpatient + 1;
            }
            if (workRequest.getLocation().equals(Location.PHARMACY)) {
                timeofpha = timeofpha + 1;
            }
            if (workRequest.getLocation().equals(Location.WARD)) {
                timeofward = timeofward + 1;
            }

        }
    }

    int[] numbs;
    numbs = new int[6];
    numbs[0] = timeofem;
    numbs[1] = timeoflab;
    numbs[2] = timeofor;
    numbs[3] = timeofoutpatient;
    numbs[4] = timeofpha;
    numbs[5] = timeofward;

    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(Location.EMERGENCY, timeofem);
    dataset.setValue(Location.LABORATORY, timeoflab);
    dataset.setValue(Location.OR, timeofor);
    dataset.setValue(Location.OUTPATIEN, timeofoutpatient);
    dataset.setValue(Location.PHARMACY, timeofpha);
    dataset.setValue(Location.WARD, timeofward);

    JFreeChart chart = ChartFactory.createPieChart(" Chart", dataset, true, true, true);

    PiePlot p = (PiePlot) chart.getPlot();

    ChartFrame chartFrame = new ChartFrame("Location of events", chart);
    chartFrame.setSize(450, 550);
    chartFrame.setVisible(true);

}

From source file:com.qspin.qtaste.reporter.testresults.html.HTMLReportFormatter.java

private void generatePieChart() {
    if (currentTestSuite == null) {
        return;/*from   ww w  . j  a  va  2 s  . c  o  m*/
    }

    File testSummaryFile = new File(reportFile.getParentFile(), testSummaryFileName);
    File tempTestSummaryFile = new File(testSummaryFile.getPath() + ".tmp");

    final DefaultPieDataset pieDataSet = new DefaultPieDataset();

    pieDataSet.setValue("Passed", new Integer(currentTestSuite.getNbTestsPassed()));
    pieDataSet.setValue("Failed", new Integer(currentTestSuite.getNbTestsFailed()));
    pieDataSet.setValue("Tests in error", new Integer(currentTestSuite.getNbTestsNotAvailable()));
    pieDataSet.setValue("Not executed",
            new Integer(currentTestSuite.getNbTestsToExecute() - currentTestSuite.getNbTestsExecuted()));
    JFreeChart chart = null;
    final boolean drilldown = true;

    // create the chart...
    if (drilldown) {
        final PiePlot plot = new PiePlot(pieDataSet);

        Color[] colors = { new Color(100, 230, 40), new Color(210, 35, 35), new Color(230, 210, 40),
                new Color(100, 90, 40) };
        PieRenderer renderer = new PieRenderer(colors);
        renderer.setColor(plot, (DefaultPieDataset) pieDataSet);

        plot.setURLGenerator(new StandardPieURLGenerator("pie_chart_detail.jsp"));
        plot.setLabelGenerator(new TestSectiontLabelPieGenerator());
        chart = new JFreeChart("Test summary", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    } else {
        chart = ChartFactory.createPieChart("Test summary", // chart title
                pieDataSet, // data
                true, // include legend
                true, false);
    }

    chart.setBackgroundPaint(java.awt.Color.white);

    try {
        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        ChartUtilities.saveChartAsPNG(tempTestSummaryFile, chart, 600, 400, info);
    } catch (IOException e) {
        logger.error("Problem saving png chart", e);
    }

    testSummaryFile.delete();
    if (!tempTestSummaryFile.renameTo(testSummaryFile)) {
        logger.error("Couldn't rename test summary file " + tempTestSummaryFile + " into " + testSummaryFile);
    }
}

From source file:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java

@SuppressWarnings("unchecked")
public PieGraphData makeDataSet() throws GraphException {
    if (data.size() != 1) {
        throw new GraphException("Was expecting a single series, receieved " + data.size());
    }/* w ww .j  a  va  2 s. com*/

    DataSeriesInterface dsi = data.get(0);

    DefaultPieDataset pieData = new DefaultPieDataset();
    Map<Comparable, Paint> colors = new HashMap<Comparable, Paint>(dsi.getPoints().size());
    Map<Comparable, String> toolTips = new HashMap<Comparable, String>(dsi.getPoints().size());
    Map<Comparable, String> urls = new HashMap<Comparable, String>(dsi.getPoints().size());

    for (PointInterface p : dsi.getPoints()) {
        if (p.getDescriminator() instanceof Comparable) {
            Comparable key = (Comparable) p.getDescriminator();
            pieData.setValue(key, p.getValue());

            Paint itemColor = getParam(p.getMetadata(), ITEM_COLOR, Paint.class, null);
            String itemToolTip = getParam(p.getMetadata(), ITEM_TOOL_TIP, String.class, null);
            String itemURL = getParam(p.getMetadata(), ITEM_URL, String.class, null);
            if (itemColor != null) {
                colors.put(key, itemColor);
            }
            if (itemToolTip != null) {
                toolTips.put(key, itemToolTip);
            }
            if (itemURL != null) {
                urls.put(key, itemURL);
            }
        }
    }

    return new PieGraphData(pieData, colors, toolTips, urls);
}

From source file:UserInterfaces.HAdministration.SurgeryJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:

    int timeofem = 0;
    int timeofpha = 0;
    int timeofward = 0;
    int timeofor = 0;
    int timeoflab = 0;
    int timeofoutpatient = 0;

    int i;/*from  w w w  .j av a  2s .co  m*/
    int max = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.SURGERY_OR_ANESTHESIA)) {
            if (workRequest.getLocation().equals(Location.EMERGENCY)) {
                timeofem = timeofem + 1;
            }
            if (workRequest.getLocation().equals(Location.LABORATORY)) {
                timeoflab = timeoflab + 1;
            }
            if (workRequest.getLocation().equals(Location.OR)) {
                timeofor = timeofor + 1;
            }
            if (workRequest.getLocation().equals(Location.OUTPATIEN)) {
                timeofoutpatient = timeofoutpatient + 1;
            }
            if (workRequest.getLocation().equals(Location.PHARMACY)) {
                timeofpha = timeofpha + 1;
            }
            if (workRequest.getLocation().equals(Location.WARD)) {
                timeofward = timeofward + 1;
            }

        }
    }

    int[] numbs;
    numbs = new int[6];
    numbs[0] = timeofem;
    numbs[1] = timeoflab;
    numbs[2] = timeofor;
    numbs[3] = timeofoutpatient;
    numbs[4] = timeofpha;
    numbs[5] = timeofward;

    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue(Location.EMERGENCY, timeofem);
    dataset.setValue(Location.LABORATORY, timeoflab);
    dataset.setValue(Location.OR, timeofor);
    dataset.setValue(Location.OUTPATIEN, timeofoutpatient);
    dataset.setValue(Location.PHARMACY, timeofpha);
    dataset.setValue(Location.WARD, timeofward);

    JFreeChart chart = ChartFactory.createPieChart(" Chart", dataset, true, true, true);

    PiePlot p = (PiePlot) chart.getPlot();

    ChartFrame chartFrame = new ChartFrame("Location of events", chart);
    chartFrame.setSize(450, 550);
    chartFrame.setVisible(true);
}

From source file:com.indicator_engine.controller.GraphController.java

private PieDataset createDataSet(GLAIndicator glaIndicator) {
    DefaultPieDataset dpd = new DefaultPieDataset();
    GLAEntityDao glaEntityBean = (GLAEntityDao) appContext.getBean("glaEntity");
    Gson gson = new Gson();
    if (glaIndicator.getGlaIndicatorProps().isComposite()) {
        CompositeQuery[] compositeQuery = gson.fromJson(glaIndicator.getHql(), CompositeQuery[].class);
        for (int i = 0; i < compositeQuery.length; i++) {
            log.info("PIE CHART DATA : COMPOSITE \n" + compositeQuery[i].getQuery());
            dpd.setValue(compositeQuery[i].getParentIndName(),
                    glaEntityBean.findNumber(compositeQuery[i].getQuery()));
        }/*from   www. j a v  a2 s .  c o m*/
    } else {

        log.info("PIE CHART DATA : STARTED \n" + glaIndicator.getIndicator_name());
        dpd.setValue(glaIndicator.getIndicator_name(), glaEntityBean.findNumber(glaIndicator.getHql()));
    }

    return dpd;
}

From source file:com.swordlord.gozer.components.wicket.graph.GWPieChartPanel.java

public GWPieChartPanel(String id, IModel<?> model, GPieChart child) {
    super(id, model);

    DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey();
    DataBindingMember dbMemberValue = child.getDataBindingMemberValue();
    DataBindingManager dbManager = child.getDataBindingManager();

    DefaultPieDataset dpd = new DefaultPieDataset();

    List<DataRowBase> rowKeys = dbManager.getRows(dbMemberRowKey);
    List<DataRowBase> values = dbManager.getRows(dbMemberValue);

    String[] codes = new String[rowKeys.size()];
    int[] results = new int[rowKeys.size()];

    int i = 0;//from   w  ww. j  a  v a2  s  . c o  m
    for (DataRowBase row : rowKeys) {
        codes[i] = row.getPropertyAsString(dbMemberRowKey.getDataBindingFieldName());
        i++;
    }

    i = 0;
    for (DataRowBase row : values) {
        results[i] = row.getPropertyAsInt(dbMemberValue.getDataBindingFieldName());
        i++;
    }

    for (Integer j = 0; j < rowKeys.size(); j++) {
        dpd.setValue(MessageFormat.format("{0}: {1}", codes[j], results[j]), results[j]);
    }

    JFreeChart chart = ChartFactory.createPieChart(child.getTitle(), dpd, child.getLegend(), false, false);

    chart.setBackgroundPaint(Color.white);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDrawingSupplier(child.getDrawingSupplier());

    ChartImage image = new ChartImage("chart", chart, child.getWidth(200), child.getHeight(200));
    add(image);

}

From source file:co.edu.eam.dinesoft.egresados.vista.gui.VentanaReportes.java

/**
 * Grafica de pastel//from  w w  w .  j  a  va  2s .  c o m
 */
public void reporteEgresadosOcupacion() {
    ChartPanel panel;
    try {
        List<InformacionLaboral> listaInfoLab = controlador.listarInfoLab();

        double empleado = 0;
        double desempleado = 0;
        double independiente = 0;
        double empresario = 0;

        int contadorEmpleado = 0;
        int contadordDesempleado = 0;
        int contadorIndependiente = 0;
        int contadorEmpresario = 0;

        if (listaInfoLab.size() == 0) {
            JOptionPane.showMessageDialog(null, "No hay egresados registrados");
        }

        for (InformacionLaboral informacionLaboral : listaInfoLab) {
            if (informacionLaboral.getSituaActual().equals(SituacionActual.EMPLEADO)) {
                contadorEmpleado++;
            } else if (informacionLaboral.getSituaActual().equals(SituacionActual.DESEMPLEADO)) {
                contadordDesempleado++;
            } else if (informacionLaboral.getSituaActual().equals(SituacionActual.INDEPENDIENTE)) {
                contadorIndependiente++;
            } else if (informacionLaboral.getSituaActual().equals(SituacionActual.EMPRESARIO)) {
                contadorEmpresario++;
            }

            empleado = (contadorEmpleado * 100) / listaInfoLab.size();
            desempleado = (contadordDesempleado * 100) / listaInfoLab.size();
            independiente = (contadorIndependiente * 100) / listaInfoLab.size();
            empresario = (contadorEmpresario * 100) / listaInfoLab.size();
        }
        DefaultPieDataset ds = new DefaultPieDataset();
        ds.setValue("EMPLEADO: " + empleado + "%", empleado);
        ds.setValue("DESEMPLEADO: " + desempleado + "%", desempleado);
        ds.setValue("INDEPENDIENTE: " + independiente + "%", independiente);
        ds.setValue("EMPRESARIO: " + empresario + "%", empresario);

        JFreeChart jf = ChartFactory.createPieChart3D("Reporte de egresados por tipo de ocupacin", ds, true,
                true, true);

        panel = new ChartPanel(jf);
        panel.setBounds(20, 50, 720, 350);

        jPGrafica.add(panel);

    } catch (Exception e) {
        // TODO: handle exception
    }

}

From source file:com.swordlord.gozer.components.fop.graph.GFopPieChart.java

public GFopPieChart(IGozerFrameExtension gfe, GPieChart child) {
    super(gfe);//from w w w. j  a v  a2 s.  c  om

    DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey();
    DataBindingMember dbMemberValue = child.getDataBindingMemberValue();
    DataBindingManager dbManager = child.getDataBindingManager();

    DefaultPieDataset dpd = new DefaultPieDataset();

    List<DataRowBase> rowKeys = dbManager.getRows(dbMemberRowKey);
    List<DataRowBase> values = dbManager.getRows(dbMemberValue);

    String[] codes = new String[rowKeys.size()];
    int[] results = new int[rowKeys.size()];

    int i = 0;
    for (DataRowBase row : rowKeys) {
        codes[i] = row.getPropertyAsString(dbMemberRowKey.getDataBindingFieldName());
        i++;
    }

    i = 0;
    for (DataRowBase row : values) {
        results[i] = row.getPropertyAsInt(dbMemberValue.getDataBindingFieldName());
        i++;
    }

    for (Integer j = 0; j < rowKeys.size(); j++) {
        dpd.setValue(MessageFormat.format("{0}: {1}", codes[j], results[j]), results[j]);
    }

    JFreeChart chart = ChartFactory.createPieChart(child.getTitle(), dpd, child.getLegend(), false, false);

    chart.setBackgroundPaint(Color.white);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDrawingSupplier(child.getDrawingSupplier());

    _image = new ChartImage("chart", chart, child.getWidth(800), child.getHeight(800));
}

From source file:co.edu.eam.dinesoft.egresados.vista.gui.VentanaReportes.java

private void jCBProgramaRep1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCBProgramaRep1ItemStateChanged
    // TODO add your handling code here:
    ChartPanel panel;/* w ww  .j  av a 2  s . co m*/
    try {

        Programa programa = (Programa) jCBProgramaRep1.getSelectedItem();

        List<InformacionLaboral> listaInfoLab = controlador.infoLabPro(programa);

        jPGrafica.removeAll();

        double empleado = 0;
        double desempleado = 0;
        double independiente = 0;
        double empresario = 0;

        int contadorEmpleado = 0;
        int contadordDesempleado = 0;
        int contadorIndependiente = 0;
        int contadorEmpresario = 0;

        if (listaInfoLab.size() == 0) {
            JOptionPane.showMessageDialog(null, "No egresados registrados");
        }

        for (InformacionLaboral informacionLaboral : listaInfoLab) {
            if (informacionLaboral.getSituaActual().equals(SituacionActual.EMPLEADO)) {
                contadorEmpleado++;
            } else if (informacionLaboral.getSituaActual().equals(SituacionActual.DESEMPLEADO)) {
                contadordDesempleado++;
            } else if (informacionLaboral.getSituaActual().equals(SituacionActual.INDEPENDIENTE)) {
                contadorIndependiente++;
            } else if (informacionLaboral.getSituaActual().equals(SituacionActual.EMPRESARIO)) {
                contadorEmpresario++;
            }

            empleado = (contadorEmpleado * 100) / listaInfoLab.size();
            desempleado = (contadordDesempleado * 100) / listaInfoLab.size();
            independiente = (contadorIndependiente * 100) / listaInfoLab.size();
            empresario = (contadorEmpresario * 100) / listaInfoLab.size();
        }
        DefaultPieDataset ds = new DefaultPieDataset();
        ds.setValue("EMPLEADO: " + empleado + "%", empleado);
        ds.setValue("DESEMPLEADO: " + desempleado + "%", desempleado);
        ds.setValue("INDEPENDIENTE: " + independiente + "%", independiente);
        ds.setValue("EMPRESARIO: " + empresario + "%", empresario);

        JFreeChart jf = ChartFactory.createPieChart3D("Reporte de egresados por tipo de ocupacin", ds, true,
                true, true);

        panel = new ChartPanel(jf);
        panel.setBounds(20, 50, 720, 350);

        jPGrafica.add(panel);

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}