package view.panels.tabs;

import view.panels.PlotPanel;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;

/**
 * Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
 *
 * @Author: Armin Wolf
 * @Email: a_wolf28@uni-muenster.de
 * @Date: 10.09.2017.
 */
public abstract class TabPanel extends JPanel{


    private PlotPanel plotPanel;
    private JPanel northPanel;
    private JPanel centerPanel;

    private JButton startButton;

    public TabPanel() {
        super();
        this.centerPanel = new JPanel(new BorderLayout());
        this.centerPanel.setBorder(new TitledBorder("Visualisierung"));

        this.setLayout(new BorderLayout());
        this.northPanel = new JPanel(new BorderLayout());
        this.centerPanel = new JPanel(new BorderLayout());
        this.northPanel.setBorder(new TitledBorder("Konfiguration"));
        this.centerPanel.setBorder(new TitledBorder("Visualisierung"));


        this.add(centerPanel, BorderLayout.CENTER);
        this.add(northPanel, BorderLayout.NORTH);

        this.startButton = new JButton("Start");
        this.startButton.setFont(new Font("Verdana", Font.PLAIN, 16));
    }

    public void setPlotPanel(PlotPanel plotPanel) {
        this.plotPanel = plotPanel;
        if (this.centerPanel.getComponents().length > 0)
            this.centerPanel.remove(0);

        this.centerPanel.add(plotPanel, BorderLayout.CENTER);
        this.plotPanel.setVisible(true);
        this.repaint();
        this.revalidate();
    }

    protected void addTextfieldAndInput(int row, String name, Double value){
        //muss nicht obligatorisch implementiert werden
    }

    public PlotPanel getPlotPanel() {
        return plotPanel;
    }

    public JButton getStartButton() {
        return startButton;
    }

    public void setStartButton(JButton startButton) {
        this.startButton = startButton;
    }

    public JPanel getNorthPanel() {
        return northPanel;
    }

    public void setNorthPanel(JPanel northPanel) {
        this.northPanel = northPanel;
    }

    public JPanel getCenterPanel() {
        return centerPanel;
    }

    public void setCenterPanel(JPanel centerPanel) {
        this.centerPanel = centerPanel;
    }
}
