/* Author: Amay Agrawal
 * Project: Bacteria Cloud
 * Mentor: Prof. Manish K Gupta
 */
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.imageio.ImageIO;
import javax.swing.*;

public class Mainframe extends JFrame {

    //public  JFrame frame1;

    // JPanel
	String aaf = "You can find software credits here : ";
    String bbf = "Credits";
    String gf = String.format("<html>%s<font color='blue'><u>%s</u></font></html>",aaf , bbf);
    JLabel lblFileLink = new JLabel(gf);
    String aaf1 = "You can find Software Manual here : ";
    String bbf1 = "Software_Manual";
    String gf1 = String.format("<html>%s<font color='blue'><u>%s</u></font></html>",aaf1 , bbf1);
    JLabel lblFileLink1 = new JLabel(gf1);
    String aaf2 = "Link to the software hompage is : ";
    String bbf2 = "Homepage";
    String gf2 = String.format("<html>%s<font color='blue'><u>%s</u></font></html>",aaf2,bbf2);
    //String gf2 = "<html> Link to the software homepage is : <a href=\"https://www.w3schools.com\">abab</a></html>";
  JLabel lblFileLink2 = new JLabel(gf2);
  String aaf3 = "You can find software demo here : ";
  String bbf3 = "Software_Demo";
  String gf3 = String.format("<html>%s<font color='blue'><u>%s</u></font></html>",aaf3 , bbf3);
  JLabel lblFileLink3 = new JLabel(gf3);
    static JPanel pnlButton = new JPanel();
    // Buttons
    static JLabel lblBackgroundImage = new JLabel();
    ImageIcon ii = new ImageIcon("logo/main.jpg");
    JLabel lable = new JLabel(ii);
    public static JButton aboutbutton;
    static JButton importbutton = new JButton("Import File");
    static JButton declone = new JButton("Declone Data");
    static JButton encode = new JButton("Encode File");
    static JButton decode = new JButton("Import Encoded");
    static JButton btn = new JButton("OK");
    static JButton mcs = new JButton("MCS & Restriction Enzyme");
    static JLabel lbl = new JLabel("Select desirable Plasmid");
    static JLabel lbl1 = new JLabel("Select Restriction enzyme");
    static JLabel lbl2 = new JLabel("<html><U>Bacteria Plasmid Storage System</U></html>");
    static JButton clone = new JButton("Clone Data");
    static String[] choices = { "pBR322","pUC18", "pUC19","pUC57","pUC118","pUC119","pUAST","LITMUS28","LITMUS28i","LITMUS29","LITMUS38","LITMUS38i","LITMUS39","M13mp18","M13mp19","pACYC177","pACYC184","pAN7-1","pANT7_cGST","pANT7_nHA","pBC KS(-)","pBC KS(+)","pBC SK(-)","pBC SK(+)","pBluescript II KS(-)","pBluescript II KS(+)","pBluescript II SK(-)","pBluescript II SK(+)","pBluescript KS(-)","pBluescript KS(+)","pBluescript SK(-)","pBluescript SK(+)","pBS KS(-)","pBS KS(+)","pBS SK(-)","pBS SK(+)","pBS(-)","pBS(+)","pcDNA3.1(-)","pcDNA3.1(+)","pcDNA3","pDD","pDNR-Dual","pDNR-LIB","pEX1","pEX-1","pEX2","pEX3","pEX-A","pEX-C-GST","pEX-C-His","pEX-K","pEX-N-GST","pEX-N-His","pEX-N-His-GST","pEZ BAC","pEZSeq-Amp","pEZSeq-Kan","pF1A T7","pF1K T7","pF25A ICE T7","pF25K ICE T7","pFC7A (HQ)","pFC7K (HQ)","pFC20A HaloTag T7 SP6","pFC20K HaloTag T7 SP6","pFC30A His6HaloTag T7","pFC30K His6HaloTag T7","pFN2A (GST)","pFN2K (GST)","pFN6A (HQ)","pFN6K (HQ)","pFN18A HaloTag T7","pFN18K HaloTag T7","pFN19A HaloTag T7 SP6","pFN19K HaloTag T7 SP6","pFN29A His6HaloTag T7","pFN29K His6HaloTag T7","pGEM-3Z","pGEM-3Zf(-)","pGEM-3Zf(+)","pGEM-4Z","pGEM-5Zf(+)","pGEM-7Zf(-)","pGEM-7Zf(+)","pGEM-9Zf(-)","pGEM-11Zf(-)","pGEM-11Zf(+)","pGEM-T","pGS-21a","pH6HTC His6HaloTag T7","pH6HTN His6HaloTag T7","pHSG298","pHSG299","pHSG396","pHSG398","pHY300PLK","pInvRecA","pJAZZ-OC","pJAZZ-OK","pJET1.2","pJW168","pKF 18k-2","pKF 19k-2","pLEXX-AK","pMAL-c5E","pMAL-c5G","pMAL-c5X","pMAL-p5E","pMAL-p5G","pMAL-p5X","pMCS5","pMiniT","pNEB193","pOSIP-CH","pOSIP-CO","pOSIP-CT","pOSIP-KC","pOSIP-KH","pOSIP-KL","pOSIP-KO","pOSIP-KP","pOSIP-KT","pOSIP-TH","pOSIP-TO","pOSIP-TT","pPCR-Script Amp SK(+)","pPCR-Script Cam SK(+)","pRANGER-BTB-1","pRANGER-BTB-2","pRANGER-BTB-3","pRANGER-BTB-5","pRHA-67","pRHA-109","pRHA-113","pRSET A","pRSET B","pRSET C","pSB1C3","pSC101","pSEAP2-Basic","pSF-Core","pSMART BAC v2.0","pSMART HCAmp","pSMART HCKan","pSMART LCAmp","pSMART LCKan","pSP64 Poly(A)","pSP72","pSP73","pSpark Done (linearized)","pSpark I (linearized)","pSpark II (linearized)","pSpark III (linearized)","pSpark IV (linearized)","pSpark V (linearized)","pSTBlue-1","pSTV28","pSTV29","pT7Blue","pT7Blue-2","pT7Blue-3","pTrcHis A","pTrcHis B","pTrcHis C","pTrcHis2 A","pTrcHis2 B","pTrcHis2 C","pTV 118N","pTWV228","pTXB1","pTYB21","pTZ19R","pTZ19U","pTZ57R","pZErO-2"};
    static String[] choices1 = { "Unique Cutters","Unique 6+ Cutters", "Unique & Dual_Cutters","restriction_enzymes","6+ Cutters"};
    
