public void setup() {
    size(800, 600);
    background(255);

    // Local variables to set where the components will be
    int margin = 16;
    int spacing = 36;
    int w = 128;
    int h = 32;

    // Initialize ControlP5
    controlP5 = new ControlP5(this);
    // Set the color of the labels
    controlP5.setColorLabel(color(255, 0, 0));

    // Add components
    controlP5.addButton("Clear Screen", 1, margin, spacing, w, h);
    controlP5.addSlider("Leaf Red", 0, 255, 255, margin, spacing * 2, w, h);
    controlP5.addSlider("Leaf Green", 0, 255, 64, margin, spacing * 3, w, h);
    controlP5.addSlider("Leaf Blue", 0, 255, 0, margin, spacing * 4, w, h);
    controlP5.addSlider("Branch Random", 0, PI, PI / 4, margin, spacing * 5, w, h);
    controlP5.addSlider("Leaf Random", 0, 32, 16, margin, spacing * 6, w, h);
    controlP5.addSlider("Leaf Size", 0, 32, 16, margin, spacing * 7, w, h);
    controlP5.addSlider("Start Size", 0, 128, 64, margin, spacing * 8, w, h);
  }
示例#2
0
  public void InitButton() {
    // Set zero acc e gyro
    controlP5
        .addButton("SET_ZERO")
        // .setValue(0)
        .setPosition(450, 50)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Read PID parameter
    controlP5
        .addButton("READ_PID")
        // .setValue(0)
        .setPosition(450, 90)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Write PID parameter
    controlP5
        .addButton("WRITE_PID")
        // .setValue(0)
        .setPosition(450, 130)
        .setSize(60, 20)
        .setColorBackground(c_blue);

    // Write PID parameter
    controlP5
        .addButton("SAVE_PID")
        //  .setValue(0)
        .setPosition(450, 170)
        .setSize(60, 20)
        .setColorBackground(c_blue);
    /*
          // START
      controlP5.addButton("START")
         .setPosition(650,50)
         .setSize(60,20)
         .setColorBackground(c_blue)
         ;

      // STOP
      controlP5.addButton("STOP")
         .setPosition(650,90)
         .setSize(60,20)
         .setColorBackground(c_blue)
         ;
    */
  }
示例#3
0
  public void setup() {
    size(1024, 768);
    background(0);
    frameRate(30);
    smooth();

    drawVectors = false;

    paused = true;

    timeline = new Timeline();

    sim = new GravitySimulation();

    sun = new Star(5000, 25, new PVector(300, 500), new PVector(0, 0), 0, "sun");
    planet = new Planet(10, 10, new PVector(500, 500), new PVector(0, 40), "planet");
    planet2 = new Planet(50, 10, new PVector(150, 500), new PVector(0, -40), "planet2");

    timeline.registerStatefulObject(sun);
    timeline.registerStatefulObject(planet);
    timeline.registerStatefulObject(planet2);

    controlP5 = new ControlP5(this);

    btnRewind = controlP5.addButton("btnRewind_OnClick", 0, 800, 20, 50, 20);
    btnRewind.setLabel("Rewind");

    btnPlayPause = controlP5.addButton("btnPlayPause_OnClick", 0, 860, 20, 50, 20);
    btnPlayPause.setLabel("Play");

    btnFastForward = controlP5.addButton("btnFastForward_OnClick", 0, 920, 20, 80, 20);
    btnFastForward.setLabel("Fast Forward");

    sliderTimeline = controlP5.addSlider("sliderTimeline_OnClick", 0, 10000, 0, 20, 720, 900, 10);
    sliderTimeline.setLabel("Timeline");
  }
示例#4
0
  /**
   * Creates a thin, dark standard button.
   *
   * @param name of the button
   * @param text to display on the button
   * @param x position of the button
   * @param y position of the button
   * @param m left margin of the text
   * @return a button object
   */
  private controlP5.Button createSelectButton(String name, String text, int x, int y) {
    controlP5.Button b =
        cp5.addButton(name)
            .setPosition(x, y)
            .setSize(100, 20)
            .setColorBackground(color(0, 200))
            .setColorActive(color(0, 200))
            .setColorForeground(color(0, 150));

    b.getCaptionLabel()
        .setFont(arialMain)
        .toUpperCase(false)
        .setSize(12)
        .setText(text)
        .setColor(color(140));

    return b;
  }
示例#5
0
  /**
   * Creates a standard button.
   *
   * @param name of the button
   * @param text to display on the button
   * @param x position of the button
   * @param y position of the button
   * @param m left margin of the text
   * @return a button object
   */
  @SuppressWarnings("deprecation")
  private controlP5.Button createButton(String name, String text, int x, int y, int m) {
    controlP5.Button b =
        cp5.addButton(name)
            .setPosition(x, y)
            .setSize(160, 35)
            .setColorBackground(color(0, 50))
            .setColorActive(color(0, 200))
            .setColorForeground(color(0, 150));

    b.getCaptionLabel()
        .setFont(arialB)
        .setText(text)
        .toUpperCase(false)
        .setSize(18)
        .setColor(color(200));
    b.captionLabel().getStyle().marginLeft = m;

    return b;
  }
