/* =========================================================
 * ====                   WARNING                        ===
 * =========================================================
 * The code in this tab has been generated from the GUI form
 * designer and care should be taken when editing this file.
 * Only add/edit code inside the event handlers i.e. only
 * use lines between the matching comment tags. e.g.

 void myBtnEvents(GButton button) { //_CODE_:button1:12356:
     // It is safe to enter your event code here  
 } //_CODE_:button1:12356:
 
 * Do not rename this tab!
 * =========================================================
 */

synchronized public void win_draw1(GWinApplet appc, GWinData data) { //_CODE_:window1:677055:
  appc.background(255);
} //_CODE_:window1:677055:

public void csExpl_change1(GCustomSlider source, GEvent event) { //_CODE_:csExpl:499811:
  explode = csExpl.getValueF();
} //_CODE_:csExpl:499811:

public void csAgg_change1(GCustomSlider source, GEvent event) { //_CODE_:csAgg:315096:
  thv.setWait(round((1/csAgg.getValueF())*1000));
} //_CODE_:csAgg:315096:

public void pRegole_Click1(GPanel source, GEvent event) { //_CODE_:pRegole:224665:
} //_CODE_:pRegole:224665:

public void tfLon_change1(GTextField source, GEvent event) { //_CODE_:tfLon:673356:
} //_CODE_:tfLon:673356:

public void tfCrow_change1(GTextField source, GEvent event) { //_CODE_:tfCrow:374114:
} //_CODE_:tfCrow:374114:

public void tfMinN_change1(GTextField source, GEvent event) { //_CODE_:tfMinN:658076:
} //_CODE_:tfMinN:658076:

public void tfMaxN_change1(GTextField source, GEvent event) { //_CODE_:tfMaxN:314532:
} //_CODE_:tfMaxN:314532:

public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:604408:
  ogniTot = int(tfOgniTot.getText());
  
  loneliness = int(tfLon.getText());
  overcrowding = int(tfCrow.getText());
  minNeight = int(tfMinN.getText());
  maxNeight = int(tfMaxN.getText());

  thv.interrupt();
  istanziaBrodo();
  thv = new thVita();
  
} //_CODE_:button1:604408:

public void tfOgniTotchange1(GTextField source, GEvent event) { //_CODE_:tfOgniTot:934471:
} //_CODE_:tfOgniTot:934471:

public void csOpa_change1(GCustomSlider source, GEvent event) { //_CODE_:csOpa:589219:
  opacita = int(255 * csOpa.getValueI()/100);
} //_CODE_:csOpa:589219:



// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  if(frame != null)
    frame.setTitle("Sketch Window");
  window1 = new GWindow(this, "Window title", 0, 0, 338, 424, false, JAVA2D);
  window1.addDrawHandler(this, "win_draw1");
  lExplode = new GLabel(window1.papplet, 20, 30, 80, 20);
  lExplode.setText("Explode");
  lExplode.setTextBold();
  lExplode.setOpaque(false);
  csExpl = new GCustomSlider(window1.papplet, 130, 20, 190, 40, "grey_blue");
  csExpl.setShowValue(true);
  csExpl.setShowLimits(true);
  csExpl.setLimits(0.0, 0.0, 100.0);
  csExpl.setNumberFormat(G4P.DECIMAL, 2);
  csExpl.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  csExpl.setOpaque(false);
  csExpl.addEventHandler(this, "csExpl_change1");
  lAgg = new GLabel(window1.papplet, 10, 80, 100, 30);
  lAgg.setText("Aggiornamenti al secondo");
  lAgg.setTextBold();
  lAgg.setOpaque(false);
  csAgg = new GCustomSlider(window1.papplet, 130, 70, 190, 50, "grey_blue");
  csAgg.setShowValue(true);
  csAgg.setShowLimits(true);
  csAgg.setLimits(1.0, 0.3, 5.0);
  csAgg.setNbrTicks(5);
  csAgg.setNumberFormat(G4P.DECIMAL, 1);
  csAgg.setOpaque(false);
  csAgg.addEventHandler(this, "csAgg_change1");
  pRegole = new GPanel(window1.papplet, 11, 206, 320, 210, "Regole (su 26 cellule adiacenti)");
  pRegole.setCollapsible(false);
  pRegole.setDraggable(false);
  pRegole.setText("Regole (su 26 cellule adiacenti)");
  pRegole.setTextBold();
  pRegole.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  pRegole.setOpaque(true);
  pRegole.addEventHandler(this, "pRegole_Click1");
  lSeViva = new GLabel(window1.papplet, 10, 30, 80, 20);
  lSeViva.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  lSeViva.setText("Se Viva:");
  lSeViva.setTextBold();
  lSeViva.setOpaque(false);
  lSeMorta = new GLabel(window1.papplet, 10, 110, 80, 20);
  lSeMorta.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  lSeMorta.setText("Se Morta:");
  lSeMorta.setTextBold();
  lSeMorta.setOpaque(false);
  lmuoveSolit = new GLabel(window1.papplet, 10, 50, 170, 20);
  lmuoveSolit.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  lmuoveSolit.setText("Muore se ha meno di");
  lmuoveSolit.setOpaque(false);
  label1 = new GLabel(window1.papplet, 240, 50, 80, 20);
  label1.setText("vicini");
  label1.setOpaque(false);
  label2 = new GLabel(window1.papplet, 10, 70, 170, 20);
  label2.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  label2.setText("Muore se ha più di");
  label2.setOpaque(false);
  label3 = new GLabel(window1.papplet, 240, 70, 80, 20);
  label3.setText("vicini");
  label3.setOpaque(false);
  label4 = new GLabel(window1.papplet, 10, 130, 170, 20);
  label4.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  label4.setText("Vive se ha almeno");
  label4.setOpaque(false);
  label5 = new GLabel(window1.papplet, 240, 130, 80, 20);
  label5.setText("vicini");
  label5.setOpaque(false);
  label6 = new GLabel(window1.papplet, 10, 150, 170, 20);
  label6.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  label6.setText("Vive se ha al massimo");
  label6.setOpaque(false);
  label7 = new GLabel(window1.papplet, 240, 150, 80, 20);
  label7.setText("vicini");
  label7.setOpaque(false);
  tfLon = new GTextField(window1.papplet, 180, 50, 60, 20, G4P.SCROLLBARS_NONE);
  tfLon.setText("3");
  tfLon.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  tfLon.setOpaque(true);
  tfLon.addEventHandler(this, "tfLon_change1");
  tfCrow = new GTextField(window1.papplet, 180, 70, 60, 20, G4P.SCROLLBARS_NONE);
  tfCrow.setText("20");
  tfCrow.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  tfCrow.setOpaque(true);
  tfCrow.addEventHandler(this, "tfCrow_change1");
  tfMinN = new GTextField(window1.papplet, 180, 130, 60, 20, G4P.SCROLLBARS_NONE);
  tfMinN.setText("4");
  tfMinN.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  tfMinN.setOpaque(true);
  tfMinN.addEventHandler(this, "tfMinN_change1");
  tfMaxN = new GTextField(window1.papplet, 180, 150, 60, 20, G4P.SCROLLBARS_NONE);
  tfMaxN.setText("15");
  tfMaxN.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  tfMaxN.setOpaque(true);
  tfMaxN.addEventHandler(this, "tfMaxN_change1");
  button1 = new GButton(window1.papplet, 240, 180, 80, 30);
  button1.setText("Riavvia simulazione");
  button1.setTextBold();
  button1.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  button1.addEventHandler(this, "button1_click1");
  tfOgniTot = new GTextField(window1.papplet, 180, 180, 60, 20, G4P.SCROLLBARS_NONE);
  tfOgniTot.setText("2");
  tfOgniTot.setOpaque(true);
  tfOgniTot.addEventHandler(this, "tfOgniTotchange1");
  label8 = new GLabel(window1.papplet, 10, 180, 170, 20);
  label8.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
  label8.setText("Fai vivere una cellula ogni");
  label8.setOpaque(false);
  lOpac = new GLabel(window1.papplet, 10, -70, 80, 20);
  lOpac.setText("Opacità");
  lOpac.setTextBold();
  lOpac.setOpaque(false);
  csOpa = new GCustomSlider(window1.papplet, 120, -80, 190, 40, "grey_blue");
  csOpa.setShowValue(true);
  csOpa.setShowLimits(true);
  csOpa.setLimits(20.0, 0.0, 100.0);
  csOpa.setNumberFormat(G4P.INTEGER, 0);
  csOpa.setLocalColorScheme(GCScheme.CYAN_SCHEME);
  csOpa.setOpaque(false);
  csOpa.addEventHandler(this, "csOpa_change1");
  pRegole.addControl(lSeViva);
  pRegole.addControl(lSeMorta);
  pRegole.addControl(lmuoveSolit);
  pRegole.addControl(label1);
  pRegole.addControl(label2);
  pRegole.addControl(label3);
  pRegole.addControl(label4);
  pRegole.addControl(label5);
  pRegole.addControl(label6);
  pRegole.addControl(label7);
  pRegole.addControl(tfLon);
  pRegole.addControl(tfCrow);
  pRegole.addControl(tfMinN);
  pRegole.addControl(tfMaxN);
  pRegole.addControl(button1);
  pRegole.addControl(tfOgniTot);
  pRegole.addControl(label8);
  pRegole.addControl(lOpac);
  pRegole.addControl(csOpa);
}

// Variable declarations 
// autogenerated do not edit
GWindow window1;
GLabel lExplode; 
GCustomSlider csExpl; 
GLabel lAgg; 
GCustomSlider csAgg; 
GPanel pRegole; 
GLabel lSeViva; 
GLabel lSeMorta; 
GLabel lmuoveSolit; 
GLabel label1; 
GLabel label2; 
GLabel label3; 
GLabel label4; 
GLabel label5; 
GLabel label6; 
GLabel label7; 
GTextField tfLon; 
GTextField tfCrow; 
GTextField tfMinN; 
GTextField tfMaxN; 
GButton button1; 
GTextField tfOgniTot; 
GLabel label8; 
GLabel lOpac; 
GCustomSlider csOpa; 

