import java.awt.*;
import javax.swing.*;
import simulate.Simulation2D;
import simulate.SpeciesDisks;
import simulate.Phase;
import simulate.ControllerButton;
import simulate.P2IdealGas;
import simulate.IntegratorHard;
import simulate.DisplayConfiguration;
import simulate.*;

/**
 * A basic extension of the javax.swing.JApplet class
 */
public class Fluctuations extends JApplet
{
	public void init()
	{
	    phase1.setBoundary(Space2D.Boundary.HARD);
	    meterLocalDensity.setBounds(0,0,100,100);
		phase1.add(meterLocalDensity);
		displayConfiguration1.setDrawMeters(true);
		displayTable1 = new DisplayTable(false);
		displayScrollingGraph1.setVMin(0.0);
		displayScrollingGraph1.setVMax(60.0);
		// 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(748,486);
		simulation2D1.setLayout(null);
		getContentPane().add(simulation2D1);
		simulation2D1.setBackground(java.awt.Color.white);
		simulation2D1.setBounds(24,12,720,432);
		speciesDisks1.setDiameter(0.02);
		speciesDisks1.setNMolecules(77);
		speciesDisks1.setLayout(null);
		simulation2D1.add(speciesDisks1);
		speciesDisks1.setBounds(196,5,1,1);
		phase1.setLayout(null);
		simulation2D1.add(phase1);
		phase1.setBounds(202,5,1,1);
		phase1.add(meterDensity1);
		meterDensity1.setBounds(0,0,20,40);
		controllerButton1.setButtonColor(java.awt.Color.black);
		controllerButton1.setButtonTextColor(java.awt.Color.white);
		controllerButton1.setLayout(null);
		simulation2D1.add(controllerButton1);
		controllerButton1.setBounds(0,12,100,40);
		integratorHard1.setLayout(null);
		controllerButton1.add(integratorHard1);
		integratorHard1.setBounds(72,0,20,40);
		simulation2D1.add(P2IdealGas1);
		P2IdealGas1.setBounds(0,132,60,60);
		JPanel1.setLayout(null);
		simulation2D1.add(JPanel1);
		JPanel1.setBackground(java.awt.Color.white);
		JPanel1.setBounds(120,0,596,420);
		displayScrollingGraph1.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		JPanel1.add(displayScrollingGraph1);
		displayScrollingGraph1.setBounds(300,0,288,300);
		displayConfiguration1.setLayout(null);
		JPanel1.add(displayConfiguration1);
		displayConfiguration1.setBounds(0,12,300,300);
		displayTable1.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		JPanel1.add(displayTable1);
		displayTable1.setBounds(48,312,478,100);
		JPanel2.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
		simulation2D1.add(JPanel2);
		JPanel2.setBackground(java.awt.Color.white);
		JPanel2.setBounds(12,120,134,117);
		JButton1.setText("Smaller");
		JPanel2.add(JButton1);
		JButton1.setBounds(27,5,79,25);
		JButton2.setText("Larger ");
		JPanel2.add(JButton2);
		JButton2.setBounds(29,35,75,25);
		//}}
	
		//{{REGISTER_LISTENERS
		SymAction lSymAction = new SymAction();
		JButton1.addActionListener(lSymAction);
		JButton2.addActionListener(lSymAction);
		//}}
	}

	//{{DECLARE_CONTROLS
	simulate.Simulation2D simulation2D1 = new simulate.Simulation2D();
	simulate.SpeciesDisks speciesDisks1 = new simulate.SpeciesDisks();
	simulate.Phase phase1 = new simulate.Phase();
	simulate.MeterDensity meterDensity1 = new simulate.MeterDensity();
	simulate.ControllerButton controllerButton1 = new simulate.ControllerButton();
	simulate.IntegratorHard integratorHard1 = new simulate.IntegratorHard();
	simulate.P2IdealGas P2IdealGas1 = new simulate.P2IdealGas();
	javax.swing.JPanel JPanel1 = new javax.swing.JPanel();
	simulate.DisplayScrollingGraph displayScrollingGraph1 = new simulate.DisplayScrollingGraph();
	simulate.DisplayConfiguration displayConfiguration1 = new simulate.DisplayConfiguration();
	simulate.DisplayTable displayTable1 = new simulate.DisplayTable();
	javax.swing.JPanel JPanel2 = new javax.swing.JPanel();
	javax.swing.JButton JButton1 = new javax.swing.JButton();
	javax.swing.JButton JButton2 = new javax.swing.JButton();
	//}}
	simulate.MeterLocalDensityCube meterLocalDensity = new MeterLocalDensityCube();

	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);
			else if (object == JButton2)
				JButton2_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 {
			// convert double->int
			int oldSize = meterLocalDensity.getSize().width;
			int newSize = (int)(oldSize/1.1);
			meterLocalDensity.setSize(newSize,newSize);
		} catch (java.lang.Exception e) {
		}
	}

	void JButton2_actionPerformed(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
			 
		JButton2_actionPerformed_Interaction1(event);
	}

	void JButton2_actionPerformed_Interaction1(java.awt.event.ActionEvent event)
	{
		try {
			int oldSize = meterLocalDensity.getSize().width;
			int newSize = (int)(oldSize*1.1);
			meterLocalDensity.setSize(newSize,newSize);
		} catch (java.lang.Exception e) {
		}
	}
}
