import java.awt.*;
import javax.swing.*;
import simulate.Simulation2D;
import simulate.ControllerButton;
import simulate.SpeciesDiskWell;
import simulate.IntegratorHard;
import simulate.Phase;
import simulate.P2SquareWell;
import simulate.DisplayConfiguration;
import simulate.*;
import simulate.units.*;

/**
 * A basic extension of the javax.swing.JApplet class
 */
public class rdfSW 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(733,550);
		simulation2D1.setLayout(null);
		getContentPane().add(simulation2D1);
		simulation2D1.setBackground(java.awt.Color.white);
		simulation2D1.setBounds(24,24,684,550);
		controllerButton1.setButtonTextColor(java.awt.Color.white);
		controllerButton1.setButtonColor(java.awt.Color.black);
		controllerButton1.setLayout(null);
		simulation2D1.add(controllerButton1);
		controllerButton1.setBounds(0,48,100,40);
		integratorHard1.setSleepPeriod(5);
		integratorHard1.setIsothermal(true);
		integratorHard1.setDrawTimeStep(0.05);
		integratorHard1.setTemperature(350.0);
		integratorHard1.setLayout(null);
		controllerButton1.add(integratorHard1);
		integratorHard1.setBounds(60,0,20,40);
		speciesDiskWell1.setNMolecules(25);
		speciesDiskWell1.setDiameter(3.5);
		speciesDiskWell1.setLayout(null);
		simulation2D1.add(speciesDiskWell1);
		speciesDiskWell1.setBounds(48,120,20,40);
		phase1.setLayout(null);
		simulation2D1.add(phase1);
		phase1.setBounds(84,240,20,40);
		P2SquareWell1.setCoreDiameter(3.5);
		simulation2D1.add(P2SquareWell1);
		P2SquareWell1.setBounds(84,108,60,60);
		JSlider1.setMinimum(50);
		JSlider1.setMinorTickSpacing(50);
		JSlider1.setValue(350);
		JSlider1.setMaximum(850);
		JSlider1.setPaintLabels(true);
		JSlider1.setOpaque(false);
		JSlider1.setOrientation(javax.swing.JSlider.VERTICAL);
		JSlider1.setPaintTicks(true);
		JSlider1.setMajorTickSpacing(200);
		simulation2D1.add(JSlider1);
		JSlider1.setBounds(36,192,72,192);
		simulation2D1.add(JTabbedPane1);
		JTabbedPane1.setBackground(java.awt.Color.white);
		JTabbedPane1.setBounds(192,24,480,456);
		displayConfiguration1.setLayout(null);
		JTabbedPane1.add(displayConfiguration1);
		displayConfiguration1.setBackground(java.awt.Color.lightGray);
		displayConfiguration1.setBounds(2,27,475,426);
		JTabbedPane1.setTitleAt(0,"Configuration");
		JLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		JLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		JLabel1.setText("Temperature (K)");
		simulation2D1.add(JLabel1);
		JLabel1.setBounds(12,144,120,40);
		JButton1.setText("Reset RDF");
		simulation2D1.add(JButton1);
		JButton1.setBackground(java.awt.Color.black);
		JButton1.setForeground(java.awt.Color.white);
		JButton1.setBounds(12,396,108,40);
		//}}
		integratorHard1.setTimeStep(0.005);
		phase1.add(rdf);
		rdfPlot.setXUnit(Angstrom.UNIT);
		rdfPlot.setMeter(rdf);
		JTabbedPane1.add(rdfPlot);
		rdf.setUpdateInterval(5);
		displayConfiguration1.setAlign(0,0);
		displayConfiguration1.setAlign(1,0);
		displayConfiguration1.setBounds(0,0,300,300);
		JTabbedPane1.setTitleAt(1,"RDF");
		JTabbedPane1.setBackground(Constants.KHAKI);
		displayConfiguration1.setBackground(Constants.KHAKI);
		JSlider1.setValue(350);
		IntegratorMD.Timer clock = new IntegratorMD.Timer(integratorHard1.chronoMeter());
		simulation2D1.add(clock);
		clock.setBounds(0,450,108,60);
		DisplayBox energy = new DisplayBox.Energy(phase1);
		simulation2D1.add(energy);
		energy.setBounds(0,510,108,60);
		energy.setUnit(Kelvin.UNIT);
		integratorHard1.setIsothermal(false);
		

		//{{REGISTER_LISTENERS
		SymChange lSymChange = new SymChange();
		JSlider1.addChangeListener(lSymChange);
		SymAction lSymAction = new SymAction();
		JButton1.addActionListener(lSymAction);
		//}}
	}

	//{{DECLARE_CONTROLS
	simulate.Simulation2D simulation2D1 = new simulate.Simulation2D();
	simulate.ControllerButton controllerButton1 = new simulate.ControllerButton();
	simulate.IntegratorHard integratorHard1 = new simulate.IntegratorHard();
	simulate.SpeciesDiskWell speciesDiskWell1 = new simulate.SpeciesDiskWell();
	simulate.Phase phase1 = new simulate.Phase();
	simulate.P2SquareWell P2SquareWell1 = new simulate.P2SquareWell();
	javax.swing.JSlider JSlider1 = new javax.swing.JSlider();
	javax.swing.JTabbedPane JTabbedPane1 = new javax.swing.JTabbedPane();
	simulate.DisplayConfiguration displayConfiguration1 = new simulate.DisplayConfiguration();
	javax.swing.JLabel JLabel1 = new javax.swing.JLabel();
	javax.swing.JButton JButton1 = new javax.swing.JButton();
	//}}
		MeterRDF rdf = new MeterRDF();
		DisplayPlot rdfPlot = new DisplayPlot();

	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);
		}
	}

	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
			integratorHard1.setTemperature(JSlider1.getValue());
		} catch (java.lang.Exception e) {
		}
	}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == JButton1)
				JButton1_actionPerformed(event);
		}
	}

	void JButton1_actionPerformed(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
			 
		JButton1_actionPerformed_Interaction1(event);
	}

	void JButton1_actionPerformed_Interaction1(java.awt.event.ActionEvent event)
	{
		try {
			// rdfSW Request the focus
			rdf.reset();
		} catch (java.lang.Exception e) {
		}
	}
}