    public Mainframe() throws IOException {
    	JFrame frame1 = new JFrame("Bacteria Plasmid Storage System");
        frame1.setSize(800, 600);
        frame1.setLocationRelativeTo(null);
        frame1.getContentPane().setBackground(Color.WHITE);
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //lblBackgroundImage.setIcon(new ImageIcon("C:\\Users\\HP\\workspace\\3DNA\\icons\\platonic.jpg"));
        //frame1.setLayout(new BorderLayout());
        File file = new File("logo/bacteria 1.jpg");
        if(!file.exists()) {
           System.err.println("my file is not there, I was looking at " + file.getAbsolutePath());
        }
        
        BufferedImage bf = ImageIO.read(new File("logo/bacteria 3.jpg"));
        frame1.setContentPane(new backImage(bf));
 
    	importbutton.addActionListener(new ImportActionListener());
    	encode.addActionListener(new EncodeActionListener());
    	//decode.addActionListener(new DecodeActionListener(importbutton,encode,declone,frame1,pnlButton,lable,lbl2));
    	mcs.addActionListener(new McsActionListener());
    	clone.addActionListener(new CloneActionListener());
    	declone.addActionListener(new DecloneActionListener());
    	//btn.addActionListener(new OkActionListener(cb));
        // FlightInfo setbounds
    	pnlButton.setLayout(null);
        importbutton.setBounds(10, 10, 95, 30);
        encode.setBounds(110, 10, 98, 30);
        decode.setBounds(213, 10, 123, 30);
        btn.setBounds(885, 15, 60, 25);
        mcs.setBounds(950, 13, 185, 30);
        clone.setBounds(1140, 13, 95, 30);
        declone.setBounds(1240, 13, 110, 30);
        
//        Desktop desktop = Desktop.getDesktop();
        ImageIcon about = new ImageIcon("logo/about.png");
        aboutbutton = new JButton(about);
        aboutbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        aboutbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        aboutbutton.setBackground(Color.DARK_GRAY);
        aboutbutton.setToolTipText("About Bacteria_Cloud");
        aboutbutton.setLocation(60,600);
        aboutbutton.setSize(70, 70);
        aboutbutton.setVisible(true);
        frame1.add(aboutbutton);
        
        final JComboBox<String> cb = new JComboBox<String>(choices);
        final JComboBox<String> cb1 = new JComboBox<String>(choices1);
        //System.out.println(cb.getSelectedItem().toString());
        cb.setLocation(487,18);
        cb.setSize(90,20);
        cb.setVisible(true);
        frame1.add(cb);
        frame1.add(declone);
        
        cb1.setLocation(735,18);
        cb1.setSize(145,20);
        cb1.setVisible(true);
        frame1.add(cb1);
        
        btn.addActionListener(new OkActionListener(cb,cb1));
        lbl.setLocation(341,18);
        lbl.setSize(145, 14);
        lbl.setVisible(true);
        
        lbl1.setLocation(582,20);
        lbl1.setSize(148, 14);
        lbl1.setVisible(true);
        
        lbl2.setLocation(100,450);
        lbl2.setFont(new Font("Serif", Font.BOLD, 20));
        lbl2.setSize(500, 25);
        lbl2.setVisible(true);
        
        lable.setLocation(100,100);
        lable.setSize(340, 332);
        lable.setVisible(true);
        //importbutton.setEnabled(false);
        // JPanel bounds
        //pnlButton.setBounds(800, 800, 200, 100);

        // Adding to JFrame
        frame1.add(lbl2);
        frame1.add(lable);
        frame1.add(importbutton);
        frame1.add(encode);
        frame1.add(decode);
        frame1.add(lbl);
        frame1.add(lbl1);
        frame1.add(btn);
        frame1.add(mcs);
        frame1.add(clone);
        
        //frame1.setLocationRelativeTo(null);
        
        //frame1.add(lbl1);
       // frame1.getContentPane().add(pnlButton);
        //frame1.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("C:\\Users\\HP\\Desktop\\3dnaprinterlogo.png")))));
        //frame1.pack();
        //frame1.getContentPane().add(editorPane);
        frame1.setVisible(true);
        //ImportActionListener i = new ImportActionListener(frame1,pnlButton,lable,lbl2,decode,lblFileLink,lblFileLink1,lblFileLink2,lblFileLink3);
        EncodeActionListener e = new EncodeActionListener(frame1,pnlButton);
        //OkActionListener o = new OkActionListener(frame1,pnlButton,lable,lbl2);
        CloneActionListener c = new CloneActionListener(frame1,pnlButton);
        DecloneActionListener d = new DecloneActionListener(frame1,pnlButton);
        // JFrame properties
        //frame1.setLocationRelativeTo(null);
    	
    	
    	
        //setBackground(Color.BLACK);
    	//frame1.setTitle("Bacteria Plasmid Storage System");
    	//
    	
           }
    public static void main(String[] args) throws IOException {
        new Mainframe();
    }
}