victor11035_PilotBuddy/gui.pde
/* =========================================================
 * ====                   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(PApplet appc, GWinData data) { 
  appc.background(230);
} //set mass value when changed(text box)

public void Mass_Typed(GTextField source, GEvent event) {
  valuesUpdated();
  Mass_Slide.setValue(int(Mass_Text.getText()));//set slider to new text box value
} //set mass value when changed(slider)

public void Mass_Dragged(GCustomSlider source, GEvent event) { //_CODE_:Mass_Slide:700779:
 valuesUpdated();
 Mass_Text.setText(str(Mass_Slide.getValueF()));//set text box to new slider value

} //_CODE_:Mass_Slide:700779:

public void Trust_Typed(GTextField source, GEvent event) { 
  valuesUpdated();
  Thrust_Slide.setValue(int(Thrust_Text.getText()));
} //set thrust value when changed(text box)

public void Trust_Dragged(GCustomSlider source, GEvent event) {
  valuesUpdated();
  Thrust_Text.setText(str(Thrust_Slide.getValueI()));//set text box to new slider value
}//set thrust value when changed(slider)

public void Drag_Dragged(GCustomSlider source, GEvent event) { 
 valuesUpdated();
 Drag_Text.setText(str(Drag_Slide.getValueF()));//set text box to new slider value
} //set drag percentage when cghange(slider)

public void Drag_Typed(GTextField source, GEvent event) { //_CODE_:Drag_Text:944596:
  //println("textfield3 - GTextField >> GEvent." + event + " @ " + millis());
} //set drag percentage when changed(text box)

public void DragCo_Typed(GTextField source, GEvent event) {
  //println("textfield4 - GTextField >> GEvent." + event + " @ " + millis());
} //set drage coefficent value whne changed(text box)

public void DragCo_Dragged(GCustomSlider source, GEvent event) { 
  valuesUpdated();
  DragCo_Text.setText(str(DragCo_Slide.getValueF()));//set text box to new slider value
} //set drag coefficent value when changed(slider)

public void WingE_Dragged(GCustomSlider source, GEvent event) {
 valuesUpdated();
 WingE_Text.setText(str(WingE_Slide.getValueI()));//set text box to new slider value
} //set wing efficency percentage when changed(slider)

public void WingE_Typed(GTextField source, GEvent event) { 
 // println("textfield5 - GTextField >> GEvent." + event + " @ " + millis());
} //set wing efficency percentage when changed(text box)

public void MaxV_Dragged(GCustomSlider source, GEvent event) {
  valuesUpdated();
  MaxV_Text.setText(str(MaxV_Slide.getValueF()));//set text box to new slider value
} //set maximun velocity value when changed(slider)

public void MaxV_Typed(GTextField source, GEvent event) { 
 // println("textfield6 - GTextField >> GEvent." + event + " @ " + millis());
} //_CODE_:MaxV_Text:851374:

public void Play_Clicked(GButton source, GEvent event) { //_CODE_:Play_Button:560141:
  if (running == false){//starts movement
    loop();
    running = true;
    Play_Button.setText("STOP");
  }
  else {//stops movement
    noLoop();
    running = false;
    Play_Button.setText("PLAY");}
   
} //_CODE_:Play_Button:560141:

public void Restart_Clicked(GButton source, GEvent event) { //_CODE_:Restart:403866:
  resetValues();
} //_CODE_:Restart:403866:

void resetValues(){

//set plane and buttons back to original state
    noLoop(); //noLoop so that the animation stops happening
    running = false; 
    Play_Button.setText("PLAY");
    myPlane.pos = new PVector (0,0);
    myPlane.planeVelocity = new PVector(0, 0);
    myPlane.planeOnGround = true;
    myPlane.planeFlyingSuccesfully = true;
    for(int i = 0; i < rubbleObjects.length; i++) { //sets the rubble back to their initial position using a for loop
      this.rubbleObjects[i].rubbleX = runwayLength;
      this.rubbleObjects[i].rubbleY = rubbleGroundPosition;
    }
    explosionWidth = 1;
    explosionHeight = 1;
    redraw();
}


// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setMouseOverEnabled(false);
  surface.setTitle("Sketch Window");
  window1 = GWindow.getWindow(this, "Window title", 210, 137, 200, 430, JAVA2D); //HERE
  window1.noLoop();
  window1.setActionOnClose(G4P.KEEP_OPEN);
  window1.addDrawHandler(this, "win_draw1");
  Label_Weight = new GLabel(window1, 0, 0, 180, 20);
  Label_Weight.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  Label_Weight.setText("Plane Weight (Kg)");
  Label_Weight.setOpaque(false);
  Mass_Slide = new GCustomSlider(window1, 50, 20, 100, 40, "grey_blue");
  Mass_Slide.setShowValue(true);
  Mass_Slide.setLimits(400.0, 10.0, 2000.0);
  Mass_Slide.setNumberFormat(G4P.DECIMAL, 2);
  Mass_Slide.setOpaque(false);
  Mass_Slide.addEventHandler(this, "Mass_Dragged");
  Label_Thrust = new GLabel(window1, 0, 60, 180, 20);
  Label_Thrust.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  Label_Thrust.setText("Engine Thrust (N)");
  Label_Thrust.setOpaque(false);
  Thrust_Slide = new GCustomSlider(window1, 50, 80, 100, 40, "grey_blue");
  Thrust_Slide.setShowValue(true);
  Thrust_Slide.setLimits(1000.0, 50.0, 40000.0);
  Thrust_Slide.setNumberFormat(G4P.DECIMAL, 2);
  Thrust_Slide.setOpaque(false);
  Thrust_Slide.addEventHandler(this, "Trust_Dragged");
  Label_Drag = new GLabel(window1, 0, 120, 180, 20);
  Label_Drag.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  Label_Drag.setText("Runway Length (m)");
  Label_Drag.setOpaque(false);
  Drag_Slide = new GCustomSlider(window1, 50, 140, 100, 40, "grey_blue");
  Drag_Slide.setShowValue(true);
  Drag_Slide.setLimits(1000, 100, 1300);
  Drag_Slide.setNumberFormat(G4P.INTEGER, 0);
  Drag_Slide.setOpaque(false);
  Drag_Slide.addEventHandler(this, "Drag_Dragged");
  Label_DragCo = new GLabel(window1, 0, 180, 180, 20);
  Label_DragCo.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  Label_DragCo.setText("Drag Coefficent (0-0.1)");
  Label_DragCo.setOpaque(false);
  DragCo_Slide = new GCustomSlider(window1, 50, 200, 100, 40, "grey_blue");
  DragCo_Slide.setShowValue(true);
  DragCo_Slide.setLimits(0.05, 0.01, 0.1);
  DragCo_Slide.setNumberFormat(G4P.DECIMAL, 2);
  DragCo_Slide.setOpaque(false);
  DragCo_Slide.addEventHandler(this, "DragCo_Dragged");
  Label_WingE = new GLabel(window1, 0, 240, 180, 20);
  Label_WingE.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  Label_WingE.setText("Lift-to-drag ratio (L/D)");
  Label_WingE.setOpaque(false);
  WingE_Slide = new GCustomSlider(window1, 50, 260, 100, 40, "grey_blue");
  WingE_Slide.setShowValue(true);
  WingE_Slide.setLimits(20, 0, 35);
  WingE_Slide.setNumberFormat(G4P.INTEGER, 0);
  WingE_Slide.setOpaque(false);
  WingE_Slide.addEventHandler(this, "WingE_Dragged");
  MaxV_Slide = new GCustomSlider(window1, 50, 320, 100, 40, "grey_blue");
  MaxV_Slide.setShowValue(true);
  MaxV_Slide.setLimits(1, 0.1, 10);
  MaxV_Slide.setNumberFormat(G4P.DECIMAL, 2);
  MaxV_Slide.setOpaque(false);
  MaxV_Slide.addEventHandler(this, "MaxV_Dragged");
  Label_MaxV = new GLabel(window1, 0, 300, 180, 20);
  Label_MaxV.setTextAlign(GAlign.CENTER, GAlign.MIDDLE);
  Label_MaxV.setText("Cross-sectional area (m^2)");
  Label_MaxV.setOpaque(false);
  Play_Button = new GButton(window1, 100, 380, 80, 30);
  Play_Button.setText("PLAY");
  Play_Button.addEventHandler(this, "Play_Clicked");
  Restart = new GButton(window1, 10, 380, 80, 30);
  Restart.setText("Restart");
  Restart.addEventHandler(this, "Restart_Clicked");
  window1.loop();
}

// Variable declarations 
// autogenerated do not edit
GWindow window1;
GTextField Mass_Text; 
GLabel Label_Weight; 
GCustomSlider Mass_Slide; 
GLabel Label_Thrust; 
GTextField Thrust_Text; 
GCustomSlider Thrust_Slide; 
GLabel Label_Drag; 
GCustomSlider Drag_Slide; 
GTextField Drag_Text; 
GLabel Label_DragCo; 
GTextField DragCo_Text; 
GCustomSlider DragCo_Slide; 
GLabel Label_WingE; 
GCustomSlider WingE_Slide; 
GTextField WingE_Text; 
GCustomSlider MaxV_Slide; 
GLabel Label_MaxV; 
GTextField MaxV_Text; 
GButton Play_Button; 
GButton Restart; 
