UserInterface.DoctorRole.DoctorReportChartJPanel.java Source code

Java tutorial

Introduction

Here is the source code for UserInterface.DoctorRole.DoctorReportChartJPanel.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package UserInterface.DoctorRole;

import Business.EcoSystem;
import Business.Enterprise.Enterprise;
import Business.Report.ReportToReporter;
import Business.UserAccount.UserAccount;
import java.awt.Color;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

/**
 *
 * @author Jeremy
 */
public class DoctorReportChartJPanel extends javax.swing.JPanel {

    /**
     * Creates new form DoctorReportToReporterChartJPanel
     */
    JPanel container;
    UserAccount ua;

    Enterprise enterprise;
    EcoSystem es;

    public DoctorReportChartJPanel(JPanel container, UserAccount ua, Enterprise enterpirse, EcoSystem ecoSystem) {
        initComponents();
        this.container = container;
        this.ua = ua;
        this.enterprise = enterpirse;
        es = ecoSystem;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        level1jButton1 = new javax.swing.JButton();
        feedjButton2 = new javax.swing.JButton();
        personneljButton3 = new javax.swing.JButton();
        sourcejButton1 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();

        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        level1jButton1.setText("View");
        level1jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                level1jButton1ActionPerformed(evt);
            }
        });
        add(level1jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(65, 204, -1, -1));

        feedjButton2.setText("View");
        feedjButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                feedjButton2ActionPerformed(evt);
            }
        });
        add(feedjButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(65, 448, -1, -1));

        personneljButton3.setText("View");
        personneljButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                personneljButton3ActionPerformed(evt);
            }
        });
        add(personneljButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(65, 324, -1, -1));

        sourcejButton1.setText("View");
        sourcejButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sourcejButton1ActionPerformed(evt);
            }
        });
        add(sourcejButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 560, -1, -1));

        jLabel7.setFont(new java.awt.Font("Verdana", 1, 24)); // NOI18N
        jLabel7.setIcon(new javax.swing.ImageIcon(
                getClass().getResource("/UserInterface/PatientRole/Screen Shot 2013-12-10 at 6.17.30 PM.png"))); // NOI18N
        add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(116, 0, 470, 40));
        add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 40, 690, 10));

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jLabel3.setText("Reported Medical Error");
        add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 170, -1, -1));

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jLabel4.setText("Related Personnel of Reported Medical Error");
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 290, -1, -1));

        jLabel2.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jLabel2.setText("Were the reporter satisfied with the ");
        add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 390, -1, -1));

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jLabel6.setText("respond of the institutes they reported :");
        add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 420, -1, -1));

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jLabel5.setText("Source of Reports");
        add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 530, -1, -1));
    }// </editor-fold>//GEN-END:initComponents

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

        ReportToReporter report = enterprise.getReport();
        if (report.getStatus() != null) {
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            dataset.addValue(report.getIncidentnumber(), "Incident", "Incident");
            dataset.addValue(report.getNearmissnumber(), "Near miss", "Near miss");
            dataset.addValue(report.getUnsafenumber(), "Unsafe condition", "Unsafe condition");

            JFreeChart chart = ChartFactory.createBarChart("Level1 Error", "Error Name", "Times", dataset,
                    PlotOrientation.VERTICAL, false, true, false);
            CategoryPlot plot = chart.getCategoryPlot();
            plot.setRangeGridlinePaint(Color.DARK_GRAY);
            ChartFrame frame = new ChartFrame("Chart for ERROR", chart);
            frame.setVisible(true);
            frame.setSize(350, 450);
        } else {
            JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated");

        }

        // report.getMaxlevel1() = maxlevel1number;
    }//GEN-LAST:event_level1jButton1ActionPerformed

    private void feedjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_feedjButton2ActionPerformed
        // TODO add your handling code here:
        ReportToReporter report = enterprise.getReport();
        if (report.getStatus() != null) {
            DefaultPieDataset pieDataset = new DefaultPieDataset();
            pieDataset.setValue("satisfy", report.getYes());
            pieDataset.setValue("not satisfy", report.getNo());
            JFreeChart chart = ChartFactory.createPieChart("Satifaction", pieDataset, true, true, true);

            PiePlot p = (PiePlot) chart.getPlot();
            // p.setForegroundAlpha(TOP_ALIGNMENT);

            ChartFrame frame = new ChartFrame("Chart for Satifaction", chart);
            frame.setVisible(true);
            frame.setSize(350, 450);
        } else {
            JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated");
        }

    }//GEN-LAST:event_feedjButton2ActionPerformed

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

        ReportToReporter report = enterprise.getReport();
        if (report.getStatus() != null) {
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            dataset.addValue(report.getTimeofadmin(), "Adminstration", "Adminstration");
            dataset.addValue(report.getTimeofnurse(), "Nurse", "Nurse");
            dataset.addValue(report.getTimeofpathology(), "Pathologist", "Pathologist");
            dataset.addValue(report.getTimeofphar(), "Pharmacist", "Pharmacist");
            dataset.addValue(report.getTimeofphysician(), "Physician", "Physician");
            dataset.addValue(report.getTimeofsurgeon(), "Surgeon", "Surgeon");
            //dataset.setValue(80, "masd", "sss");

            JFreeChart chart = ChartFactory.createBarChart("Personnel", "Position", "Times", dataset,
                    PlotOrientation.VERTICAL, false, true, false);
            CategoryPlot plot = chart.getCategoryPlot();
            plot.setRangeGridlinePaint(Color.WHITE);
            ChartFrame frame = new ChartFrame("Chart for ERROR", chart);
            frame.setVisible(true);
            frame.setSize(550, 550);

        } else {
            JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated");
        }
    }//GEN-LAST:event_personneljButton3ActionPerformed

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

        ReportToReporter report = enterprise.getReport();
        if (report.getStatus() != null) {
            DefaultPieDataset dataset = new DefaultPieDataset();
            dataset.setValue("First hand", report.getFirsthandsource());
            dataset.setValue("Second hand", report.getSecondhandsource());

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

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

            ChartFrame chartFrame = new ChartFrame("Source of Reports", chart);
            chartFrame.setSize(450, 550);
            chartFrame.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(null, "Sorry, the final report has not been generated");
        }

    }//GEN-LAST:event_sourcejButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton feedjButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JButton level1jButton1;
    private javax.swing.JButton personneljButton3;
    private javax.swing.JButton sourcejButton1;
    // End of variables declaration//GEN-END:variables
}