示例#6
0
  /**
   * Creates the window, sets up the fonts and the libraries. Aligns all the buttons, backgrounds
   * and the text.
   */
  public void setup() {

    // Create window
    size(600, 500);

    // Select Fonts
    arialMain = createFont("ArialBold", 32);
    arialB = createFont("Arial", 16);

    // Set the controller
    cp5 = new ControlP5(this);

    // Main Menu text
    cp5.addTextlabel("mainText")
        .setPosition(width / 2 - 85, 30)
        .setText("Main Menu")
        .setFont(arialMain)
        .setColor(200);

    // Help Button
    buttonHelp = createButton("buttonHelp", "Help", 55, 85, 60);

    // Tournament Button
    buttonTournament = createButton("buttonTournament", "Tournament", 220, 85, 27);

    // Random Map Button
    createMap = createButton("createMap", "Random Map", 385, 85, 22);

    // A group to store all the brain related objects
    Group antBrains =
        cp5.addGroup("antBrains")
            .setBackgroundColor(color(0, 64))
            .setBackgroundHeight(270)
            .setWidth(490)
            .setTitle("Ant brain, you choose.")
            .setColorBackground(color(0, 100))
            .setPosition(55, 125)
            .hideArrow()
            .hideBar();

    // Load the background image for the brain group
    bg = loadImage("brainsbg.png");

    // A button is used to store the background image for the brain group.
    bgBrain =
        cp5.addButton("bgBrain")
            .setPosition(0, 0)
            .setImages(bg, bg, bg)
            .updateSize()
            .moveTo(antBrains)
            .setOff();

    // Select Red Brain Button
    selectRedBrain =
        createSelectButton("selectRedBrain", "Select Brain", 490 / 4 - 50, 140).moveTo(antBrains);

    // Select Black Brain Button
    selectBlackBrain =
        createSelectButton("selectBlackBrain", "Select Brain", 490 / 4 * 3 - 50, 140)
            .moveTo(antBrains);

    // Select Map Button
    selectMap =
        cp5.addButton("selectMap")
            .setPosition(0, 232)
            .setSize(490, 35)
            .setColorBackground(color(0, 200))
            .setColorActive(color(0, 200))
            .setColorForeground(color(0, 150))
            .moveTo(antBrains);

    // Set text and font options for the Select Map Button
    selectMap
        .getCaptionLabel()
        .setFont(arialB)
        .setText("Select Map")
        .toUpperCase(false)
        .setSize(18)
        .setColor(color(140))
        .getStyle()
        .setMarginLeft(190);

    // Start Button
    startButton =
        cp5.addButton("startButton")
            .setPosition(55, 400)
            .setSize(490, 65)
            .setColorBackground(color(115, 73, 73))
            .setColorActive(color(215, 73, 73))
            .setColorForeground(color(115, 73, 73))
            .lock();

    // Set text and font options for the Start Button
    startButton
        .getCaptionLabel()
        .setFont(arialB)
        .setText("START")
        .toUpperCase(false)
        .setSize(38)
        .setColor(color(140))
        .getStyle()
        .setMarginLeft(180);

    // Load the main background image
    bgMain = loadImage("bg.jpg");

    // Creates all the temporary files;
    createTempDir();
  }
