コード例 #1
0
  public ControlBroadcaster broadcast(final ControlEvent theControlEvent, final int theType) {
    if (broadcast) {
      for (ControlListener cl : _myControlListeners) {
        cl.controlEvent(theControlEvent);
      }
      if (theControlEvent.isTab() == false && theControlEvent.isGroup() == false) {
        if (theControlEvent.getController().getControllerPlugList().size() > 0) {
          if (theType == ControlP5Constants.STRING) {
            for (ControllerPlug cp : theControlEvent.getController().getControllerPlugList()) {
              callTarget(cp, theControlEvent.getStringValue());
            }
          } else if (theType == ControlP5Constants.ARRAY) {

          } else {
            for (ControllerPlug cp : theControlEvent.getController().getControllerPlugList()) {
              if (cp.checkType(ControlP5Constants.EVENT)) {
                invokeMethod(cp.getObject(), cp.getMethod(), new Object[] {theControlEvent});
              } else {
                callTarget(cp, theControlEvent.getValue());
              }
            }
          }
        }
      }
      if (_myControlEventType == ControlP5Constants.METHOD) {
        invokeMethod(
            _myControlEventPlug.getObject(),
            _myControlEventPlug.getMethod(),
            new Object[] {theControlEvent});
      }
    }
    return this;
  }
コード例 #2
0
ファイル: OpenWheels.java プロジェクト: praneybehl/OpenWheels
 public void controlEvent(ControlEvent theEvent) {
   // select com from list
   if (theEvent.isGroup() && theEvent.name().equals("portComList")) {
     println("Select portComList" + "   value = " + theEvent.group().value()); // for debugging
     InitSerial(theEvent.group().value()); // initialize the serial port selected
   }
 }
コード例 #3
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
  public void controlEvent(ControlEvent theEvent) {
    // PulldownMenu is if type ControlGroup.
    // A controlEvent will be triggered from within the ControlGroup.
    // therefore you need to check the originator of the Event with
    // if (theEvent.isGroup())
    // to avoid an error message from controlP5.
    if (theEvent.isGroup()) {
      if (theEvent.group().name() == "ruleChoiceList") {
        //    println(theEvent.group().value()+" from "+theEvent.group());
        selectedRule = PApplet.parseInt(theEvent.group().value());
        // has to be here for the controlp5 library
      }
    } else if (theEvent.isController()) {
      //    println(theEvent.controller().value()+" from "+theEvent.controller());
    }

    //  switch(theEvent.controller().id()) {
    //    case(1):
    //    myColorRect = (int)(theEvent.controller().value());
    //    break;
    //    case(2):
    //    myColorBackground = (int)(theEvent.controller().value());
    //    break;
    //    case(3):
    //    println(theEvent.controller().stringValue());
    //    break;
    //  }

  }
コード例 #4
0
 public void controlEvent(ControlEvent theEvent) {
   if (theEvent.isGroup()) {
     if (theEvent.group().name() == "optionsbox") {
       for (int i = 0; i < theEvent.group().arrayValue().length; i++) {
         optionsArray[i] = (int) theEvent.group().arrayValue()[i];
       }
       if (optionsArray[0] == 1) {
         translator = true;
       } else {
         translator = false;
       }
     }
   }
 }
コード例 #5
0
  public void controlEvent(ControlEvent theEvent) {
    // DropdownList is of type ControlGroup.
    // A controlEvent will be triggered from inside the ControlGroup class.
    // therefore you need to check the originator of the Event with
    // if (theEvent.isGroup())
    // to avoid an error message thrown by controlP5.

    /*  if (theEvent.getController().getName().equals("restart")) {
      paddles[0].points=0;
      paddles[1].points=0;
    }*/

    if (theEvent.isGroup()) {
      // check if the Event was triggered from a ControlGroup
      //  println("event from group : "+theEvent.getGroup().getValue()+" from
      // "+theEvent.getGroup());
      if (theEvent.getGroup().toString().equals("paddle1 [DropdownList]")) {
        println("paddle1 " + theEvent.getGroup().getValue());
        paddleSelector1 = translations[(int) theEvent.getGroup().getValue()];
        println(jointNames[paddleSelector1]);
      } else if (theEvent.getGroup().toString().equals("paddle2 [DropdownList]")) {
        println("paddle2 " + theEvent.getGroup().getValue());
        paddleSelector2 = translations[(int) theEvent.getGroup().getValue()];
        println(jointNames[paddleSelector2]);
      } else if (theEvent.getGroup().toString().equals("1_or_2_player [DropdownList]")) {
        if ((int) theEvent.getGroup().getValue() == 0) {
          onePlayer = true;
        } else {
          onePlayer = false;
        }
      } else if (theEvent.getGroup().toString().equals("speed [DropdownList]")) {
        if ((int) theEvent.getGroup().getValue() == 0) {
          ball.speed = new PVector(5, 5);
        } else if ((int) theEvent.getGroup().getValue() == 1) {
          ball.speed = new PVector(10, 10);
        } else if ((int) theEvent.getGroup().getValue() == 2) {
          ball.speed = new PVector(15, 15);
        }
      }
    } else if (theEvent.isController()) {
      println(
          "event from controller : "
              + theEvent.getController().getValue()
              + " from "
              + theEvent.getController());
    }
  }