/**
 * 
 */
package cz.neubauer.tomas.hazardanalysis.viewcontroller.dangeranalysis;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 * @author Tomáš Neubauer
 */
public class StepPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = -9154626557899756747L;

	private int stepIndex;

	private String stepDesctiption, dangerDescription, counterAct;

	private DangerCalculatorPanel dangerCalculatorPanel;

	private JTextArea txaCounterActDescription;

	/**
	 * @param stepDesctiption
	 * @param dangerDescription
	 */
	public StepPanel(int stepIndex, String stepDesctiption,
			String dangerDescription, String counterAct) {
		this.stepIndex = stepIndex;
		this.stepDesctiption = stepDesctiption;
		this.counterAct = counterAct;
		this.dangerDescription = dangerDescription;

		initGUI();
	}

	/**
	 * @param stepDesctiption
	 * @param dangerDescription
	 */
	public StepPanel(int stepIndex, String stepDesctiption,
			String dangerDescription) {
		this.stepIndex = stepIndex;
		this.stepDesctiption = stepDesctiption;
		counterAct = "";
		this.dangerDescription = dangerDescription;

		initGUI();
	}

	/**
	 * 
	 */
	private void initGUI() {
		GridBagLayout gbl = new GridBagLayout();
		gbl.rowHeights = new int[] { 13, 50, 60 };
		gbl.columnWidths = new int[] { 80, 600 };
		setLayout(gbl);

		GridBagConstraints c = new GridBagConstraints();
		c.anchor = GridBagConstraints.NORTHWEST;
		c.fill = GridBagConstraints.BOTH;
		c.insets = new Insets(2, 6, 2, 6);

		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 2;
		c.gridheight = 1;
		JLabel label = new JLabel("KROK " + stepIndex + ": " + stepDesctiption);
		label.setFont(new Font(label.getFont().getName(), Font.BOLD, 14));
		this.add(label, c);

		c.gridx = 0;
		c.gridy = 1;
		c.gridwidth = 1;
		this.add(new JLabel("Popis opatření"), c);

		c.gridx = 1;
		c.gridy = 1;
		c.gridwidth = 1;
		txaCounterActDescription = new JTextArea(counterAct);
		JScrollPane scroll = new JScrollPane(txaCounterActDescription);
		scroll.setViewportView(txaCounterActDescription);
		this.add(scroll, c);

		c.gridx = 0;
		c.gridy = 2;
		c.gridwidth = 2;
		dangerCalculatorPanel = new DangerCalculatorPanel(dangerDescription);
		this.add(dangerCalculatorPanel, c);

		setPreferredSize(new Dimension(700, 180));
		setBorder(BorderFactory.createLineBorder(Color.black, 1));
	}

	public String getStepDesctiption() {
		return stepDesctiption;
	}

	public void setStepDesctiption(String stepDesctiption) {
		this.stepDesctiption = stepDesctiption;

	}

	public String getDangerDescription() {
		return dangerDescription;
	}

	public void setDangerDescription(String dangerDescription) {
		this.dangerDescription = dangerDescription;
	}

	public void setCounterActDescription(String desc) {
		counterAct = desc;
		txaCounterActDescription.setText(counterAct);
	}

	public String getCounterActDescription() {
		counterAct = txaCounterActDescription.getText();
		return counterAct;
	}

	public void setS(int s) {
		dangerCalculatorPanel.setS(s);
	}

	public int getS() {
		return dangerCalculatorPanel.getS();
	}

	public void setA(int a) {
		dangerCalculatorPanel.setA(a);
	}

	public int getA() {
		return dangerCalculatorPanel.getA();
	}

	public void setE(int e) {
		dangerCalculatorPanel.setE(e);
	}

	public int getE() {
		return dangerCalculatorPanel.getE();
	}

	public void setW(int w) {
		dangerCalculatorPanel.setW(w);
	}

	public int getW() {
		return dangerCalculatorPanel.getW();
	}

	public String getCurrentS() {
		return dangerCalculatorPanel.getCurrentS();
	}

	public String getCurrentA() {
		return dangerCalculatorPanel.getCurrentA();
	}

	public String getCurrentW() {
		return dangerCalculatorPanel.getCurrentW();
	}

	public String getCurrentE() {
		return dangerCalculatorPanel.getCurrentE();
	}

	public String getCurrentDangerLevel() {
		return dangerCalculatorPanel.getCurrentDangerLevel();
	}
}
