userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.java Source code

Java tutorial

Introduction

Here is the source code for userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.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.DistrictAdminRole;

import business.EcoDistrict;
import business.Enterprise.CommunityEnterprise;
import business.Enterprise.Enterprise;
import business.Neighborhood.Neighborhood;
import business.Organization.HouseholdOrg;
import business.Organization.Organization;
import business.Person.Member;
import business.Person.Person;
import business.Sensors.Sensor;
import business.vitalSignSensor.VitalSign;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.util.ArrayList;
import java.awt.Component;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 *
 * @author Reshmi
 */
public class MonitorNeighborhoodAreasJPanel extends javax.swing.JPanel {

    /**
     * Creates new form MonitorNeighborhoodAreasJPanel
     */
    private JPanel userProcessContainer;
    private EcoDistrict ecoDistrict;
    private ArrayList<Person> healthyFamily = new ArrayList<>();
    private ArrayList<Person> unHealthyFamily = new ArrayList<>();
    private ArrayList<Person> efficientHouse = new ArrayList<>();
    private ArrayList<Person> unefficientHouse = new ArrayList<>();

    public MonitorNeighborhoodAreasJPanel(JPanel userProcessContainer, EcoDistrict ecoDistrict) {
        initComponents();
        this.userProcessContainer = userProcessContainer;
        this.ecoDistrict = ecoDistrict;

        populateComboBox();

    }

    public void populateComboBox() {
        areasComboBox.removeAllItems();
        for (Neighborhood area : ecoDistrict.getNeighborhoodList()) {
            areasComboBox.addItem(area);
        }
    }
    //    public void populateHouseAdmins(Neighborhood area){
    //        familyHeadComboBox.removeAllItems();
    //            for(Enterprise ent : area.getEnterpriseList().getEnterpriseList()){
    //                if(ent instanceof CommunityEnterprise){
    //                    for(Organization org : ent.getOrganizationList().getOrganizationList()){
    //                        if(org instanceof HouseholdOrg){
    //                            for(Person person : org.getPersonDir().getPersonDir()){
    //                                familyHeadComboBox.addItem(person);
    //                            }
    //                        }
    //                    }
    //                }
    //            } 
    //    }

