コード例 #1
0
  /** Private method, fiducial has been updated */
  private void updated() {
    AbstractShape component = FiducialRegistry.getInstance().getFiducialComponent(EventID);

    if (component != null) {
      component.setPositionGlobal(event.getPosition());
      float oldAngle = (Float) component.getUserData("angle"); // retrieve the "old" angle
      float newAngle = event.getAngle();
      if (oldAngle != newAngle) {
        float diff = newAngle + oldAngle;
        component.setUserData("angle", newAngle);
        diff = MTApplication.degrees(diff); // our rotation expects degrees (not radians)
        component.rotateZ(component.getCenterPointRelativeToParent(), diff);
      }
    }
  }
コード例 #2
0
  /** Private method, handle a new fiducial */
  private void started() {
    AbstractShape roundingcircle =
        new MTEllipse(app, new Vector3D(event.getPosition()), 180, 180, 100);
    roundingcircle.setNoFill(false);
    float r = ToolsMath.getRandom(20, 255);
    float g = ToolsMath.getRandom(20, 255);
    float b = ToolsMath.getRandom(20, 255);
    roundingcircle.setFillColor(new MTColor(r, g, b, 200));
    roundingcircle.setNoStroke(false);
    roundingcircle.setStrokeWeight(1);
    roundingcircle.setStrokeColor(new MTColor(r, g, b, 200));
    roundingcircle.unregisterAllInputProcessors();

    AbstractShape component = new MTEllipse(app, new Vector3D(event.getPosition()), 20, 20, 20);
    component.setNoFill(false);
    float r1 = ToolsMath.getRandom(20, 255);
    float g1 = ToolsMath.getRandom(20, 255);
    float b1 = ToolsMath.getRandom(20, 255);
    component.setFillColor(new MTColor(r1, g1, b1, 200));
    component.setNoStroke(false);
    component.setStrokeWeight(1);
    component.setStrokeColor(new MTColor(r1, g1, b1, 200));
    component.unregisterAllInputProcessors(); // Dont process input/gestures on this component

    roundingcircle.addChild(component);

    MTColor white = new MTColor(255, 255, 255);

    IFont fontArial = FontManager.getInstance().createFont(app, "arial.ttf", 50, white);

    MTTextArea text = new MTTextArea(app, fontArial);
    text.setFillColor(new MTColor(0, 0, 0, 0));
    text.setStrokeColor(new MTColor(0, 0, 0, 0));
    text.unregisterAllInputProcessors();
    roundingcircle.addChild(text);
    text.setPositionRelativeToParent(
        new Vector3D(event.getPosition().x, event.getPosition().y - 120));

    roundingcircle.setUserData("angle", event.getAngle());

    MTKeyboard keys = KeyboardPool.getInstance(app).getKeyboard();
    roundingcircle.addChild(keys);
    keys.setPositionRelativeToParent(
        new Vector3D(event.getPosition().x, event.getPosition().y + 150));
    keys.setUserData("fiducialID", EventID);

    text.setExpandDirection(ExpandDirection.UP);
    text.unregisterAllInputProcessors();
    /*
     * Need to find a way to keep the text centred at all times.
     */
    // text.setEnableCaret(true);

    keys.addTextInputListener(text);
    keys.addInputListener(text);

    FiducialRegistry.getInstance().putFiducialCompoent(EventID, roundingcircle);

    String searchTerm = "Doctor Who";
    TwitterSearch twsearch = new TwitterSearch();
    twsearch.search(searchTerm);

    canvas.addChild(roundingcircle);
  }
コード例 #3
0
 /** Private method, dispose of fiducial */
 private void ended() {
   AbstractShape component = FiducialRegistry.getInstance().getFiducialComponent(EventID);
   component.destroy();
 }