package jatek0002Demo;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;

import customize.Custom;
import jatek.JatekPanel;

public class Jatek0002DemoPanel extends JatekPanel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8564812576014765114L;
	
	protected JPanel inputPanel=new JPanel();
		protected Grafika gr = new Grafika();
	protected JLabel gameResults=new JLabel("Eredmények");

	protected JLabel jlA11,jlA12,jlA21,jlA22,jlB11,jlB12,jlB21,jlB22;
	protected JSpinner jspA11,jspA12,jspA21,jspA22,jspB11,jspB12,jspB21,jspB22;
	protected JButton start=new JButton("Számol");
	
	public Jatek0002DemoPanel(){
		super();
		SpinnerNumberModel model1 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model2 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model3 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model4 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model5 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model6 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model7 = new SpinnerNumberModel(0, -10, 10, 1);
		SpinnerNumberModel model8 = new SpinnerNumberModel(0, -10, 10, 1);
		jspA11=new JSpinner(model1);jspA11.setMaximumSize(new Dimension(20,30));
		jspA12=new JSpinner(model2);jspA12.setMaximumSize(new Dimension(20,30));
		jspA21=new JSpinner(model3);jspA21.setMaximumSize(new Dimension(20,30));
		jspA22=new JSpinner(model4);jspA22.setMaximumSize(new Dimension(20,30));
		jspB11=new JSpinner(model5);jspB11.setMaximumSize(new Dimension(20,30));
		jspB12=new JSpinner(model6);jspB12.setMaximumSize(new Dimension(20,30));
		jspB21=new JSpinner(model7);jspB21.setMaximumSize(new Dimension(20,30));
		jspB22=new JSpinner(model8);jspB22.setMaximumSize(new Dimension(20,30));
		
		
		jlA11=new JLabel("<html>a<sub>11</sub></html>");jlA11.setHorizontalAlignment(SwingConstants.CENTER);
		jlA12=new JLabel("<html>a<sub>12</sub></html>");jlA12.setHorizontalAlignment(SwingConstants.CENTER);
		jlA21=new JLabel("<html>a<sub>21</sub></html>");jlA21.setHorizontalAlignment(SwingConstants.CENTER);
		jlA22=new JLabel("<html>a<sub>22</sub></html>");jlA22.setHorizontalAlignment(SwingConstants.CENTER);
		jlB11=new JLabel("<html>b<sub>11</sub></html>");jlB11.setHorizontalAlignment(SwingConstants.CENTER);
		jlB12=new JLabel("<html>b<sub>12</sub></html>");jlB12.setHorizontalAlignment(SwingConstants.CENTER);
		jlB21=new JLabel("<html>b<sub>21</sub></html>");jlB21.setHorizontalAlignment(SwingConstants.CENTER);
		jlB22=new JLabel("<html>b<sub>22</sub></html>");jlB22.setHorizontalAlignment(SwingConstants.CENTER);
		
		gameResults.setHorizontalAlignment(SwingConstants.CENTER);
		gameResults.setBorder(BorderFactory.createLineBorder(Color.black));
		this.setLayout(new FlowLayout());

		//inputPanel tartalma
		Box ab=Box.createVerticalBox();
		
			Box inBoxA=Box.createHorizontalBox();
			inBoxA.add(jlA11);inBoxA.add(jspA11);
			inBoxA.add(jlA12);inBoxA.add(jspA12);
			inBoxA.add(Box.createHorizontalStrut(100));
			inBoxA.add(jlB11);inBoxA.add(jspB11);
			inBoxA.add(jlB12);inBoxA.add(jspB12);
		
			Box inBoxB=Box.createHorizontalBox();
			inBoxB.add(jlA21);inBoxB.add(jspA21);
			inBoxB.add(jlA22);inBoxB.add(jspA22);
			inBoxB.add(Box.createHorizontalStrut(100));
			inBoxB.add(jlB21);inBoxB.add(jspB21);
			inBoxB.add(jlB22);inBoxB.add(jspB22);
			
		ab.add(inBoxA);
		ab.add(Box.createVerticalStrut(10));
		ab.add(inBoxB);
		ab.add(Box.createVerticalStrut(10));
		ab.add(gameResults);
		ab.add(Box.createVerticalStrut(10));
		ab.add(start);
		
		Box box = Box.createVerticalBox();
	    box.setPreferredSize(new Dimension(550,500));
	    box.add(ab);
        box.add(gr);
        
        inputPanel.add(box);
        inputPanel.setBorder(BorderFactory.createLineBorder(Color.decode(Custom.getBorderColor()),Custom.getBorderThickness()));      
        
	    this.add(inputPanel);
	    setPanel("input");
	}

	@Override
	public void showMessage(String messageType){
		if("loaded".equals(messageType)){
			JOptionPane.showMessageDialog(this,"Sikeres betöltés. Kattintson az OK gombra!",
		         "Betöltés",JOptionPane.INFORMATION_MESSAGE);
		}
	}
	
	public JLabel getGameResults() {
		return gameResults;
	}


	public void setGameResults(JLabel gameResults) {
		this.gameResults = gameResults;
	}


	public Grafika getGr() {
		return gr;
	}
	public JSpinner getJspA11() {
		return jspA11;
	}


	public void setJspA11(JSpinner jspA11) {
		this.jspA11 = jspA11;
	}


	public JSpinner getJspA12() {
		return jspA12;
	}


	public void setJspA12(JSpinner jspA12) {
		this.jspA12 = jspA12;
	}


	public JSpinner getJspA21() {
		return jspA21;
	}


	public void setJspA21(JSpinner jspA21) {
		this.jspA21 = jspA21;
	}


	public JSpinner getJspA22() {
		return jspA22;
	}


	public void setJspA22(JSpinner jspA22) {
		this.jspA22 = jspA22;
	}


	public JSpinner getJspB11() {
		return jspB11;
	}


	public void setJspB11(JSpinner jspB11) {
		this.jspB11 = jspB11;
	}


	public JSpinner getJspB12() {
		return jspB12;
	}


	public void setJspB12(JSpinner jspB12) {
		this.jspB12 = jspB12;
	}


	public JSpinner getJspB21() {
		return jspB21;
	}


	public void setJspB21(JSpinner jspB21) {
		this.jspB21 = jspB21;
	}


	public JSpinner getJspB22() {
		return jspB22;
	}


	public void setJspB22(JSpinner jspB22) {
		this.jspB22 = jspB22;
	}


	public JButton getStart() {
		return start;
	}


	public void setStart(JButton start) {
		this.start = start;
	}


	/**
	 * A megadott paraméter segítségével eldönti, hogy melyik panelre kell állítani a
	 * középső területet a képernyőn.
	 * @param s String
	 */
	@Override
	public void setPanel(String s){
		if(s.equals("input")) {
			//true
			inputPanel.setVisible(true);
		}
	}
	
}