    public void googleMaps() {
        Neighborhood area = (Neighborhood) areasComboBox.getSelectedItem();
        String loc1 = area.getNeighborhoodName();
        loc1 = loc1.replace(' ', '+');
        String marker1 = loc1;

        BufferedImage image;
        try {
            image = ImageIO.read(new URL(
                    "http://maps.googleapis.com/maps/api/staticmap?autoscale=1&size=400x400&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xff0000%7Clabel:1%7C"
                            + marker1));
            mapLabel1.setIcon(new ImageIcon(image));
        } catch (IOException ex) {
            Logger.getLogger(MonitorNeighborhoodAreasJPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void browserMethod() {
        Neighborhood area = (Neighborhood) areasComboBox.getSelectedItem();
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);
        JFrame frame = new JFrame("JxBrowser Google Maps");
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        browser.loadURL("https://www.google.com/maps/place/" + area);
    }

    /**
     * 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() {

        areasComboBox = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        healthyFamilyBtn = new javax.swing.JButton();
        viewAreaBtn = new javax.swing.JButton();
        backJButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        mapLabel1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        efFamilesTable = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        unefFamilesTable = new javax.swing.JTable();
        efficientFamilyCountTxt = new javax.swing.JTextField();
        unefficientFamilyCountTxt = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        hFamilesTable = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        uhFamilesTable = new javax.swing.JTable();
        healthyFamilyCountTxt = new javax.swing.JTextField();
        unhealthyFamilyCountTxt = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        areasComboBox.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        areasComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                areasComboBoxActionPerformed(evt);
            }
        });

        jLabel1.setText("Areas");

        healthyFamilyBtn.setBackground(new java.awt.Color(0, 153, 0));
        healthyFamilyBtn.setFont(new java.awt.Font("Verdana", 3, 12)); // NOI18N
        healthyFamilyBtn.setForeground(new java.awt.Color(255, 255, 255));
        healthyFamilyBtn.setText("Show Community Statistics");
        healthyFamilyBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                healthyFamilyBtnActionPerformed(evt);
            }
        });

        viewAreaBtn.setBackground(new java.awt.Color(0, 153, 0));
        viewAreaBtn.setFont(new java.awt.Font("Verdana", 3, 12)); // NOI18N
        viewAreaBtn.setForeground(new java.awt.Color(255, 255, 255));
        viewAreaBtn.setText("View Area");
        viewAreaBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAreaBtnActionPerformed(evt);
            }
        });

        backJButton.setBackground(new java.awt.Color(0, 153, 0));
        backJButton.setFont(new java.awt.Font("Verdana", 3, 12)); // NOI18N
        backJButton.setForeground(new java.awt.Color(255, 255, 255));
        backJButton.setText("<< Back");
        backJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButtonActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Area Map",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 0, 11),
                new java.awt.Color(102, 0, 102))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout
                .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                                .addComponent(mapLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
                                .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel1Layout.createSequentialGroup().addContainerGap()
                                .addComponent(mapLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                                .addContainerGap()));

        jTabbedPane1.setBackground(new java.awt.Color(255, 255, 255));
        jTabbedPane1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
                "Community Members Energy Consumption Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 0, 11),
                new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jLabel3.setText("Houses with Efficient Energy Usage");

        efFamilesTable.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        efFamilesTable.setModel(
                new javax.swing.table.DefaultTableModel(new Object[][] { { null }, { null }, { null }, { null } },
                        new String[] { "Efficient Usage Houses" }) {
                    boolean[] canEdit = new boolean[] { false };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit[columnIndex];
                    }
                });
        jScrollPane3.setViewportView(efFamilesTable);

        unefFamilesTable.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        unefFamilesTable.setModel(
                new javax.swing.table.DefaultTableModel(new Object[][] { { null }, { null }, { null }, { null } },
                        new String[] { "More Energy Consuming Houses" }) {
                    boolean[] canEdit = new boolean[] { false };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit[columnIndex];
                    }
                });
        jScrollPane2.setViewportView(unefFamilesTable);

        efficientFamilyCountTxt.setEditable(false);
        efficientFamilyCountTxt.setBackground(new java.awt.Color(255, 255, 255));
        efficientFamilyCountTxt.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        unefficientFamilyCountTxt.setEditable(false);
        unefficientFamilyCountTxt.setBackground(new java.awt.Color(255, 255, 255));
        unefficientFamilyCountTxt.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jLabel4.setText("Houses with High Energy Usage");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 124,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel4))
                        .addGap(15, 15, 15)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(efficientFamilyCountTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(unefficientFamilyCountTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10).addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 142,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 101,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel2Layout.createSequentialGroup().addGap(18, 18, 18)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel3).addComponent(efficientFamilyCountTxt,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel2Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel4).addComponent(unefficientFamilyCountTxt,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 101,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap()));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));

        jTabbedPane1.addTab("Efficient/Unefficient Usage", jPanel4);

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Community Members Health Data",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 0, 11),
                new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jLabel5.setText("Number of Healthy Families");

        hFamilesTable.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        hFamilesTable.setModel(
                new javax.swing.table.DefaultTableModel(new Object[][] { { null }, { null }, { null }, { null } },
                        new String[] { "Healthy Family Admins" }) {
                    boolean[] canEdit = new boolean[] { false };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit[columnIndex];
                    }
                });
        jScrollPane4.setViewportView(hFamilesTable);

        uhFamilesTable.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        uhFamilesTable.setModel(
                new javax.swing.table.DefaultTableModel(new Object[][] { { null }, { null }, { null }, { null } },
                        new String[] { "UnHealthy Family Admins" }) {
                    boolean[] canEdit = new boolean[] { false };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit[columnIndex];
                    }
                });
        jScrollPane5.setViewportView(uhFamilesTable);

        healthyFamilyCountTxt.setEditable(false);
        healthyFamilyCountTxt.setBackground(new java.awt.Color(255, 255, 255));
        healthyFamilyCountTxt.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        unhealthyFamilyCountTxt.setEditable(false);
        unhealthyFamilyCountTxt.setBackground(new java.awt.Color(255, 255, 255));
        unhealthyFamilyCountTxt.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jLabel6.setText("Number of Unhealthy Families");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 124,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)
                        .addGroup(
                                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel6))
                        .addGap(15, 15, 15)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(healthyFamilyCountTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(unhealthyFamilyCountTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(16, 16, 16).addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 142,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 101,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel3Layout.createSequentialGroup().addGap(18, 18, 18)
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel5).addComponent(healthyFamilyCountTxt,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel6).addComponent(unhealthyFamilyCountTxt,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 101,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap()));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(jPanel5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 23, Short.MAX_VALUE)));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jTabbedPane1.addTab("Healthy/Unhealthy Homes", jPanel5);

        jTabbedPane1.setSelectedIndex(1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addGap(20, 20, 20).addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup().addComponent(jLabel1)
                                                .addGap(40, 40, 40)
                                                .addComponent(areasComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(61, 61, 61)
                                                .addComponent(viewAreaBtn, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        113, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup().addGap(151, 151, 151)
                                                .addComponent(healthyFamilyBtn))
                                        .addGroup(layout.createSequentialGroup().addGap(10, 10, 10).addComponent(
                                                jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(0, 0, Short.MAX_VALUE)))
                                .addContainerGap())
                        .addGroup(layout.createSequentialGroup().addComponent(backJButton).addGap(0, 0,
                                Short.MAX_VALUE)))));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGap(26, 26, 26)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(areasComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel1)))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                layout.createSequentialGroup().addContainerGap().addComponent(viewAreaBtn)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18).addComponent(healthyFamilyBtn).addGap(32, 32, 32)
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 194,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20).addComponent(backJButton).addGap(30, 30, 30)));
    }// </editor-fold>//GEN-END:initComponents

    private void areasComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_areasComboBoxActionPerformed
        Neighborhood area = (Neighborhood) areasComboBox.getSelectedItem();
        if (area != null) {
            googleMaps();
            //populateHouseAdmins(area);

        }
    }//GEN-LAST:event_areasComboBoxActionPerformed

    private void healthyFamilyBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_healthyFamilyBtnActionPerformed
        Neighborhood area = (Neighborhood) areasComboBox.getSelectedItem();
        if (area != null) {
            healthyPerson(area);
            efficientEnergyHouse(area);
        }
    }//GEN-LAST:event_healthyFamilyBtnActionPerformed

    private void viewAreaBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAreaBtnActionPerformed
        browserMethod();
    }//GEN-LAST:event_viewAreaBtnActionPerformed

    private void backJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButtonActionPerformed
        userProcessContainer.remove(this);
        CardLayout layout = (CardLayout) userProcessContainer.getLayout();
        layout.previous(userProcessContainer);
    }//GEN-LAST:event_backJButtonActionPerformed

    public void efficientEnergyHouse(Neighborhood area) {
        for (Enterprise ent : area.getEnterpriseList().getEnterpriseList()) {
            if (ent instanceof CommunityEnterprise) {
                for (Organization org : ent.getOrganizationList().getOrganizationList()) {
                    if (org instanceof HouseholdOrg) {
                        int unEfficient = 0;
                        for (Person person : org.getPersonDir().getPersonDir()) {
                            int count = 0;
                            for (Sensor sensor : person.getSensorsList().getSensorsList()) {
                                int n = person.getSensorsList().getSensorsList().size();

                                if (n == 1) {
                                    if (sensor.getConsumptionLevel().equals("Efficient")) {
                                        count++;
                                    }
                                } else if (n > 1) {
                                    Sensor s1 = person.getSensorsList().getSensorsList().get(n - 1);
                                    Sensor s2 = person.getSensorsList().getSensorsList().get(n - 2);
                                    if (s1.getReadingRecorded().compareTo(s2.getReadingRecorded()) >= 0) {
                                        if (s1.getConsumptionLevel().equals("Efficient")
                                                || s2.getConsumptionLevel().equals("Efficient")) {
                                            count++;
                                        }
                                    }
                                }
                            }
                            if (person.getSensorsList().getSensorsList().size() >= count - 1) {
                                efficientHouse.add(person);
                                efficientFamilyCountTxt.setText(String.valueOf(efficientHouse.size()));
                                populateEfficientFamily(person);
                            } else {
                                unefficientHouse.add(person);
                                unefficientFamilyCountTxt.setText(String.valueOf(unefficientHouse.size()));
                                populateUnEfficientFamily(person);
                            }

                        }
                    }
                }
            }
        }
    }

    public void healthyPerson(Neighborhood area) {
        for (Enterprise ent : area.getEnterpriseList().getEnterpriseList()) {
            if (ent instanceof CommunityEnterprise) {
                for (Organization org : ent.getOrganizationList().getOrganizationList()) {
                    if (org instanceof HouseholdOrg) {
                        int unHeathlyCount = 0;
                        for (Person person : org.getPersonDir().getPersonDir()) {
                            int count = 0;
                            for (Member member : person.getMemberDir().getMemberDirectory()) {
                                int n = member.getVitalSignList().getVitalSignList().size();
                                for (VitalSign vs : member.getVitalSignList().getVitalSignList()) {
                                    if (n == 1) {
                                        if (vs.getStatus().equals("Normal")) {
                                            count++;
                                        }
                                    } else if (n > 1) {
                                        VitalSign vs1 = member.getVitalSignList().getVitalSignList().get(n - 1);
                                        VitalSign vs2 = member.getVitalSignList().getVitalSignList().get(n - 2);
                                        if (vs1.getTimestamp().compareTo(vs2.getTimestamp()) >= 0) {
                                            if (vs1.getStatus().equals("Normal")
                                                    || vs2.getStatus().equals("Normal")) {
                                                count++;
                                            }
                                        }
                                    }
                                }
                            }
                            if (person.getMemberDir().getMemberDirectory().size() <= count) {
                                healthyFamily.add(person);
                                healthyFamilyCountTxt.setText(String.valueOf(healthyFamily.size()));
                                populateHealthyFamily(person);
                            } else {
                                unHealthyFamily.add(person);
                                unhealthyFamilyCountTxt.setText(String.valueOf(unHealthyFamily.size()));
                                populateunHealthyFamily(person);
                            }
                        }
                    }
                }
            }
        }
    }

    public void populateHealthyFamily(Person person) {
        DefaultTableModel model = (DefaultTableModel) hFamilesTable.getModel();
        model.setRowCount(0);
        for (Person p : healthyFamily) {
            Object[] row = new Object[1];
            row[0] = p;
            model.addRow(row);
        }
    }

    public void populateunHealthyFamily(Person person) {
        DefaultTableModel model = (DefaultTableModel) uhFamilesTable.getModel();
        model.setRowCount(0);
        for (Person p : unHealthyFamily) {
            Object[] row = new Object[1];
            row[0] = p;
            model.addRow(row);
        }
    }

    public void populateEfficientFamily(Person person) {
        DefaultTableModel model = (DefaultTableModel) efFamilesTable.getModel();
        model.setRowCount(0);
        for (Person p : efficientHouse) {
            Object[] row = new Object[1];
            row[0] = p;
            model.addRow(row);
        }
    }

    public void populateUnEfficientFamily(Person person) {
        DefaultTableModel model = (DefaultTableModel) unefFamilesTable.getModel();
        model.setRowCount(0);
        for (Person p : unefficientHouse) {
            Object[] row = new Object[1];
            row[0] = p;
            model.addRow(row);
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox areasComboBox;
    private javax.swing.JButton backJButton;
    private javax.swing.JTable efFamilesTable;
    private javax.swing.JTextField efficientFamilyCountTxt;
    private javax.swing.JTable hFamilesTable;
    private javax.swing.JButton healthyFamilyBtn;
    private javax.swing.JTextField healthyFamilyCountTxt;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel mapLabel1;
    private javax.swing.JTable uhFamilesTable;
    private javax.swing.JTable unefFamilesTable;
    private javax.swing.JTextField unefficientFamilyCountTxt;
    private javax.swing.JTextField unhealthyFamilyCountTxt;
    private javax.swing.JButton viewAreaBtn;
    // End of variables declaration//GEN-END:variables
}