package edu.kit.iks.Cryptographics.DiffieHellman.Demonstration;

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

import javax.swing.JLabel;

import edu.kit.iks.CryptographicsLib.VisualizationView;

public class AliceChooseSecretView extends VisualizationView {

	private JLabel aliceExplain;
	
	private ColorChannel cc;
	
	private ColorMix cm;
	/**
	 * 
	 */
	private static final long serialVersionUID = 87178534093974249L;
	
	
	
	public AliceChooseSecretView() {
		super();
		GridBagConstraints gbc = new GridBagConstraints();
		this.setLayout(new GridBagLayout());
		this.aliceExplain = new JLabel();
		this.aliceExplain.setText("<html><div style=\"width:120px\"Alice chooses a public color and sends it to Bob" +
				"Eve listens to the channel and gets a copy</div></html>");
		gbc.weightx = 0.3;
		gbc.weighty = 0.1;
		gbc.gridx = 0;
		gbc.gridy = 0;
		this.add(aliceExplain, gbc);
		this.cc = new ColorChannel(new Dimension(700, 200), 70);
		
		gbc.weightx = 0.3;
		gbc.weighty = 0.3;
		gbc.gridx = 0;
		gbc.gridy = 1;
		gbc.fill = GridBagConstraints.BOTH;
		this.add(this.cc, gbc);

		this.cm = new ColorMix(Color.BLUE, Color.GREEN, 50, new Dimension(300, 300));
		
		gbc.weightx = 0.3;
		gbc.weighty = 0.3;
		gbc.gridx = 0;
		gbc.gridy = 2;
		this.add(this.cm, gbc);
		this.cc.loadView();
		this.cc.setRepeat(false);
		this.cc.setKeepColor(true);
		this.cc.setColor(Color.BLUE);
		this.validate();
		
		this.cc.sendToBob(new NextStepCallback() {
			
			@Override
			public void callback() {
				cm.mixColors(true, false, new NextStepCallback() {
					
					@Override
					public void callback() {
						cc.setColor(cm.getMixedColor());
						cc.sendToBob(new NextStepCallback() {
							
							@Override
							public void callback() {
								cm.setEllipColor(2, Color.RED);
								cm.mixColors(true, false, new NextStepCallback() {
									
									@Override
									public void callback() {
										cc.setColor(cm.getMixedColor());
										cc.sendToAlice(null, 2, true);										
									}
								}, 1);
							}
						}, 1, true);
					}
				}, 0);			
			}
		}, 0, true);
	}





	public ColorChannel getColorChannel() {
		return this.cc;
	}

}

@@ -598,45 +598,301 @@
 ;%0A%09%09
-this.setLayout(new GridBagLayout()
+GridBagLayout layout = new GridBagLayout();%0A%09%09this.setLayout(layout);%0A%09%09%0A%09%09gbc.gridx = 2;%0A%09%09gbc.gridy = 2;%0A%09%09gbc.weightx = 0.1;%0A%09%09gbc.weighty = 0.1;%0A%09%09layout.setConstraints(this.getNextButton(), gbc);%0A%09%09%0A%09%09gbc.gridx = 0;%0A%09%09gbc.gridy = 2;%0A%09%09layout.setConstraints(this.getBackButton(), gbc
 );%0A
+%09%09%0A
 %09%09th
@@ -984,16 +984,17 @@
 :120px%5C%22
+%3E
 Alice ch
@@ -1111,33 +1111,33 @@
 gbc.weightx = 0.
-3
+1
 ;%0A%09%09gbc.weighty 
@@ -1149,33 +1149,33 @@
 ;%0A%09%09gbc.gridx = 
-0
+1
 ;%0A%09%09gbc.gridy = 
@@ -1174,17 +1174,17 @@
 gridy = 
-0
+2
 ;%0A%09%09this
@@ -1280,33 +1280,33 @@
 gbc.weightx = 0.
-3
+1
 ;%0A%09%09gbc.weighty 
@@ -1301,33 +1301,33 @@
 gbc.weighty = 0.
-3
+1
 ;%0A%09%09gbc.gridx = 
@@ -1318,33 +1318,33 @@
 ;%0A%09%09gbc.gridx = 
-0
+1
 ;%0A%09%09gbc.gridy = 
@@ -1343,17 +1343,17 @@
 gridy = 
-1
+0
 ;%0A%09%09gbc.
@@ -1508,25 +1508,25 @@
 weightx = 0.
-3
+1
 ;%0A%09%09gbc.weig
@@ -1533,17 +1533,17 @@
 hty = 0.
-3
+1
 ;%0A%09%09gbc.
@@ -1542,33 +1542,33 @@
 ;%0A%09%09gbc.gridx = 
-0
+2
 ;%0A%09%09gbc.gridy = 
@@ -1559,33 +1559,33 @@
 ;%0A%09%09gbc.gridy = 
-2
+0
 ;%0A%09%09this.add(thi

change layout of alicechoosesecretView