import java.awt.*;
import javax.swing.*;
import simulate.Simulation2D;
import simulate.Phase;
import simulate.DisplayConfiguration;
import simulate.SpeciesDisks;
import simulate.ControllerButton;
import simulate.IntegratorMC;
import simulate.MCMoveAtom;
import simulate.MCMoveVolume;
import simulate.P2LennardJones;

/**
 * A basic extension of the javax.swing.JApplet class
 */
public class nptMCLJ extends JApplet
{
	public void init()
	{
		// Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
		symantec.itools.lang.Context.setApplet(this);
		
		// This line prevents the "Swing: checked access to system event queue" message seen in some browsers.
		getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
		
		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		getContentPane().setLayout(null);
		getContentPane().setBackground(java.awt.Color.white);
		setSize(513,475);
		simulation2D1.setLayout(null);
		getContentPane().add(simulation2D1);
		simulation2D1.setBounds(24,12,400,300);
		phase1.setLayout(null);
		simulation2D1.add(phase1);
		phase1.setBounds(24,216,20,40);
		displayConfiguration1.setImageShells(1);
		displayConfiguration1.setDRAW_OVERFLOW(true);
		displayConfiguration1.setScale(0.8);
		displayConfiguration1.setLayout(null);
		simulation2D1.add(displayConfiguration1);
		displayConfiguration1.setBounds(108,0,300,300);
		speciesDisks1.setLayout(null);
		simulation2D1.add(speciesDisks1);
		speciesDisks1.setBounds(24,228,20,40);
		controllerButton1.setButtonTextColor(java.awt.Color.white);
		controllerButton1.setButtonColor(java.awt.Color.black);
		controllerButton1.setLayout(null);
		simulation2D1.add(controllerButton1);
		controllerButton1.setBounds(12,12,100,40);
		integratorMC1.setTemperature(100.0);
		integratorMC1.setLayout(null);
		controllerButton1.add(integratorMC1);
		integratorMC1.setBounds(60,0,20,40);
		integratorMC1.add(MCMoveAtom1);
		MCMoveAtom1.setBounds(0,0,20,40);
		MCMoveVolume1.setPressure(100000.0);
		integratorMC1.add(MCMoveVolume1);
		MCMoveVolume1.setBounds(0,0,20,40);
		simulation2D1.add(P2LennardJones1);
		P2LennardJones1.setBounds(36,60,60,60);
		JPanel1.setLayout(new GridLayout(2,2,10,0));
		getContentPane().add(JPanel1);
		JPanel1.setBackground(java.awt.Color.white);
		JPanel1.setBounds(96,320,336,135);
		JSlider1.setValue(5);
		JSlider1.setMaximum(10);
		JSlider1.setPaintLabels(true);
		JSlider1.setPaintTicks(true);
		JSlider1.setMajorTickSpacing(1);
		JPanel1.add(JSlider1);
		JSlider1.setBackground(java.awt.Color.white);
		JSlider1.setBounds(0,0,163,67);
		JLabel1.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
		JLabel1.setText("Log10(Pressure)");
		JPanel1.add(JLabel1);
		JLabel1.setBounds(173,0,163,67);
		JSlider2.setMinorTickSpacing(50);
		JSlider2.setValue(100);
		JSlider2.setMaximum(800);
		JSlider2.setPaintLabels(true);
		JSlider2.setPaintTicks(true);
		JSlider2.setMajorTickSpacing(200);
		JPanel1.add(JSlider2);
		JSlider2.setBackground(java.awt.Color.white);
		JSlider2.setBounds(0,67,163,67);
		JLabel2.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
		JLabel2.setText("Temperature");
		JPanel1.add(JLabel2);
		JLabel2.setBounds(173,67,163,67);
		//}}
	
		//{{REGISTER_LISTENERS
		SymChange lSymChange = new SymChange();
		JSlider1.addChangeListener(lSymChange);
		JSlider2.addChangeListener(lSymChange);
		//}}
	}

	//{{DECLARE_CONTROLS
	simulate.Simulation2D simulation2D1 = new simulate.Simulation2D();
	simulate.Phase phase1 = new simulate.Phase();
	simulate.DisplayConfiguration displayConfiguration1 = new simulate.DisplayConfiguration();
	simulate.SpeciesDisks speciesDisks1 = new simulate.SpeciesDisks();
	simulate.ControllerButton controllerButton1 = new simulate.ControllerButton();
	simulate.IntegratorMC integratorMC1 = new simulate.IntegratorMC();
	simulate.MCMoveAtom MCMoveAtom1 = new simulate.MCMoveAtom();
	simulate.MCMoveVolume MCMoveVolume1 = new simulate.MCMoveVolume();
	simulate.P2LennardJones P2LennardJones1 = new simulate.P2LennardJones();
	javax.swing.JPanel JPanel1 = new javax.swing.JPanel();
	javax.swing.JSlider JSlider1 = new javax.swing.JSlider();
	javax.swing.JLabel JLabel1 = new javax.swing.JLabel();
	javax.swing.JSlider JSlider2 = new javax.swing.JSlider();
	javax.swing.JLabel JLabel2 = new javax.swing.JLabel();
	//}}

	class SymChange implements javax.swing.event.ChangeListener
	{
		public void stateChanged(javax.swing.event.ChangeEvent event)
		{
			Object object = event.getSource();
			if (object == JSlider1)
				JSlider1_stateChanged(event);
			else if (object == JSlider2)
				JSlider2_stateChanged(event);
		}
	}

	void JSlider1_stateChanged(javax.swing.event.ChangeEvent event)
	{
		// to do: code goes here.
			 
		JSlider1_stateChanged_Interaction1(event);
	}

	void JSlider1_stateChanged_Interaction1(javax.swing.event.ChangeEvent event)
	{
		try {
			// JSlider1 Get the JSlider's current value
			MCMoveVolume1.setLogPressure(JSlider1.getValue());
		} catch (java.lang.Exception e) {
		}
	}

	void JSlider2_stateChanged(javax.swing.event.ChangeEvent event)
	{
		// to do: code goes here.
			 
		JSlider2_stateChanged_Interaction1(event);
	}

	void JSlider2_stateChanged_Interaction1(javax.swing.event.ChangeEvent event)
	{
		try {
			// JSlider2 Get the JSlider's current value
			integratorMC1.setTemperature(JSlider2.getValue());
		} catch (java.lang.Exception e) {
		}
	}
}
