Example usage for org.jfree.chart ChartFrame ChartFrame

List of usage examples for org.jfree.chart ChartFrame ChartFrame

Introduction

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

Prototype

public ChartFrame(String title, JFreeChart chart) 

Source Link

Document

Constructs a frame for a chart.

Usage

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  w  w . j  av a 2 s .  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:datavis.Gui.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    //Initialize a copy of the current Pie chart on display and then create a pop-up containing it

    //Get the chart based on the Combobox item
    String sItem = jComboBox1.getSelectedItem().toString();
    sItem = sItem.replaceAll("\\s+", "");
    sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : "");

    JFreeChart popOut_PieChart = dataset.getPieChartChart(sItem);

    //Create the pop-up
    ChartFrame frame = new ChartFrame(dataset.getStationName() + "  (" + dataset.getStationID() + ")",
            popOut_PieChart);//  w w w  . ja v  a2  s .  co  m
    frame.setVisible(true);
    frame.setSize(450, 450);

}

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  ww w  .  j a v  a2s. co  m*/
    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:datavis.Gui.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    //Initialize a copy of the current Line chart on display and then create a pop-up containing it

    //Get the chart based on the Combobox item
    String sItem = jComboBox2.getSelectedItem().toString();
    sItem = sItem.replaceAll("\\s+", "");
    sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : "");

    //Create the pop-up
    JFreeChart popOut_PieChart = dataset.getLineGraphChart(sItem);
    ChartFrame frame = new ChartFrame(dataset.getStationName() + "  (" + dataset.getStationID() + ")",
            popOut_PieChart);/*from ww w .ja v a 2  s . c  o m*/
    frame.setVisible(true);
    frame.setSize(450, 450);

}

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   ww  w.  j  a v  a  2s  . c  om
    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:userinterface.PatientRole.PatientWorkAreaJPanel.java

private void btnViewBarsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewBarsActionPerformed

    if (patient.vitalSignHistory.getVitalSignHistory().size() > 0) {

        String legend = null;//w  w w  . ja v  a 2  s.c o m
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (VitalSign vs : patient.vitalSignHistory.getVitalSignHistory()) {

            /*if(vs.getState().equalsIgnoreCase("ABNORMAL"))
            legend=vs.getTimestamp().concat(" (" +vs.getState()+")");
            else*/
            legend = vs.getTimestamp();

            dataset.addValue(vs.getRespiratoryRate(), legend, "Respiratory Rate");
            dataset.addValue(vs.getHeartRate(), legend, "Heart Rate");
            dataset.addValue(vs.getSystolicBloodPressure(), legend, "Blood Pressure");
            dataset.addValue(vs.getWeight(), legend, "Weight");

        }

        JFreeChart chart = ChartFactory.createBarChart3D("Vital Signs", "Vital Signs", "Values", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        CategoryPlot P = chart.getCategoryPlot();
        P.setRangeGridlinePaint(Color.BLACK);

        ChartFrame frame = new ChartFrame("Bar Charts", chart);
        frame.setVisible(true);
        frame.setSize(650, 550);

    } else {
        JOptionPane.showMessageDialog(null, "There's no Vital Sign reported for this patient");
        return;
    }

}

From source file:datavis.Gui.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

    //Initialize a copy of the current Bar chart on display and then create a pop-up containing it

    //Get the chart based on the Combobox item

    String sItem = jComboBox3.getSelectedItem().toString();
    sItem = sItem.replaceAll("\\s+", "");
    sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : "");

    //Create the pop-up
    JFreeChart popOut_PieChart = dataset.getBarGraphChart(sItem);
    ChartFrame frame = new ChartFrame(dataset.getStationName() + "  (" + dataset.getStationID() + ")",
            popOut_PieChart);/*from w ww  . jav  a 2  s .c  o  m*/
    frame.setVisible(true);
    frame.setSize(450, 450);

}

From source file:User.Interface.InventoryAdminRole.InventoryAdminWorkAreaJPanel.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    //check if the supplier has products in the product list
    if (inventoryEnterprise.getWarehouse().getMdeciDeviceCatalog().getMedicalDeviceList().size() < 0) {
        JOptionPane.showMessageDialog(this, "No devices found in the inventory.", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;//from  www. j a va  2 s.  c o  m
    }

    MedicalDevice[] product;
    product = new MedicalDevice[100];

    int numberOfProducts = inventoryEnterprise.getWarehouse().getMdeciDeviceCatalog().getMedicalDeviceList()
            .size();
    DefaultCategoryDataset dataSetProduct = new DefaultCategoryDataset();

    for (int i = 0; i < numberOfProducts; i++) {
        product[i] = inventoryEnterprise.getWarehouse().getMdeciDeviceCatalog().getMedicalDeviceList().get(i);
        int soldQuantity = 0;
        soldQuantity = product[i].getNumUses();
        String prodName = product[i].getDeviceName();
        dataSetProduct.setValue(soldQuantity, "Medical Device", prodName);
    }

    JFreeChart chartProduct = ChartFactory.createBarChart("Device Usage Report", "Device",
            "Number of times usdr", dataSetProduct, PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot p1 = chartProduct.getCategoryPlot();
    p1.setRangeGridlinePaint(Color.black);
    ChartFrame frame1 = new ChartFrame("Device Usage Report", chartProduct);
    frame1.setVisible(true);
    frame1.setSize(400, 400);
    Point pt1 = new Point(0, 0);
    frame1.setLocation(pt1);
}

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

private void createChart() {
    DefaultCategoryDataset vitalSignDataset = new DefaultCategoryDataset();
    int selectedRow = viewPatientsJTable.getSelectedRow();
    Person person = (Person) viewPatientsJTable.getValueAt(selectedRow, 0);
    Patient patient = person.getPatient();
    if (patient == null) {
        JOptionPane.showMessageDialog(this, "Patient not created, Please create Patient first.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;//from   w  w  w. j  a  v  a 2 s. co m
    }

    ArrayList<VitalSign> vitalSignList = patient.getVitalSignHistory().getHistory();
    /*At least 2 vital sign records needed to show chart */
    if (vitalSignList.isEmpty() || vitalSignList.size() == 1) {
        JOptionPane.showMessageDialog(this,
                "No vital signs or only one vital sign found. At least 2 vital sign records needed to show chart!",
                "Warning", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    for (VitalSign vitalSign : vitalSignList) {
        vitalSignDataset.addValue(vitalSign.getRespiratoryRate(), "RR", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getHeartRate(), "HR", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getBloodPressure(), "BP", vitalSign.getTimestamp());
        vitalSignDataset.addValue(vitalSign.getWeight(), "WT", vitalSign.getTimestamp());
    }

    JFreeChart vitalSignChart = ChartFactory.createBarChart3D("Vital Sign Chart", "Time Stamp", "Rate",
            vitalSignDataset, PlotOrientation.VERTICAL, true, false, false);
    vitalSignChart.setBackgroundPaint(Color.white);
    CategoryPlot vitalSignChartPlot = vitalSignChart.getCategoryPlot();
    vitalSignChartPlot.setBackgroundPaint(Color.lightGray);

    CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis();
    vitalSignDomainAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis();
    vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartFrame chartFrame = new ChartFrame("Chart", vitalSignChart);
    chartFrame.setVisible(true);
    chartFrame.setSize(500, 500);

}

From source file:UserInterfaces.HAdministration.FallReportJPanel.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 w w.  ja  v a2 s . c om*/
    int max = 0;

    for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) {
        if (workRequest.getLevel2().equals(ErrorUtil.FALL)) {
            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);

}