示例#7
0
  public void setup() {

    size(600, 280);
    background(75);

    textSize(28);
    fill(0, 120, 170); // blue
    text("EvvGC GUI", 20, 50);
    text(Version, 170, 50);

    // Define colors
    b1 = color(80);
    b2 = color(60);
    c1 = color(80, 80, 80);
    c2 = color(60, 61, 59);

    controlP5 = new ControlP5(this); // initialize the GUI controls

    // List all the available serial ports:
    println(Serial.list());

    commListMax = -1;
    for (int i = 0; i < Serial.list().length; i++) {
      commListMax = i;
    }

    /**
     * ****************************PID
     * cells************************************************************
     */
    PitchP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("PitchP", 0, xPP, yPP, 40, 16));
    PitchP.setColorBackground(gray_);
    PitchP.setMin(0);
    PitchP.setDirection(Controller.HORIZONTAL);
    PitchP.setDecimalPrecision(2);
    PitchP.setMultiplier(0.01f);
    PitchP.setMax(2.54f);

    PitchD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("PitchD", 0, xPD, yPD, 40, 16));
    PitchD.setColorBackground(gray_);
    PitchD.setMin(0);
    PitchD.setDirection(Controller.HORIZONTAL);
    PitchD.setDecimalPrecision(2);
    PitchD.setMultiplier(0.01f);
    PitchD.setMax(1);

    RollP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollP", 0, xRP, yRP, 40, 16));
    RollP.setColorBackground(gray_);
    RollP.setMin(0);
    RollP.setDirection(Controller.HORIZONTAL);
    RollP.setDecimalPrecision(2);
    RollP.setMultiplier(0.01f);
    RollP.setMax(2.54f);

    RollD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollD", 0, xRD, yRD, 40, 16));
    RollD.setColorBackground(gray_);
    RollD.setMin(0);
    RollD.setDirection(Controller.HORIZONTAL);
    RollD.setDecimalPrecision(2);
    RollD.setMultiplier(0.01f);
    RollD.setMax(1);

    YawP = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawP", 0, xYP, yYP, 40, 16));
    YawP.setColorBackground(gray_);
    YawP.setMin(0);
    YawP.setDirection(Controller.HORIZONTAL);
    YawP.setDecimalPrecision(2);
    YawP.setMultiplier(0.01f);
    YawP.setMax(2.54f);

    YawD = (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawD", 0, xYD, yYD, 40, 16));
    YawD.setColorBackground(gray_);
    YawD.setMin(0);
    YawD.setDirection(Controller.HORIZONTAL);
    YawD.setDecimalPrecision(2);
    YawD.setMultiplier(0.01f);
    YawD.setMax(1);

    /**
     * ****************************Power
     * cells************************************************************
     */
    PitchPWR =
        (controlP5.Numberbox)
            hideLabel(controlP5.addNumberbox("PitchPWR", 0, xPPWR, yPPWR, 40, 16));
    PitchPWR.setColorBackground(gray_);
    PitchPWR.setMin(0);
    PitchPWR.setDirection(Controller.HORIZONTAL);
    PitchPWR.setDecimalPrecision(0);
    PitchPWR.setMultiplier(1);
    PitchPWR.setMax(100);

    RollPWR =
        (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("RollPWR", 0, xRPWR, yRPWR, 40, 16));
    RollPWR.setColorBackground(gray_);
    RollPWR.setMin(0);
    RollPWR.setDirection(Controller.HORIZONTAL);
    RollPWR.setDecimalPrecision(0);
    RollPWR.setMultiplier(1);
    RollPWR.setMax(100);

    YawPWR =
        (controlP5.Numberbox) hideLabel(controlP5.addNumberbox("YawPWR", 0, xYPWR, yYPWR, 40, 16));
    YawPWR.setColorBackground(gray_);
    YawPWR.setMin(0);
    YawPWR.setDirection(Controller.HORIZONTAL);
    YawPWR.setDecimalPrecision(0);
    YawPWR.setMultiplier(1);
    YawPWR.setMax(100);

    /**
     * ****************************Calibration
     * cells************************************************************
     */
    RollCal =
        (controlP5.Numberbox)
            hideLabel(controlP5.addNumberbox("RollCal", 0, xRollCal, yRollCal, 40, 16));
    RollCal.setColorBackground(gray_);
    RollCal.setMin(-10);
    RollCal.setDirection(Controller.HORIZONTAL);
    RollCal.setDecimalPrecision(1);
    RollCal.setMultiplier(0.2f);
    RollCal.setMax(10);
    buttonZeroRoll = controlP5.addButton("ZERO", 1, 535, 200, 40, 16);
    buttonZeroRoll.setColorBackground(gray_);

    /**
     * **************************Buttons********************************************************************
     */
    buttonWRITE = controlP5.addButton("WRITE", 1, 500, 248, 60, 20);
    buttonWRITE.setColorBackground(gray_);
    buttonREAD = controlP5.addButton("READ", 1, 40, 248, 60, 20);
    buttonREAD.setColorBackground(gray_);

    buttonCONFon = controlP5.addButton("CONFIGon", 1, 400, 10, 60, 60);
    buttonCONFon.setColorBackground(gray_);
    buttonCONFoff = controlP5.addButton("CONFIGoff", 1, 330, 10, 60, 60);
    buttonCONFoff.setColorBackground(gray_);

    buttonP0 = controlP5.addButton("P0", 1, 490, 5, 20, 20);
    buttonP0.setColorBackground(gray_);
    buttonP1 = controlP5.addButton("P1", 1, 490, 30, 20, 20);
    buttonP1.setColorBackground(gray_);
    buttonP2 = controlP5.addButton("P2", 1, 490, 55, 20, 20);
    buttonP2.setColorBackground(gray_);

    buttonRCOff = controlP5.addButton("RC_OFF", 1, 450, 122, 65, 20);
    buttonRCOff.setColorBackground(gray_);
    buttonRCOn = controlP5.addButton("RC_ON", 1, 450, 100, 65, 20);
    buttonRCOn.setColorBackground(gray_);

    buttonYawRC = controlP5.addButton("Yaw_RC_Pan", 1, 520, 100, 75, 20);
    buttonYawRC.setColorBackground(gray_);
    buttonYawAut = controlP5.addButton("Yaw_Auto_Pan", 1, 520, 122, 75, 20);
    buttonYawAut.setColorBackground(gray_);

    buttonCONFoff.setColorBackground(green_);
  }