package fr.iutfbleau.projetIHM2022FI2.Graphic.View;

import javax.swing.JFrame;
import javax.swing.JPanel;

import java.awt.*;
import java.util.LinkedList;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import fr.iutfbleau.projetIHM2022FI2.API.*;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurFenetre;

public class MaFenetre extends JFrame{
    private LinkedList<Groupe> tabGroupe=new LinkedList<Groupe>();
    private JPanel Left;
    private JPanel Right;

    public MaFenetre(){
        super();
        this.setSize(1000,720);
        this.setLocation(200,200);
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        this.getContentPane().setBackground(new Color(230, 230, 255, 255));
        this.addWindowListener(new ObservateurFenetre());
        this.setLayout(new GridBagLayout());
        this.Left=new JPanel();
        this.Right=new JPanel();


        GridBagConstraints gc=new GridBagConstraints();
        gc.gridx=1;
        gc.gridy=1;
        gc.anchor=GridBagConstraints.CENTER;
        gc.gridheight=1;
        gc.gridwidth=1;
        gc.fill=GridBagConstraints.BOTH;
        this.add(this.Left, gc);

        gc.gridx=2;
        gc.gridy=1;
        gc.anchor=GridBagConstraints.CENTER;
        gc.gridheight=1;
        gc.gridwidth=1;
        gc.fill=GridBagConstraints.BOTH;
        this.add(this.Right, gc);
    }

    public void addGroupe(Groupe g){
        this.tabGroupe.add(g);
    }
    public boolean removeGroupe(Groupe g){
        int i=this.tabGroupe.indexOf(g);
        if(i==-1){
            return false;
        }else{
            this.tabGroupe.remove(i);
        }
        return true;
    }
    
    private void GroupeDraw(){

    }
    private GridBagConstraints getConstraints(int index){
        GridBagConstraints gc=new GridBagConstraints();
        gc.gridx=1;
        gc.gridy=index;
        gc.anchor=GridBagConstraints.BASELINE;
        gc.gridheight=1;
        gc.gridwidth=1;
        gc.insets=null;
        gc.fill=GridBagConstraints.HORIZONTAL;
        return gc;
    }
}