diff --git a/Footprint/Attributes.java b/Footprint/Attributes.java new file mode 100644 index 0000000..e26bc36 --- /dev/null +++ b/Footprint/Attributes.java @@ -0,0 +1,25 @@ +package footprint; + +public class Attributes { + + int number_of_roads; + double area_of_city; + double co2; + double co; + double ch; + double hc; + double nox; + double pm; + double so2; + double calculate_industry + ( + double co2, + double co, + double ch, + double hc, + double nox, + double pm, + double so2){ + return (ch+ co+ co2+ hc+ nox+ pm+ so2)*8.91*28 /1000; + } +} diff --git a/Footprint/Industry.java b/Footprint/Industry.java new file mode 100644 index 0000000..81a1b5a --- /dev/null +++ b/Footprint/Industry.java @@ -0,0 +1,841 @@ +package footprint; + +import java.util.*; + +import java.util.concurrent.TimeUnit; + +import java.awt.EventQueue; + +import java.awt.FlowLayout; + + + +import javax.swing.JFrame; + +import javax.swing.JPanel; + +import javax.swing.JTextArea; + +import javax.swing.border.Border; + +import javax.swing.border.EmptyBorder; + + + +import java.awt.BorderLayout; + +import java.awt.Color; + +import java.awt.Dimension; + + + +import javax.swing.JLabel; + +import java.awt.Font; + +import java.awt.Graphics; + +import java.awt.GridLayout; + +import java.awt.event.ActionEvent; + +import java.awt.event.ActionListener; + + + +import javax.swing.SwingConstants; + +import javax.swing.JTextField; + +import javax.swing.BorderFactory; + +import javax.swing.ImageIcon; + +import javax.swing.JButton; + + + + + + + +class individual { + + static double co2; + + static double co; + + static double ch; + + static double hc; + + static double nox; + + static double pm; + + static double so2; + + static double footprint; + + void accept() { + + JFrame f = new JFrame("First Page"); + + f.setSize(1200, 800); + + f.setLayout(new FlowLayout()); + +//Color color=new Color(153, 153 ,153); + +//f.getContentPane().setBackground(color); + + JLabel l1 = new JLabel("INDUSTRIAL FOOTPRINT", JLabel.CENTER); + + l1.setOpaque(true); + + l1.setBackground(new Color(0, 102, 0)); + + l1.setForeground(Color.WHITE); + + l1.setFont(new Font("Arial", Font.BOLD, 30)); + + l1.setPreferredSize(new Dimension(1200, 100)); + + Border blackline = BorderFactory.createLineBorder(Color.green); + + l1.setBorder(blackline); + + Color c1 = new Color(0, 160,0); + +// create a border for the label + + Border border = BorderFactory.createMatteBorder(2, 0, 2, 0,Color.GREEN); + + l1.setBorder(border); + + f.add(l1); + + + JLabel nameLabel0 = new JLabel("YOUR CITY "); + + nameLabel0.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel0.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField0 = new JTextField(20); + + nameField0.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel0 = new JPanel(new FlowLayout()); + +//namePanel1.setBackground(color); + + namePanel0.setPreferredSize(new Dimension(500, 40)); + + namePanel0.add(nameLabel0); + + namePanel0.add(nameField0); + + f.add(namePanel0); + + + JLabel nameLabel1 = new JLabel("CO2 EMMITED "); + + nameLabel1.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel1.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField1 = new JTextField(20); + + nameField1.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel1 = new JPanel(new FlowLayout()); + +//namePanel1.setBackground(color); + + namePanel1.setPreferredSize(new Dimension(500, 40)); + + namePanel1.add(nameLabel1); + + namePanel1.add(nameField1); + + f.add(namePanel1); + + + + + + JLabel nameLabel2 = new JLabel("CO EMMITED"); + + nameLabel2.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel2.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField2 = new JTextField(20); + + nameField2.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel2 = new JPanel(new FlowLayout()); + + namePanel2.setPreferredSize(new Dimension(500, 40)); + +//namePanel2.setBackground(color); + + namePanel2.add(nameLabel2); + + namePanel2.add(nameField2); + + f.add(namePanel2); + + + + JLabel nameLabel3 = new JLabel("CH EMMITED"); + + nameLabel3.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel3.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField3 = new JTextField(20); + + nameField3.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel3 = new JPanel(new FlowLayout()); + + namePanel3.setPreferredSize(new Dimension(500, 40)); + +//namePanel3.setBackground(color); + + namePanel3.add(nameLabel3); + + namePanel3.add(nameField3); + + f.add(namePanel3); + + + + JLabel nameLabel4 = new JLabel("HC EMMITED"); + + nameLabel4.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel4.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField4 = new JTextField(20); + + nameField4.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel4 = new JPanel(new FlowLayout()); + + namePanel4.setPreferredSize(new Dimension(500, 40)); + +//namePanel4.setBackground(color); + + namePanel4.add(nameLabel4); + + namePanel4.add(nameField4); + + f.add(namePanel4); + + + + JLabel nameLabel5 = new JLabel("NOX EMMITED"); + + nameLabel5.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel5.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField5 = new JTextField(20); + + nameField5.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel5 = new JPanel(new FlowLayout()); + + namePanel5.setPreferredSize(new Dimension(500, 40)); + +//namePanel5.setBackground(color); + + namePanel5.add(nameLabel5); + + namePanel5.add(nameField5); + + f.add(namePanel5); + + + + JLabel nameLabel6 = new JLabel("SO2 EMMITED"); + + nameLabel6.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel6.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField6 = new JTextField(20); + + nameField6.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel6 = new JPanel(new FlowLayout()); + + namePanel6.setPreferredSize(new Dimension(500, 40)); + +//namePanel6.setBackground(color); + + namePanel6.add(nameLabel6); + + namePanel6.add(nameField6); + + f.add(namePanel6); + + + + JLabel nameLabel7 = new JLabel("PM EMMITED"); + + nameLabel7.setFont(new Font("Arial", Font.PLAIN, 20)); + + nameLabel7.setPreferredSize(new Dimension(150, 30)); + + JTextField nameField7 = new JTextField(20); + + nameField7.setPreferredSize(new Dimension(200, 30)); + + JPanel namePanel7 = new JPanel(new FlowLayout()); + + namePanel7.setPreferredSize(new Dimension(500, 40)); + +//namePanel7.setBackground(color); + + namePanel7.add(nameLabel7); + + namePanel7.add(nameField7); + + + + f.add(namePanel7); + + JButton backButton1 = new JButton("Back"); + + backButton1.setFont(new Font("Arial", Font.PLAIN, 20)); + + backButton1.setPreferredSize(new Dimension(150, 50)); + + backButton1.setBackground(new Color(0, 102, 0)); + + backButton1.setForeground(Color.WHITE); + + JPanel backPanel1 = new JPanel(new FlowLayout()); + + backPanel1.setPreferredSize(new Dimension(800,50)); + +//backPanel1.setBackground(color); + + backPanel1.add(backButton1); + + f.add(backPanel1); + + + + + + JButton submitButton = new JButton("Submit"); + + submitButton.setFont(new Font("Arial", Font.PLAIN, 20)); + + submitButton.setPreferredSize(new Dimension(150, 50)); + + submitButton.setBackground(new Color(0, 102, 0)); + + submitButton.setForeground(Color.WHITE); + + JPanel submitPanel = new JPanel(new FlowLayout()); + + submitPanel.setPreferredSize(new Dimension(800,50)); + +//submitPanel.setBackground(color); + + submitPanel.add(submitButton); + + f.add(submitPanel); + + + + f.setVisible(true); + + + + submitButton.addActionListener(new ActionListener() { + + + + @Override + + public void actionPerformed(ActionEvent e) { + + co2= Integer.valueOf(nameField1.getText()); + + co= Integer.valueOf(nameField2.getText()); + + ch = Integer.valueOf(nameField3.getText()); + + hc= Integer.valueOf(nameField4.getText()); + + nox= Integer.valueOf(nameField5.getText()); + + so2= Integer.valueOf(nameField6.getText()); + + pm= Integer.valueOf(nameField7.getText()); + + + + calculate_footprint2(); + + f.setVisible(false); + + new Main(); + + window(); + + + + } + + }); + + backButton1.addActionListener(new ActionListener() { + + + + @Override + + public void actionPerformed(ActionEvent e) { + + + + f.setVisible(false); + + new Main(); + + + + + + } + + }); + + + + } + + void calculate_footprint2() + + { + + footprint= (ch+ co+ co2+ hc+ nox+ pm+ so2)*8.91*28 /1000; + + ch=(ch/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100; + + } + + static void window() { + + + + + + double carbonfootprint3 = footprint; + + JFrame f = new JFrame("First Page"); + + f.setLayout(null); + + + + JTextArea textArea = new JTextArea("\t\t\t Your Industrial Footprint is "+carbonfootprint3); + + + + + + + + + + textArea.setPreferredSize(new Dimension(800, 50)); + + textArea.setFont(new Font("Arial", Font.BOLD, 20)); + + + + // set the line wrap and word wrap properties of the text area + + textArea.setLineWrap(true); + + textArea.setWrapStyleWord(true); + + + + // make the text area read-only + + textArea.setEditable(false); + + + + // Set the position and size of the JTextArea using absolute positioning + + textArea.setBounds(0, 100, 1200, 70); + + + + // add the text area to the frame + + f.add(textArea); + + + + // set the size of the text area + + f.setSize(1200, 800); + + + + // make the frame visible + + f.pack(); + + // f.setVisible(true); + + + + + + + + // Create values and colors for the pie charts + + List values1 = new ArrayList<>(); + + values1.add((ch/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + values1.add((co/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + values1.add((co2/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + values1.add((hc/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + values1.add((nox/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + values1.add((pm/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + values1.add((so2/(ch+ co+ co2+ hc+ nox+ pm+ so2))*100); + + + + List colors1 = new ArrayList<>(); + + colors1.add(Color.RED); + + colors1.add(Color.GREEN); + + colors1.add(Color.BLUE); + + colors1.add(new Color(128,0, 128)); + + colors1.add(Color.YELLOW); + + colors1.add(new Color(0,128, 128)); + + colors1.add(new Color(255, 165, 0)); + + + + List labels1 = new ArrayList<>(); + + labels1.add("Label 1"); + + labels1.add("Label 2"); + + labels1.add("Label 3"); + + labels1.add("Label 4"); + + labels1.add("Label 5"); + + labels1.add("Label 6"); + + + + + + + + // Create two new pie charts with the values and colors + + PieChart2 chart1 = new PieChart2(values1, colors1,labels1); + + //PieChart chart2 = new PieChart(values2, colors2, labels2); + + + + // Create a new JFrame and add the pie charts to it + + //JFrame f = new JFrame("First Page"); + + f.setVisible(true); + + f.setSize(1200, 800); + + f.setLayout(new BorderLayout()); + + + + // Create a JPanel to hold the pie charts + + JPanel chartsPanel = new JPanel(); + + chartsPanel.setLayout(new GridLayout(1, 2)); // Change to 1 row, 2 columns + + chartsPanel.add(chart1); + + //chartsPanel.add(chart2); + + + + // Add the charts panel to the JFrame + + f.add(chartsPanel, BorderLayout.CENTER); + + + + // Add a title label to the top of the JFrame + + JLabel l1 = new JLabel("INDUSTRIAL LEVEL CARBON FOOTPRINT", JLabel.CENTER); + + l1.setOpaque(true); + + l1.setBackground(new Color(0, 102, 0)); + + l1.setForeground(Color.WHITE); + + l1.setFont(new Font("Arial", Font.BOLD, 30)); + + l1.setPreferredSize(new Dimension(1200, 100)); + + // create a border for the label + + Border border = BorderFactory.createMatteBorder(2, 0, 2, 0, Color.GREEN); + + l1.setBorder(border); + + f.add(l1, BorderLayout.NORTH); + + + + + + + + ImageIcon imageIcon = new ImageIcon("C:\\Users\\swami\\OneDrive\\Desktop\\buffer\\label3.jpg"); + + JLabel imageLabel = new JLabel(); + + imageLabel.setIcon(imageIcon); + + JPanel imagePanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + + imagePanel1.add(imageLabel); + + + + + + JPanel imagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); + + imagePanel.add(imagePanel1); + + //imagePanel.add(imagePanel2); + + + + JPanel mainPanel = new JPanel(new BorderLayout()); + + mainPanel.add(chartsPanel, BorderLayout.CENTER); + + mainPanel.add(imagePanel, BorderLayout.PAGE_END); + + + + f.add(mainPanel, BorderLayout.CENTER); + + + +// JButton backButton2 = new JButton("Back"); + +// backButton2.setFont(new Font("Arial", Font.PLAIN, 20)); + +// backButton2.setPreferredSize(new Dimension(150, 50)); + +// backButton2.setBackground(new Color(0, 102, 0)); + +// backButton2.setForeground(Color.red); + +// // backButton2.setBounds(, 10, 150, 50); + +// JPanel backPanel2 = new JPanel(new FlowLayout()); + +// backPanel2.setPreferredSize(new Dimension(1000,50)); + +// // backPanel2.setBackground(color); + +// backPanel2.add(backButton2); + +// f.add(backButton2); + + f.setVisible(true); + + } + +} + + + +class PieChart2 extends JPanel { + + + + private List values; + + private List colors; + + private List labels; + + + + public PieChart2(List values, List colors, List labels) { + + this.values = values; + + this.colors = colors; + + this.labels = labels; + + } + + + + @Override + + protected void paintComponent(Graphics g) { + + super.paintComponent(g); + + + + double total = 0; + + for (double value : values) { + + total += value; + + } + + + + double currentAngle = 0; + + int x = getWidth() / 2; + + int y = getHeight() / 2; + + int diameter = Math.min(getWidth(), getHeight()) - 200; + + + + for (int i = 0; i < values.size(); i++) { + + double value = values.get(i); + + double angle = 360 * value / total; + + g.setColor(colors.get(i)); + + g.fillArc(x - diameter / 2, y - diameter / 2, diameter, diameter, (int) currentAngle, (int) angle); + + + + // Add label to center of pie slice + + g.setColor(Color.BLACK); + + Font font5 = new Font("Helvetica", Font.PLAIN, 20); + + g.setFont(font5); + + double labelAngle = currentAngle + angle / 2; + + int labelX = (int) (x + (diameter / 2 * Math.cos(Math.toRadians(labelAngle)))); + + int labelY = (int) (y + (diameter / 2 * Math.sin(Math.toRadians(labelAngle)))); + + String label = String.format("%.1f%%", value); + + g.drawString(label, labelX, labelY); + + currentAngle += angle; + + } + + } + + + + public JPanel createLabelsPanel() { + + JPanel labelsPanel = new JPanel(new GridLayout(values.size(), 2)); + + for (int i = 0; i < values.size(); i++) { + + JLabel colorLabel = new JLabel(" "); + + colorLabel.setOpaque(true); + + colorLabel.setBackground(colors.get(i)); + + labelsPanel.add(colorLabel); + + JTextField valueTextField = new JTextField(String.format("%.1f%%", values.get(i))); + + valueTextField.setEditable(false); + + labelsPanel.add(valueTextField); + + JLabel labelLabel = new JLabel(labels.get(i)); + + labelsPanel.add(labelLabel); + + JTextField labelTextField = new JTextField(labels.get(i)); + + labelTextField.setEditable(false); + + labelsPanel.add(labelTextField); + + } + + return labelsPanel; + + } + +} + +public class Industry { + + + + public static void main(String[] args) { + +// TODO Auto-generated method stub + + individual ob2 = new individual(); + + ob2.accept(); + + } + +} \ No newline at end of file diff --git a/Footprint/Main.java b/Footprint/Main.java new file mode 100644 index 0000000..a298f77 --- /dev/null +++ b/Footprint/Main.java @@ -0,0 +1,258 @@ +package footprint; + +import java.util.*; + +import javax.swing.*; +import java.awt.*; +import javax.swing.border.Border; +import javax.swing.event.AncestorListener; +import javax.swing.SwingConstants; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +public class Main extends JFrame implements ActionListener { + JButton button1; + JButton button2; + JButton button3; + JButton button4; + JFrame f; + public static String which_button = ""; + + + public Main() { + + f = new JFrame("First Page"); + //f.setVisible(true); + f.setSize(1200, 800); + f.setLayout(new FlowLayout()); + + JLabel l1 = new JLabel("WELCOME TO CARBON FOOTPRINT", JLabel.CENTER); + l1.setOpaque(true); + l1.setBackground(new Color(0, 102, 0)); + l1.setForeground(Color.WHITE); + l1.setFont(new Font("Arial", Font.BOLD, 30)); + l1.setPreferredSize(new Dimension(1200, 100)); + + // create a border for the label + Border border = BorderFactory.createMatteBorder(2, 0, 2, 0, Color.GREEN); + l1.setBorder(border); + f.add(l1); + + + JTextArea textArea = new JTextArea(" Carbon footprint is a measure of the amount of greenhouse gases, primarily carbon dioxide, released into the atmosphere as a result of human activities, such as driving a car, using electricity, and producing goods and services.\n\n" + + " The importance of carbon footprint is multifaceted and includes the following:\n" + + " - Raising awareness about environmental issues\n" + + " - Encouraging individuals and organizations to reduce their greenhouse gas emissions\n" + + " - Helping governments to develop and implement policies to address climate change\n"); + + + // set the size of the text area + textArea.setPreferredSize(new Dimension(1200, 200)); + textArea.setFont(new Font("Arial", Font.BOLD, 15)); + + // set the line wrap and word wrap properties of the text area + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + + // make the text area read-only + textArea.setEditable(false); + + // add the text area to the frame + f.add(textArea); + + + + + JTextArea textArea2 = new JTextArea("Climate Change Mitigation: " + + "The release of greenhouse gases, particularly carbon dioxide, " + + "is a major driver of climate change. " + + "Carbon footprint is a key metric that helps individuals and organizations to " + + "understand their contribution to climate change and take action to reduce their emissions. " + + "By measuring and reducing our carbon footprint, we can help mitigate " + + "the effects of climate change."); + textArea2.setPreferredSize(new Dimension(250, 200)); + textArea2.setLineWrap(true); + textArea2.setWrapStyleWord(true); + textArea2.setEditable(false); + + // set the font and justification + Font font = new Font("Helvetica", Font.PLAIN, 12); + textArea2.setFont(font); + textArea2.setMargin(new Insets(10,10,10,10)); // Add some margin for readability + textArea2.setOpaque(false); // Make the background transparent + textArea2.setForeground(Color.BLACK); + f.add(textArea2); + + + JTextArea textArea3 = new JTextArea("Environmental Stewardship: " + + "The earth's resources are finite, and we must be good stewards of them. " + + "By reducing our carbon footprint, we can reduce our impact on the " + + "environment and help preserve the planet for future generations."); + textArea3.setPreferredSize(new Dimension(250, 200)); + textArea3.setLineWrap(true); + textArea3.setWrapStyleWord(true); + textArea3.setEditable(false); + + // set the font and justification + Font font3 = new Font("Helvetica", Font.PLAIN, 12); + textArea3.setFont(font); + textArea3.setMargin(new Insets(10,10,10,10)); // Add some margin for readability + textArea3.setOpaque(false); // Make the background transparent + textArea3.setForeground(Color.BLACK); + f.add(textArea3); + + JTextArea textArea4 = new JTextArea("Economic Benefits: " + + "Reducing our carbon footprint can have significant economic benefits, " + + "such as lowering energy costs, increasing efficiency, and creating new jobs " + + "in the clean energy sector. By transitioning to a low-carbon economy, " + + "we can also reduce our dependence on fossil fuels and increase our energy security."); + textArea4.setPreferredSize(new Dimension(250, 200)); + textArea4.setLineWrap(true); + textArea4.setWrapStyleWord(true); + textArea4.setEditable(false); + + // set the font and justification + Font font4 = new Font("Helvetica", Font.PLAIN, 12); + textArea4.setFont(font); + textArea4.setMargin(new Insets(10,10,10,10)); // Add some margin for readability + textArea4.setOpaque(false); // Make the background transparent + textArea4.setForeground(Color.BLACK); // Set the text color + f.add(textArea4); + + + JTextArea textArea5 = new JTextArea("Social Responsibility:" + + "As individuals and organizations, we have a responsibility " + + "to contribute to the greater good. By reducing our carbon footprint, " + + "we can help create a more sustainable and equitable future for all."); + + textArea5.setPreferredSize(new Dimension(250, 200)); + textArea5.setLineWrap(true); + textArea5.setWrapStyleWord(true); + textArea5.setEditable(false); + + // set the font and justification + Font font5 = new Font("Helvetica", Font.PLAIN, 12); + textArea5.setFont(font); + textArea5.setMargin(new Insets(10,10,10,10)); // Add some margin for readability + textArea5.setOpaque(false); // Make the background transparent + textArea5.setForeground(Color.BLACK); + f.add(textArea5); + + + + ImageIcon img1 = new ImageIcon("C:\\Users\\swami\\OneDrive\\Documents\\HTML\\buffer\\buffer\\src\\buffer\\individual_carbon.jpeg"); + JLabel imageLabel = new JLabel(img1); + imageLabel.setBounds(0,0, 200, 200); // Set the position and size + f.add(imageLabel); + + ImageIcon img2 = new ImageIcon("C:\\Users\\swami\\OneDrive\\Documents\\HTML\\buffer\\buffer\\src\\buffer\\industry.jpg"); + Image image = img1.getImage(); + int width = image.getWidth(null); + int height = image.getHeight(null); + + + Image scaledImage = img2.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT); + img2.setImage(scaledImage); + JLabel imageLabel2 = new JLabel(img2); + imageLabel2.setBounds(0, 0, width, height); + f.add(imageLabel2); + + + ImageIcon img3 = new ImageIcon("C:\\Users\\swami\\OneDrive\\Documents\\HTML\\buffer\\buffer\\src\\buffer\\reduce1.jpg"); + JLabel imageLabel3 = new JLabel(img3); + Image scaledImage3 = img3.getImage().getScaledInstance(img1.getIconWidth(), img1.getIconHeight(), Image.SCALE_DEFAULT); + img3.setImage(scaledImage3); + imageLabel3.setBounds(0, 0, img1.getIconWidth(), img1.getIconHeight()); + f.add(imageLabel3); + + + + ImageIcon img4 = new ImageIcon("C:\\Users\\swami\\OneDrive\\Documents\\HTML\\buffer\\buffer\\src\\buffer\\region.jpg"); + JLabel imageLabel4 = new JLabel(img4); + Image scaledImage4 = img4.getImage().getScaledInstance(img1.getIconWidth(), img1.getIconHeight(), Image.SCALE_DEFAULT); + img4.setImage(scaledImage4); + imageLabel4.setBounds(0, 0, img1.getIconWidth(), img1.getIconHeight()); + f.add(imageLabel4); + + + + // Create a button + button1 = new JButton("INDIVIDUAL FOOTPRINT"); + button1.setBackground(new Color(0, 102, 0)); + button1.setForeground(Color.WHITE); + button1.setFont(new Font("Arial", Font.BOLD, 12)); + int buttonX = imageLabel.getX(); + int buttonY = imageLabel.getY() + imageLabel.getHeight(); + button1.setBounds(buttonX, buttonY, imageLabel.getWidth(), 30); // Set the position and size of the button + f.add(button1); + button1.addActionListener(this); + + + button2 = new JButton("INDUSTRIAL FOOTPRINT"); + button2.setBackground(new Color(0, 102, 0)); + button2.setForeground(Color.WHITE); + button2.setFont(new Font("Arial", Font.BOLD, 12)); + button2.setBounds(100, 600, 200, 30); + f.add(button2); + button2.addActionListener(this); + + button3 = new JButton("REDUCTION METHODS"); + button3.setBackground(new Color(0, 102, 0)); + button3.setForeground(Color.WHITE); + button3.setFont(new Font("Arial", Font.BOLD, 12)); + button3.setBounds(1000, 600, 200, 30); + f.add(button3); + button3.addActionListener(this); + + button4 = new JButton("REGIONWISE DISTRIBUTION"); + button4.setBackground(new Color(0, 102, 0)); + button4.setForeground(Color.WHITE); + button4.setFont(new Font("Arial", Font.BOLD, 12)); + button4.setBounds(1500, 600, 200, 30); + f.add(button4); + button4.addActionListener(this); + f.setVisible(true); + + + } + + public void actionPerformed(ActionEvent e) + { + if(e.getSource()==button1) + { + new Indi().accept(); + which_button = "Individual"; + //new Main(); + this.f.setVisible(false); + } + if(e.getSource()==button2) + { + individual ob2 = new individual(); + ob2.accept(); + which_button = "Industry"; + //new Main(); + this.f.setVisible(false); + } + if(e.getSource()==button3) + { + new solution(); + this.f.setVisible(false); + } + + if(e.getSource()==button4) + { + Maps1.window(); + this.f.setVisible(false); + } + } + + public static void main(String[] args) { + Main ob2 = new Main(); + //ob2.first_page(); + + + + } + +} diff --git a/Footprint/Maps1.java b/Footprint/Maps1.java new file mode 100644 index 0000000..8365b9a --- /dev/null +++ b/Footprint/Maps1.java @@ -0,0 +1,158 @@ +package footprint; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.util.HashMap; +import java.util.Map; +import javax.swing.border.Border; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +public class Maps1 extends JPanel { + + private Map data; + + public Maps1(Map data) { + this.data = data; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + int width = getWidth(); + int height = getHeight(); + + // Draw x and y axis + g.setColor(Color.BLACK); + g.drawLine(50, height - 50, width - 50, height - 50); + g.drawLine(50, height - 50, 50, 50); + + // Calculate maximum value for scaling + double maxValue = 0; + for (double value : data.values()) { + if (value > maxValue) { + maxValue = value; + } + } + int scale = (int) Math.ceil(maxValue / 10.0) * 10; + + // Draw y axis labels + g.setFont(new Font("Arial", Font.PLAIN, 12)); + for (int i = 0; i <= scale; i += scale / 10) { + int label = i; + int y = height - 50 - (i * (height - 100) / scale); + g.drawString(String.valueOf(label), 25, y + 5); + g.drawLine(45, y, 50, y); + } + + // Draw x axis labels + int barWidth = (width - 100) / data.size(); + int x = 75; + for (String state : data.keySet()) { + g.drawString(state, x, height - 30); + x += barWidth; + } + + // Draw bars + x = 75; + for (String state : data.keySet()) { + double value = data.get(state); + int barHeight = (int) Math.round((value * 1.0 / scale) * (height - 100)); + g.setColor(new Color(70, 130, 180)); + g.fillRect(x, height - 50 - barHeight, barWidth, barHeight); + g.setColor(Color.BLACK); + g.drawRect(x, height - 50 - barHeight, barWidth, barHeight); + x += barWidth; + } + + } + + static void window() { +// Create data for the bar graph + JFrame f = new JFrame("First Page"); + f.setSize(1200, 800); + f.setLayout(new FlowLayout()); + + JLabel l1 = new JLabel("REGIONWISE CARBON FOOTPRINT", JLabel.CENTER); + l1.setOpaque(true); + l1.setBackground(new Color(0, 102, 0)); + l1.setForeground(Color.WHITE); + l1.setFont(new Font("Arial", Font.BOLD, 30)); + l1.setPreferredSize(new Dimension(1200, 100)); + +// create a border for the label + Border border = BorderFactory.createMatteBorder(2, 0, 2, 0, Color.GREEN); + l1.setBorder(border); + f.add(l1); + +// Add the title label to the chart panel +//chartPanel.add(titleLabel, BorderLayout.NORTH); + +// Create a new StateWisePollutionDistribution object with the data + Map data = new HashMap<>(); + data.put("1", 3.188); + data.put("2", 1.439); + data.put("3", 5.342); + data.put("4", 4.662); + data.put("5", 5.749); + data.put("6", 2.811); + data.put("7", 3.068); + data.put("8", 2.197); + data.put("9", 4.7148); + data.put("10", 8.222); + data.put("11", 0.635); + data.put("12", 1.171); + data.put("13", 8.970); + data.put("14", 1.684); + data.put("15", 2.914); + data.put("16", 2.0416); + data.put("17", 3.799); + data.put("18", 1.3773); + data.put("19 ", 1.299); + data.put("20", 0.970); + Maps1 chart = new Maps1(data); + +//f.add(chartPanel); + +// Create a JPanel to hold the chart + JPanel chartPanel = new JPanel(new BorderLayout()); + +// Add the chart to the chart panel + chartPanel.add(chart, BorderLayout.CENTER); + +// Load the image and create a label for it + ImageIcon img1 = new ImageIcon("m1.png"); + JLabel imageLabel = new JLabel(img1); + +// Create a JPanel to hold both the chart panel and the image label + JPanel mainPanel = new JPanel(new GridLayout(1, 2)); + mainPanel.add(chartPanel); + mainPanel.add(imageLabel); + + + f.getContentPane().add(mainPanel); + imageLabel.setBounds(800, 100, 400, 400); + + f.setVisible(true); + + + } + + + + public static void main(String[] args) { + window(); + + + } +} diff --git a/Footprint/README b/Footprint/README new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Footprint/README @@ -0,0 +1 @@ + diff --git a/Footprint/Reduce.java b/Footprint/Reduce.java new file mode 100644 index 0000000..b98d56b --- /dev/null +++ b/Footprint/Reduce.java @@ -0,0 +1,60 @@ +package footprint; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +class solution extends JFrame implements ActionListener { + JFrame f; + public solution() { + f = new JFrame("First Page"); + f.setVisible(true); + f.setSize(1200, 800); + f.setLayout(new FlowLayout()); + + JLabel l1 = new JLabel("REDUCE YOUR CARBON FOOTPRINT", JLabel.CENTER); + l1.setOpaque(true); + l1.setBackground(new Color(0, 150, 0)); + l1.setForeground(Color.WHITE); + l1.setFont(new Font("Arial", Font.BOLD, 30)); + l1.setPreferredSize(new Dimension(1200, 100)); + + Border border = BorderFactory.createMatteBorder(2, 2, 5, 2, Color.GREEN); + l1.setBorder(border); + f.add(l1); + String s=""; + if(Main.which_button.equals("Individual")){ + s = Tree.create("INDIVIDUAL FOOTPRINT",Indi.basic_footprint); + } + else if(Main.which_button.equals("Industrial")){ + s = Tree.create("INDUSTRIAL FOOTPRINT",individual.footprint); + } +// Individual obj1 = new Individual(); + else { + s = Tree.region; + } + + JLabel label = new JLabel(s); + f.getContentPane().add(label); + f.pack(); + f.setVisible(true); + + JTextArea textArea = new JTextArea(s); + f.add(textArea); + f.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + f.setVisible(true); + } +} +public class Reduce { + public static void main(String[] args) { + new solution(); + // obj.method(); + + } +} diff --git a/Footprint/Tree.java b/Footprint/Tree.java new file mode 100644 index 0000000..14d0f14 --- /dev/null +++ b/Footprint/Tree.java @@ -0,0 +1,423 @@ +package footprint; + +class Node{ + + String text; + + Node one; + + Node two; + + Node three; + + + + public Node(String text){ + + this.text = text; + + this.one = null; + + this.two = null; + + this.three = null; + + } + +} + +public class Tree{ + static String region=" Reduce energy consumption: Use energy-efficient appliances, turn off lights and electronics when you're not using them, and adjust your thermostat to use less energy.\n" + + + "\n" + + + " Choose sustainable transportation: Use public transport, walk, bike or carpool instead of driving alone.\n" + + + "\n" + + + " Reduce waste: Recycle, compost, and reduce your use of single-use plastics.\n" + + + "\n" + + + " Eat a plant-based diet: Reduce your meat consumption, eat more plant-based foods, and support local and sustainable agriculture.\n" + + + "\n" + + + " Use renewable energy: Install solar panels or use renewable energy providers.\n" + + + "\n" + + + " Buy carbon offsets: Support projects that reduce carbon emissions, such as renewable energy projects or reforestation efforts.\n" + + + "\n" + + + " Educate yourself and others: Learn more about climate change and encourage others to make environmentally conscious choices."; + + + + public static String create(String who, double footprint){ + + String target = ""; + + + + + + String Individual="1. Hang out the washing instead of tumble drying \n" + + + "Hanging the washing out instead of using the tumble drier will save about 153kg CO2 a year - that's £52 (USD68) each year, based on 150 cycles a year. \n" + + + "\n" + + + "2. Turn down the heating by 1⁰C\n" + + + "Reducing your heating by 1⁰C can reduce your energy consumption by 8%. For an average household gas bill of 12,500kWh this will reduce your CO2 emissions by 184kg - that's £42 (USD55) each year.\n" + + + "\n" + + + "3. Only fill the kettle with the amount of water you need to boil\n" + + + "Only boiling the amount of water for your hot drink will save 72kg CO2 a year - that's £23 (USD30) per annum\n" + + + "\n" + + + "4. Spend less time in the shower\n" + + + "Spending 1 minute less in the shower can save 23kg CO2 and £8 (USD10) a year (based on one shower a day and a 9kW shower).\n" + + + "\n" + + + "5. Turn electrical equipment off when not in use \n" + + + "Fully turning off just one LCD TV (rather than leaving it on standby) for 18 hours a day will save about 5kg CO2 a year - saving £2 a year (USD2.64). Turn off all other electrical equipment when not in use to multiply the savings."; + + + + String Industry_low="If a company's carbon footprint is already low, there are several steps it can take to further reduce its carbon emissions and environmental impact:\n" + + + "\n" + + + "Set ambitious targets: The company can set aggressive, science-based targets to reduce its carbon footprint even further. These targets can be based on the latest climate science and can be aligned with the goals of the Paris Agreement.\n" + + + "\n" + + + "Invest in renewable energy: The company can invest in renewable energy sources like solar and wind power. By generating their own renewable energy, the company can reduce its dependence on fossil fuels and lower its carbon emissions.\n" + + + "\n" + + + "Improve energy efficiency: The company can adopt energy-efficient practices and technologies to reduce energy consumption. This can include upgrading to more efficient lighting, heating, and cooling systems, optimizing processes, and using energy-saving equipment.\n" + + + "\n" + + + "Reduce waste: The company can work to reduce waste and increase recycling. This can include implementing a waste reduction and recycling program, using reusable packaging, and minimizing unnecessary packaging.\n" + + + "\n" + + + "Encourage sustainable practices among employees and suppliers: The company can encourage sustainable practices among its employees and suppliers. This can include promoting the use of public transportation, telecommuting, and encouraging the use of environmentally friendly products.\n" + + + "\n" + + + "Collaborate with other companies and organizations: The company can collaborate with other companies and organizations to share best practices, develop new technologies, and advocate for policies that support sustainability.\n" + + + "\n" + + + "Overall, reducing a company's carbon footprint requires a comprehensive approach that involves setting ambitious goals, investing in renewable energy, improving energy efficiency, reducing waste, promoting sustainable practices among employees and suppliers, and collaborating with other companies and organizations."; + + String Industry_med="There are several steps that a medium-sized industry can take to reduce its carbon footprint:\n" + + + "\n" + + + "Conduct an energy audit: Conduct an energy audit to identify areas where energy is being wasted and to identify opportunities to reduce energy use. This will help the company understand how much energy they are consuming and which areas they need to focus on to improve efficiency.\n" + + + "\n" + + + "Implement energy efficiency measures: Implement measures to improve energy efficiency, such as upgrading equipment to more efficient models, installing LED lighting, and improving insulation.\n" + + + "\n" + + + "Switch to renewable energy: Switching to renewable energy sources like solar or wind power can significantly reduce carbon emissions. Companies can consider installing solar panels on their premises or purchasing renewable energy from a supplier.\n" + + + "\n" + + + "Reduce transportation emissions: Encouraging employees to carpool, use public transportation, or work remotely can reduce transportation emissions. The company can also consider switching to electric or hybrid vehicles for their fleet.\n" + + + "\n" + + + "Reduce waste: Reducing waste and increasing recycling can also reduce a company's carbon footprint. This can be achieved by implementing a waste management plan, reducing packaging, and encouraging the reuse of materials.\n" + + + "\n" + + + "Engage stakeholders: Engaging stakeholders such as suppliers, customers, and employees in sustainability efforts can create a culture of sustainability within the company and encourage others to reduce their carbon footprint.\n" + + + "\n" + + + "By implementing these steps, a medium-sized industry can significantly reduce its carbon footprint and contribute to the fight against climate change."; + + String Industry_high="Reducing a company's carbon footprint can be a complex task that requires a comprehensive and systematic approach. Here are some steps that an industry can take to reduce its carbon footprint:\n" + + + "\n" + + + "Conduct a carbon footprint assessment: Before taking any steps, it is important to understand the company's current carbon emissions and identify areas where emissions can be reduced. This will help to set a baseline and establish goals for reducing the carbon footprint.\n" + + + "\n" + + + "Increase energy efficiency: Industries can reduce their carbon footprint by improving energy efficiency. This can be achieved by upgrading equipment and technology, improving insulation, and optimizing processes to reduce energy consumption.\n" + + + "\n" + + + "Switch to renewable energy: Industries can reduce their carbon footprint by switching to renewable energy sources such as wind, solar, hydro, or geothermal. This can be achieved by installing on-site renewable energy systems or purchasing renewable energy from third-party providers.\n" + + + "\n" + + + "Implement green transportation policies: Industries can reduce their carbon footprint by implementing green transportation policies such as encouraging employees to use public transport, cycling, or carpooling. The industry can also consider using electric or hybrid vehicles in their fleet.\n" + + + "\n" + + + "Reduce waste: Industries can reduce their carbon footprint by implementing waste reduction strategies such as reducing packaging, reusing materials, and recycling. They can also explore circular economy models to minimize waste generation.\n" + + + "\n" + + + "Engage suppliers: Industries can reduce their carbon footprint by engaging their suppliers to adopt sustainable practices. They can set sustainability requirements in their procurement policies and work with suppliers to reduce carbon emissions throughout the supply chain.\n" + + + "\n" + + + "Educate employees and stakeholders: Industries can reduce their carbon footprint by educating their employees and stakeholders on sustainability and the importance of reducing carbon emissions. This can lead to a culture of sustainability that drives ongoing improvements.\n" + + + "\n" + + + "Overall, reducing a company's carbon footprint requires a long-term commitment and a willingness to adopt sustainable practices throughout the organization."; + + String Industry="Switching from lower efficiency T12 and T8 lamps to higher efficiency T5 or even better, " + + + "LED lamps will reduce energy consumption and can lead to economic savings.Heat can easily be lost through " + + + "poorly insulated windows.\nDouble glazing can reduce heat loss by 50% compared to single glazing with Low E Glass " + + + "double glazing and triple glazing reducing this loss further. When replacing windows consider those with the" + + + " lowest U-values as these will reduce heat loss the greatest.\nA Building Management System (BMS) or Building Energy Management" + + + " System (BEMS) can be used to control heating, lighting and ventilation to the optimum conditions. Having a BMS/BEMS that" + + + " can be controlled internally gives greater control over energy usage. Identifying a member of staff who is in control of " + + + "the thermostat avoids frequent changes in temperature. Increasing the thermostat by 1 degree Celsius can increase costs by 8%."; + + String Individual_low="If you have a low carbon footprint, that's great! It means you're already making conscious choices to reduce your impact on the environment. Here are some additional steps you can take to further reduce your carbon footprint:\n" + + + "\n" + + + "Reduce your energy consumption even further: Consider using LED light bulbs, turning off power strips when not in use, and upgrading to energy-efficient appliances if you haven't already.\n" + + + "\n" + + + "Encourage others: Share your sustainable practices with friends and family, and encourage them to make changes in their own lives.\n" + + + "\n" + + + "Support sustainable businesses: Look for businesses that prioritize sustainability in their practices and choose to support them.\n" + + + "\n" + + + "Invest in carbon offsets: Even if your carbon footprint is low, investing in carbon offsets can support projects that reduce carbon emissions and help offset any remaining emissions you may have.\n" + + + "\n" + + + "Eat a plant-based diet: If you're not already eating a plant-based diet, consider incorporating more plant-based meals into your diet to further reduce your carbon footprint.\n" + + + "\n" + + + "Use public transport or bike more often: If you have access to public transport, consider using it more often, or if possible, biking to your destinations instead of driving.\n" + + + "\n" + + + "By taking these additional steps, you can further reduce your carbon footprint and continue to make a positive impact on the environment." ; + + String Individual_med="Reducing your carbon footprint is an important step towards mitigating the effects of climate change. Here are some steps you can take to reduce your carbon footprint if it is medium:\n" + + + "\n" + + + "Reduce energy consumption: Turn off lights and appliances when they're not in use, use energy-efficient light bulbs, and consider using a programmable thermostat to regulate the temperature of your home.\n" + + + "\n" + + + "Reduce water usage: Fix any leaks, take shorter showers, and consider installing low-flow showerheads and toilets.\n" + + + "\n" + + + "Reduce transportation emissions: Walk, bike, carpool or use public transportation instead of driving alone, and consider purchasing a hybrid or electric vehicle.\n" + + + "\n" + + + "Reduce waste: Recycle, compost, and reduce your overall consumption of single-use plastics and packaging.\n" + + + "\n" + + + "Eat a more plant-based diet: Eating less meat and dairy can reduce your carbon footprint, as the production of animal products generates significant greenhouse gas emissions.\n" + + + "\n" + + + "Support renewable energy: Consider installing solar panels on your home, or supporting renewable energy projects through investments or advocacy.\n" + + + "\n" + + + "Reduce air travel: Air travel generates significant carbon emissions, so try to limit the number of flights you take, and consider offsetting your emissions through carbon offsets or investing in projects that reduce emissions.\n" + + + "\n" + + + "By taking these steps, you can significantly reduce your carbon footprint and contribute to the fight against climate change."; + + String Individual_high="Reducing your carbon footprint is an important step in mitigating climate change. Here are some steps you can take to reduce your carbon footprint if it is critically high:\n" + + + "\n" + + + "Reduce energy use: Turn off appliances and lights when you are not using them, and replace incandescent light bulbs with LEDs. Set your thermostat to a lower temperature in winter and a higher temperature in summer.\n" + + + "\n" + + + "Use renewable energy sources: Install solar panels or use wind power to generate electricity. Many electricity providers now offer renewable energy options, so check with your provider.\n" + + + "\n" + + + "Reduce water usage: Fix any leaks in your home and install water-efficient showerheads and toilets. Use drought-tolerant landscaping in your yard.\n" + + + "\n" + + + "Reduce waste: Reduce, reuse, and recycle. Buy products with less packaging, and recycle everything you can. Compost food waste and yard waste.\n" + + + "\n" + + + "Eat a plant-based diet: Meat production is a major contributor to greenhouse gas emissions. Eating a plant-based diet or reducing meat consumption can significantly reduce your carbon footprint.\n" + + + "\n" + + + "Reduce transportation emissions: Use public transportation, carpool, or bike instead of driving alone. Consider purchasing an electric or hybrid vehicle if you need a car.\n" + + + "\n" + + + "Support climate-friendly policies: Vote for politicians who support climate-friendly policies and advocate for policies that reduce carbon emissions.\n" + + + "\n" + + + "These are just a few steps you can take to reduce your carbon footprint. By making changes in your daily life and supporting climate-friendly policies, you can help mitigate the impacts of climate change."; + + + + String solution = "Carbon offsetting funds solutions to reducing carbon emissions now. Frequently carbon offsetting" + + + " reduces emissions much faster than you can as an individual/single company. Carbon offsetting projects help" + + + " to combat global climate change as well as caring for local communities. In many instances providing" + + + " much needed employment, health improvement, biodiversity, reforestation and broad social benefits to impoverished" + + + " communities." + "\nTips and Advice to help you cut carbon and energy costs"; + + + + Node root = new Node(solution); + + + + Node ptr = root; + + root.one = new Node(region); + + ptr = root.one; + + ptr.one = new Node(Individual); + + ptr.two = new Node(Industry); + + Node ptr1 = ptr; + + ptr1=ptr.two; + + ptr = ptr.one; + + ptr.one = new Node(Individual_low); + + ptr.two = new Node(Individual_med); + + ptr.three = new Node(Individual_high); + + + + ptr1.one = new Node(Industry_low); + + ptr1.two = new Node(Industry_med); + + ptr1.three = new Node(Industry_high); + + Indi obj5 = new Indi(); + + + + Node pointer1 = root.one; + + if(who.equals("INDIVIDUAL FOOTPRINT")){ + + pointer1=pointer1.one; + + + + if(footprint<0.02){ + + target = pointer1.text + pointer1.one.text; + + } else if (footprint>=0.02 && footprint<0.5 ) { + + target = pointer1.text + pointer1.two.text; + + } + + else target = pointer1.text + pointer1.three.text; + + } + + + + else if (who.equals("INDUSTRIAL FOOTPRINT")){ + + pointer1 = root.two; + + if(footprint<0.02){ + + target = pointer1.text + pointer1.one.text; + + } else if (footprint>=0.02 && footprint<0.5 ) { + + target = pointer1.text + pointer1.two.text; + + } + + else target = pointer1.text + pointer1.three.text; + + } + + return target; + + } + + + +} + + + +//public class Tree{ + +// public static void main(String[] args) { + +// Tree2 obj = new Tree2(); + +// Indi obj1 = new Indi(); + +// String s = obj.create("INDIVIDUAL FOOTPRINT",obj1.calculate_footprint()); + +// //System.out.println(s); + +// } + +//} + diff --git a/Footprint/User1.java b/Footprint/User1.java new file mode 100644 index 0000000..089c4fe --- /dev/null +++ b/Footprint/User1.java @@ -0,0 +1,466 @@ +package footprint; + + +import java.util.*; +import java.awt.EventQueue; +import java.awt.FlowLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; + +import javax.swing.JLabel; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.SwingConstants; +import javax.swing.JTextField; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +class Indi { + double carbonfootprint1 = 0; + double carbonfootprint2 = 0; + +static double electricity=0; +static double heating_oil=0; +static double coal = 0; +static double lpg = 0; +static double propane = 0; +static double natural_gas = 0; + +static double distance_car = 0; +static double milage_car = 0; + +static double distance_2 = 0; +static double milage_2 = 0; + +static double basic_footprint = 0; +static double from_car = 0; +static double from_2 = 0; + +public double footprint_page=0; +JFrame f = new JFrame("First Page"); +void accept() { + +f.setSize(1200, 800); +f.setLayout(new FlowLayout()); + +JLabel l1 = new JLabel("INDIVIDUAL FOOTPRINT", JLabel.CENTER); +l1.setOpaque(true); +l1.setBackground(new Color(0, 102, 0)); +l1.setForeground(Color.WHITE); +l1.setFont(new Font("Arial", Font.BOLD, 30)); +l1.setPreferredSize(new Dimension(1200, 100)); + +// create a border for the label +Border border = BorderFactory.createMatteBorder(2, 0, 2, 0, Color.GREEN); +l1.setBorder(border); +f.add(l1); + + +JLabel nameLabel1 = new JLabel("Electricity Bill: "); +nameLabel1.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel1.setPreferredSize(new Dimension(150, 30)); +JTextField nameField1 = new JTextField(20); +nameField1.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel1 = new JPanel(new FlowLayout()); +namePanel1.setPreferredSize(new Dimension(500, 40)); +namePanel1.add(nameLabel1); +namePanel1.add(nameField1); +f.add(namePanel1); + +JLabel nameLabel2 = new JLabel("Heating Oil: "); +nameLabel2.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel2.setPreferredSize(new Dimension(150, 30)); +JTextField nameField2 = new JTextField(20); +nameField2.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel2 = new JPanel(new FlowLayout()); +namePanel2.setPreferredSize(new Dimension(500, 40)); +namePanel2.add(nameLabel2); +namePanel2.add(nameField2); +f.add(namePanel2); + +JLabel nameLabel3 = new JLabel("Coal: "); +nameLabel3.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel3.setPreferredSize(new Dimension(150, 30)); +JTextField nameField3 = new JTextField(20); +nameField3.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel3 = new JPanel(new FlowLayout()); +namePanel3.setPreferredSize(new Dimension(500, 40)); +namePanel3.add(nameLabel3); +namePanel3.add(nameField3); +f.add(namePanel3); + +JLabel nameLabel4 = new JLabel("LPG: "); +nameLabel4.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel4.setPreferredSize(new Dimension(150, 30)); +JTextField nameField4 = new JTextField(20); +nameField4.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel4 = new JPanel(new FlowLayout()); +namePanel4.setPreferredSize(new Dimension(500, 40)); +namePanel4.add(nameLabel4); +namePanel4.add(nameField4); +f.add(namePanel4); + +JLabel nameLabel5 = new JLabel("Propane: "); +nameLabel5.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel5.setPreferredSize(new Dimension(150, 30)); +JTextField nameField5 = new JTextField(20); +nameField5.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel5 = new JPanel(new FlowLayout()); +namePanel5.setPreferredSize(new Dimension(500, 40)); +namePanel5.add(nameLabel5); +namePanel5.add(nameField5); +f.add(namePanel5); + +JLabel nameLabel6 = new JLabel("Natural Gas: "); +nameLabel6.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel6.setPreferredSize(new Dimension(150, 30)); +JTextField nameField6 = new JTextField(20); +nameField6.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel6 = new JPanel(new FlowLayout()); +namePanel6.setPreferredSize(new Dimension(500, 40)); +namePanel6.add(nameLabel6); +namePanel6.add(nameField6); +f.add(namePanel6); + +JLabel nameLabel7 = new JLabel("Distance (Car): "); +nameLabel7.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel7.setPreferredSize(new Dimension(150, 30)); +JTextField nameField7 = new JTextField(20); +nameField7.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel7 = new JPanel(new FlowLayout()); +namePanel7.setPreferredSize(new Dimension(500, 40)); +namePanel7.add(nameLabel7); +namePanel7.add(nameField7); +f.add(namePanel7); + +JLabel nameLabel8 = new JLabel("Mileage (Car): "); +nameLabel8.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel8.setPreferredSize(new Dimension(150, 30)); +JTextField nameField8 = new JTextField(20); +nameField8.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel8 = new JPanel(new FlowLayout()); +namePanel8.setPreferredSize(new Dimension(500, 40)); +namePanel8.add(nameLabel8); +namePanel8.add(nameField8); +f.add(namePanel8); + +JLabel nameLabel9 = new JLabel("Distance bike: "); +nameLabel9.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel9.setPreferredSize(new Dimension(150, 30)); +JTextField nameField9 = new JTextField(20); +nameField9.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel9 = new JPanel(new FlowLayout()); +namePanel9.setPreferredSize(new Dimension(500, 40)); +namePanel9.add(nameLabel9); +namePanel9.add(nameField9); +f.add(namePanel9); + +JLabel nameLabel10 = new JLabel("Mileage bike: "); +nameLabel10.setFont(new Font("Arial", Font.PLAIN, 20)); +nameLabel10.setPreferredSize(new Dimension(150, 30)); +JTextField nameField10 = new JTextField(20); +nameField10.setPreferredSize(new Dimension(200, 30)); +JPanel namePanel10 = new JPanel(new FlowLayout()); +namePanel10.setPreferredSize(new Dimension(500, 40)); +namePanel10.add(nameLabel10); +namePanel10.add(nameField10); +f.add(namePanel10); + + +JButton backButton1 = new JButton("Back"); +backButton1.setFont(new Font("Arial", Font.PLAIN, 20)); +backButton1.setPreferredSize(new Dimension(150, 50)); +backButton1.setBackground(new Color(0, 102, 0)); +backButton1.setForeground(Color.red); +JPanel backPanel1 = new JPanel(new FlowLayout()); +backPanel1.setPreferredSize(new Dimension(600,50)); +backPanel1.add(backButton1); +f.add(backPanel1); + + +JButton submitButton = new JButton("Submit"); +submitButton.setFont(new Font("Arial", Font.PLAIN, 20)); +submitButton.setPreferredSize(new Dimension(150, 50)); +submitButton.setBackground(new Color(0, 102, 0)); +submitButton.setForeground(Color.red); +JPanel submitPanel = new JPanel(new FlowLayout()); +submitPanel.setPreferredSize(new Dimension(600,50)); +submitPanel.add(submitButton); +f.add(submitPanel); + +f.setVisible(true); +submitButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + electricity= Integer.valueOf(nameField1.getText()); + heating_oil= Integer.valueOf(nameField2.getText()); + coal = Integer.valueOf(nameField3.getText()); + lpg= Integer.valueOf(nameField4.getText()); + propane= Integer.valueOf(nameField5.getText()); + natural_gas= Integer.valueOf(nameField6.getText()); + distance_car= Integer.valueOf(nameField7.getText()); + milage_car = Integer.valueOf(nameField8.getText()); + distance_2= Integer.valueOf(nameField9.getText()); + milage_2 = Integer.valueOf(nameField10.getText()); + calculate_footprint(); + f.setVisible(false); + new Main(); + piechart(); + + + } +}); +backButton1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + f.setVisible(false); + new Main(); + + + } +}); + +} + + +static List lst = new ArrayList<>(); + +double calculate_footprint(){ + + basic_footprint = electricity*0.6 + natural_gas*0.05 +heating_oil*2.68 + coal*2.14 + lpg*1.5 + + propane*1.5; + lst.add( basic_footprint/1000); + + from_car = distance_car*milage_car*2.3; + lst.add( from_car/1000); + + from_2 = distance_2*milage_2*2.3; + lst.add( from_2/1000); + //Collections.sort(lst); + //System.out.println(lst); + + carbonfootprint1 = basic_footprint/1000; + carbonfootprint2 = (from_car+from_2)/1000; + + //return carbonfootprint1 + carbonfootprint2; + footprint_page = carbonfootprint1 + carbonfootprint2; + + return footprint_page; +} + + public double toReturn() { + return carbonfootprint1 + carbonfootprint2; + } + + + void piechart() +{ + + JFrame f = new JFrame("First Page"); + f.setLayout(null); + + JTextArea textArea = new JTextArea("\t Household Footprint is "+carbonfootprint1+"\t\t Outdoor Footprint is "+carbonfootprint2); + + + textArea.setPreferredSize(new Dimension(800, 50)); + textArea.setFont(new Font("Arial", Font.BOLD, 20)); + + // set the line wrap and word wrap properties of the text area + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + + // make the text area read-only + textArea.setEditable(false); + + // Set the position and size of the JTextArea using absolute positioning + textArea.setBounds(0, 100, 1200, 70); + + // add the text area to the frame + f.add(textArea); + + // set the size of the text area + f.setSize(1200, 800); + + // make the frame visible + f.pack(); + f.setVisible(true); + System.out.println(electricity +" " +heating_oil +" "+ coal +" "+ lpg +" "+ propane +" "+ natural_gas); + double sum = electricity + heating_oil + coal + lpg + propane + natural_gas; + double sum1 = distance_car + milage_car + distance_2 + milage_2; + //System.out.println(electricity/sum * 100); + // Create values and colors for the pie charts + List values1 = new ArrayList<>(); + values1.add(electricity/sum * 100); + values1.add(heating_oil/sum * 100); + values1.add(coal/sum * 100); + values1.add(lpg/sum * 100); + values1.add(propane/sum * 100); + values1.add(natural_gas/sum * 100); + System.out.println(values1); + + List colors1 = new ArrayList<>(); + colors1.add(Color.RED); + colors1.add(Color.GREEN); + colors1.add(Color.BLUE); + colors1.add(new Color(128,0, 128)); + colors1.add(Color.YELLOW); + colors1.add(new Color(0,128, 128)); + + List values2 = new ArrayList<>(); + values2.add(distance_car/sum1 * 100); + values2.add(milage_car/sum1 * 100); + values2.add(distance_2/sum1 * 100); + values2.add(milage_2/sum1 * 100); + + + + List colors2 = new ArrayList<>(); + colors2.add(Color.YELLOW); + colors2.add(new Color(128,0, 128)); + colors2.add(Color.CYAN); + colors2.add(Color.RED); + + + // Create two new pie charts with the values and colors + User2 chart1 = new User2(values1, colors1); + User2 chart2 = new User2(values2, colors2); + + // Create a new JFrame and add the pie charts to it + //JFrame f = new JFrame("First Page"); + f.setVisible(true); + f.setSize(1200, 800); + f.setLayout(new BorderLayout()); + + // Create a JPanel to hold the pie charts + JPanel chartsPanel = new JPanel(); + chartsPanel.setLayout(new GridLayout(1, 2)); // Change to 1 row, 2 columns + chartsPanel.add(chart1); + chartsPanel.add(chart2); + + // Add the charts panel to the JFrame + f.add(chartsPanel, BorderLayout.CENTER); + + // Add a title label to the top of the JFrame + JLabel l1 = new JLabel("INDIVIDUAL LEVEL CARBON FOOTPRINT", JLabel.CENTER); + l1.setOpaque(true); + l1.setBackground(new Color(0, 102, 0)); + l1.setForeground(Color.WHITE); + l1.setFont(new Font("Arial", Font.BOLD, 30)); + l1.setPreferredSize(new Dimension(1200, 100)); + // create a border for the label + Border border = BorderFactory.createMatteBorder(2, 0, 2, 0, Color.GREEN); + l1.setBorder(border); + f.add(l1, BorderLayout.NORTH); + + + + ImageIcon imageIcon = new ImageIcon("label1.jpeg"); + JLabel imageLabel = new JLabel(); + imageLabel.setIcon(imageIcon); + JPanel imagePanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + imagePanel1.add(imageLabel); + + ImageIcon imageIcon2 = new ImageIcon("label2.jpg"); + JLabel imageLabel2 = new JLabel(); + imageLabel2.setIcon(imageIcon2); + JPanel imagePanel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + imagePanel2.add(imageLabel2); + + JPanel imagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); + imagePanel.add(imagePanel1); + imagePanel.add(imagePanel2); + + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(chartsPanel, BorderLayout.CENTER); + mainPanel.add(imagePanel, BorderLayout.PAGE_END); + + f.add(mainPanel, BorderLayout.CENTER); + + // JButton backButton1 = new JButton("Back"); +// backButton1.setFont(new Font("Arial", Font.PLAIN, 20)); +// backButton1.setPreferredSize(new Dimension(150, 50)); +// backButton1.setBackground(new Color(0, 102, 0)); +// backButton1.setForeground(Color.red); +// JPanel backPanel1 = new JPanel(new FlowLayout()); +// backPanel1.setPreferredSize(new Dimension(600,50)); +// backPanel1.add(backButton1); +// f.setLayout(new BorderLayout()); + + // Add the panel to the frame's SOUTH position +// f.add(backPanel1, BorderLayout.SOUTH); +// f.setVisible(true); +} +} + class User2 extends JPanel { + + private List values; + private List colors; + + public User2(List values, List colors) { + this.values = values; + this.colors = colors; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + double total = 0; + for (double value : values) { + total += value; + } + + double currentAngle = 0; + int x = getWidth() / 2; + int y = getHeight() / 2; + int diameter = Math.min(getWidth(), getHeight()) - 200; + + for (int i = 0; i < values.size(); i++) { + double value = values.get(i); + double angle = 360 * value / total; + g.setColor(colors.get(i)); + g.fillArc(x - diameter / 2, y - diameter / 2, diameter, diameter, (int) currentAngle, (int) angle); + + // Add label to center of pie slice + g.setColor(Color.BLACK); + Font font5 = new Font("Helvetica", Font.PLAIN, 20); + g.setFont(font5); + double labelAngle = currentAngle + angle / 2; + int labelX = (int) (x + (diameter / 2 * Math.cos(Math.toRadians(labelAngle)))); + int labelY = (int) (y + (diameter / 2 * Math.sin(Math.toRadians(labelAngle)))); + String label = String.format("%.1f%%", value); + g.drawString(label, labelX, labelY); + currentAngle += angle; + } + } + } + + +public class User1 { + +//public static void main(String[] args) { +//// TODO Auto-generated method stub +//Indi ob2 = new Indi(); +//ob2.accept(); +// +//} + +} diff --git a/Footprint/convert.java b/Footprint/convert.java new file mode 100644 index 0000000..3576ede --- /dev/null +++ b/Footprint/convert.java @@ -0,0 +1,58 @@ +package footprint; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +class carbon{ + static HashMap map = new HashMap<>(); + static HashMap carbon_city = new HashMap<>(); + static String[] emp; + + void map() throws IOException { + String csvFile = "C:\\Users\\srush\\Downloads\\data.csv"; + BufferedReader br = new BufferedReader(new FileReader(csvFile)); + + String line; + int count=0; + while ((line = br.readLine()) != null) { + if(count<2) + { + count++; + continue; + } + // use comma as separator + emp = line.split(","); + + Attributes obj = new Attributes(); + obj.number_of_roads = Integer.parseInt(emp[1]); + obj.area_of_city = Double.parseDouble(emp[4]); + obj.co2 = Double.parseDouble(emp[5]); + obj.co = Double.parseDouble(emp[6]); + obj.ch = Double.parseDouble(emp[7]); + obj.hc = Double.parseDouble(emp[8]); + obj.nox = Double.parseDouble(emp[9]); + obj.pm = Double.parseDouble(emp[10]); + obj.so2 = Double.parseDouble(emp[11]); + map.put(emp[0],obj); + } + } + + void calculate(){ + for(int i=0;i< map.size();i++){ + Attributes temp = map.get(map.keySet().toArray()[i].toString()); + double footprint = (temp.ch+ temp.co+ temp.co2+ temp.hc+ temp.nox+ temp.pm+ temp.so2)*8.91*28 /1000; + carbon_city.put(map.keySet().toArray()[i].toString(),footprint/1000); + } + System.out.println(carbon_city); + } +} +public class convert { + + public static void main(String[] args) throws IOException { + carbon obj = new carbon(); + obj.map(); + obj.calculate(); + } +} + diff --git a/README.md b/README.md index e6bc571..61cadca 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ -# Buffer-4.0 -Buffer is a Data Structures and Algorithms Project series, in which students can participate as mentees in teams of 3-4 people. -This year the themes on which students can create a project are- -1. Healthcare -2. Digital Society -3. Open Innovation -4. Custom data structure to store data +THEME -Open Innovation +PROJECT NAME-Carbon Footprint +Alchemists 66 +SWAMINI BHAGWAT SY COMP +SRUSHTI JOHARI SY COMP +MAITHILI KARLE SY COMP -This repository is created for all the teams to be able to upload their final project source code for the same. -While submitting, note that: +PRESENTATION LINK-https://drive.google.com/file/d/1sBDJhtT1RI5Uuf---bSmRQCzskcox1Tq/view?usp=sharing -Each folder should have the name of the team and inside a readme file with team member details, (name, year, branch) and their theme. The readme file should also contain the link to their presentation as well as the drive link where both the report documents would be stored. -Happy Coding :) +DOCUMENT LINK- + +https://docs.google.com/document/d/1Mkbnni2RcbNRMico9WmJNhUBOkk2ERqr/edit?usp=sharing&ouid=114108411533946745290&rtpof=true&sd=true + + +https://docs.google.com/document/d/16lzHYsCqUsJdC9OsKf12v_bzUluyOJpu/edit?usp=sharing&ouid=114108411533946745290&rtpof=true&sd=true diff --git a/images/individual_carbon.jpeg b/images/individual_carbon.jpeg new file mode 100644 index 0000000..7199c74 Binary files /dev/null and b/images/individual_carbon.jpeg differ diff --git a/images/industry.jpg b/images/industry.jpg new file mode 100644 index 0000000..f767eb1 Binary files /dev/null and b/images/industry.jpg differ diff --git a/images/label1.jpg b/images/label1.jpg new file mode 100644 index 0000000..6e15306 Binary files /dev/null and b/images/label1.jpg differ diff --git a/images/label2.jpg b/images/label2.jpg new file mode 100644 index 0000000..7ee8d23 Binary files /dev/null and b/images/label2.jpg differ diff --git a/images/label3.jpg b/images/label3.jpg new file mode 100644 index 0000000..d3a7ff7 Binary files /dev/null and b/images/label3.jpg differ diff --git a/images/m1.png b/images/m1.png new file mode 100644 index 0000000..7d3bb8a Binary files /dev/null and b/images/m1.png differ diff --git a/images/reduce1.jpg b/images/reduce1.jpg new file mode 100644 index 0000000..172b6a0 Binary files /dev/null and b/images/reduce1.jpg differ diff --git a/images/region.jpg b/images/region.jpg new file mode 100644 index 0000000..b5d5dce Binary files /dev/null and b/images/region.jpg differ diff --git a/regionCSV/state_carbon.csv b/regionCSV/state_carbon.csv new file mode 100644 index 0000000..b20ef3d --- /dev/null +++ b/regionCSV/state_carbon.csv @@ -0,0 +1,23 @@ +Metropolitan,Number of all road vehicles in  metropolitan city,Ratio,Geographical area of metropolitan city (km2),CO2,CO,CH4,HC,NOx,PM,SO2 +city,,,,(Mg km-2),(Mg km-2),(Mg km-2),(Mg km-2),(Mg km-2),(Mg km-2),(Mg km-2) +Hyderabad*,1355700,0.24,172.7,18258.86,281.47,13.26,78.05,197.12,13.91,55.94 +Visakhapatnam,411691,0.07,182.7,5034.01,77.6,3.66,21.52,54.35,3.84,15.42 +Patna,335623,0.45,108.34,18244.82,189.16,5.91,32.91,149.03,10.42,55.6 +Delhi**,4236675,1,431.09,20843.82,284.43,15.56,87.74,129.99,9.13,42.38 +Ahmedabad,1075213,0.15,281.08,12438.69,165.52,6.67,35.49,93.2,7.52,32.99 +Surat,692118,0.1,212.52,10967.65,145.94,5.88,31.3,82.18,6.63,29.09 +Vadodara,586438,0.08,113.87,2481.43,21.33,0.81,5.52,29.16,1.47,8.66 +Bangalore,1890692,0.48,226.24,32013.25,405.25,16.14,86.03,323.75,22.18,93.29 +Bhopal,391579,0.1,298.48,3786.22,47.58,1.92,11.6,27.29,2.19,12.26 +Indore,644771,0.17,160.45,11973.75,150.46,6.06,36.69,86.31,6.92,38.77 +Mumbai,1199416,0.13,438,8562.01,118.91,4.95,24.69,67.8,5.41,23.67 +Nagpur,543322,0.06,217.56,7955.7,110.49,4.6,22.94,63,5.03,22 +Pune,754902,0.08,430,5366.96,74.54,3.1,15.48,42.5,3.39,14.84 +Ludhiana,770784,0.22,159.37,14847.91,183.9,7.52,43.43,98.33,8.09,38.7 +Jaipur,823715,0.21,484.64,6571.53,72.76,2.83,17.61,65.61,4.13,18.35 +Chennai,2014776,0.23,174,34903.5,429.13,18.99,118.95,353.67,23.01,108.04 +Kanpur,424652,0.07,266.74,4570.5,59.85,2.56,15.07,32.01,2.65,12.3 +Lucknow,614794,0.1,310.1,5616.32,73.55,3.15,18.52,39.34,3.26,15.12 +Varanasi,365913,0.06,91.9,11370.76,148.91,6.38,37.49,79.64,6.6,30.61 +Kolkata,875156,0.34,186.23,22402.15,213.94,9.1,59.66,273.55,14.23,72.07 +Total,20007930,0.34,4946.01,258209.86,3254.71,139.04,800.68,2287.85,160,740.09